Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .data ###
- text1: .asciiz "Bitte geben Sie eine Zahl ein: "
- .text ###
- main:
- la $a0, text1 #Load text1 in a0
- li $v0, 4 #v0= 4, print string, a0
- syscall
- li $v0, 5 #v0= 5, read int, Eingabe
- syscall
- li $t3, 1 #t3=1
- li $t2, 1 #t2=1
- li $t0, 1 #t0 = 1
- li $t4, 0
- li $t5, 0
- beq $t4, $v0, null # If v0 == t0, Springe auf null
- nop
- move $t4, $v0 #t4=<-v0
- bltz $v0, negation #Brachend less than zero,falls $vo <0 negation ausführen
- nop
- j loop
- nop
- negation:
- sub $t4, $t5, $v0 # t4 = 0 - (-3) = 3
- j loop #j=jump
- nop
- loop:
- add $t5, $t5, $t2
- beq $t4, $t0, breyk #solange $t4 = $t0
- addi $t2, $t2, 2 #t2 = t2 + 2
- nop
- sub $t4, $t4, $t3 #t4= t4 - 1
- j loop
- nop
- breyk:
- move $a0, $t5 #ergebnis t2 nach a0 kopiert
- li $v0, 1 #Print int
- syscall
- li $v0, 10 #exit
- syscall
- null:
- li $a0, 0
- li $v0, 1 #v0=1, print int a0, Ausgabe 0
- syscall
- li $v0, 10 #Exit
- syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement