assembly - Simple Addition in MIPS -
assembly - Simple Addition in MIPS -
i'm in mips assembly class , book utilize out of print relying upon net help may understand. programme taking in 3 integers. 2 of them add/sub/mult/div , 3rd operator. here code.
.text .globl __start __start: # prompt first int , take first int la $a0,firstint li $v0,4 syscall li $v0,5 move $s0, $v0 syscall # prompt sec int , take sec int la $a0,firstint li $v0,4 syscall li $v0,5 move $s1, $v0 syscall # prompt operation la $a0,operation li $v0,4 syscall li $v0,5 move $s2, $v0 syscall beq $s2,0,__add0 li $v0,10 syscall __add0: la $a0,added li $v0,4 syscall add together $a0, $s0, $s1 li $a0,1 syscall .data firstint: .asciiz "enter first integer: " secondint: .asciiz "enter sec integer: " operation: .asciiz "enter operation (add=0, subtract=1, multiply=2, divide=3): " added: .asciiz "the added number is: "
my understanding beq jump add0 if value in $s2 equal 0.. not seem happening. output stops after entering operation type. illustration output:
enter first integer: 10 come in first integer: 5 come in operation (add=0, subtract=1, multiply=2, divide=3): 0 -- programme finished running --
any ideas?
you have syscall before move:
li $v0,5 syscall move $s2, $v0
assembly mips
Comments
Post a Comment