branch - Assembly/MIPS: branching -


i'm trying compare 2 numbers using branching. using youtube video tried learn branching video doesn't explain happens when condition false. program running both of labels instead of branch true. program follows:

#branch if equal  .data   message: .asciiz "the numbers equal." message2: .asciiz "the numbers differnet."  .text  main:     #set temp regs t0 , t1 5 , 20 respectively      addi $t0, $zero, 5      addi $t1, $zero, 21       #if t0 , t1 eaual, branch label numbersequal     beq $t0, $t1, numbersequal     #if t0 , t1 not equal, branch label numbersdifferent     bne $t0, $t1, numbersdifferent      #syscall end program      li  $v0, 10      syscall   numbersdifferent: #syscall retrieve message , print text        li $v0, 4     la $a0, message2     syscall  numbersequal: #syscall retrieve message , print text      li $v0, 4      la $a0, message      syscall 


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -