Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .data
- x: .word 0
- y: .word 0
- s1: .asciiz "Number 1: "
- s2: .asciiz "Number 2: "
- s3: .asciiz "Addition: "
- .text
- main:
- # Get random num returned in $a0
- li $v0,41
- li $a0,0
- syscall
- # Load x with random num
- sw $a0,x
- # Get random num returned in $a0
- li $v0,41
- li $a0,0
- syscall
- # Load y with random num
- sw $a0,y
- # Load x and y into temp registers
- lw $t1,x
- lw $t2,y
- # Add x and y then place result in temp 0
- add $t0,$t1,$t2
- # Print s1 to screen
- li $v0,4
- la $a0,s1
- syscall
- # Print int x to screen
- li $v0,1
- lw $a0,x
- syscall
- # Print newline
- li $v0,11
- li $a0,'\n'
- syscall
- # Print s2 to screen
- li $v0,4
- la $a0,s2
- syscall
- # Print int y to screen
- li $v0,1
- lw $a0,y
- syscall
- # Print newline
- li $v0,11
- li $a0,'\n'
- syscall
- # Print s3 to screen
- li $v0,4
- la $a0,s3
- syscall
- # Print int x+y to screen
- li $v0,1
- la $a0,($t0)
- syscall
- # Print newline
- li $v0,11
- li $a0,'\n'
- syscall
- # Exit
- li $v0,10
- syscall
Add Comment
Please, Sign In to add comment