PIZZA_SIZE_OFFSET = 0 PIZZA_PRICE_OFFSET = 12 PIZZA_STRUCT_SIZE = 16 .text main: main__prologue: begin push $ra push $s0 push $s1 main_body: li $v0, 4 la $a0, menu_str # printf("The available pizza options are:\n"); syscall li $s0, 0 #int i = 0; main_loop_cond: bge $s0, 3, main_loop_end la $s1, pizza_t mul $t1, $s0, PIZZA_STRUCT_SIZE add $s1, $s1, $t1 move $a0, $s1 li $a1, 100 jal increase_price move $a0, $s1 jal print_pizza #forgot these lines in class addi $s0, 1 b main_loop_cond main_loop_end: li $v0, 0 # return 0 main__epilogue: pop $s1 pop $s0 pop $ra end jr $ra ######################## print_pizza: print_pizza_prologue: begin #forgot this in class and caused seg fault push $ra push $s0 push $s1 print_pizza_body: move $t0, $a0 li $v0, 4 la $a0, size_str syscall li $v0, 4 la $a0, PIZZA_SIZE_OFFSET($t0) syscall li $v0, 4 la $a0, price_str syscall li $v0, 1 lw $a0, PIZZA_PRICE_OFFSET($t0) syscall li $v0, 4 la $a0, cents_str syscall print_pizza_epilogue: pop $s1 pop $s0 pop $ra end jr $ra ######################### increase_price: increase_price_prologue: begin push $ra push $s0 push $s1 increase_price_body: move $t0, $a0 move $t1, $a1 lw $t2, PIZZA_PRICE_OFFSET($t0) add $t3, $t2, $t1 sw $t3, PIZZA_PRICE_OFFSET($t0) increase_price_epilogue: pop $s1 pop $s0 pop $ra end jr $ra ######################### .data pizza_t: .asciiz "small" .space 4 .space 2 .word 300 .asciiz "medium" .space 3 .space 2 .word 550 .asciiz "large" .space 4 .space 2 .word 800 menu_str: .asciiz "The available pizza options are:\n" size_str: .asciiz "Size: " price_str: .asciiz ", price: " cents_str: .asciiz " cents\n" #TODO # {"small", 300}, # {"medium", 550}, # {"large", 800}