berikut sintaxnya :
.datamsg1:.asciiz "Masukkan uang Anda : "msg2:.asciiz "\nPecahan 50000 : "msg3:.asciiz "\nPecahan 20000 : "msg4:.asciiz "\nPecahan 10000 : "msg5:.asciiz "\nPecahan 5000 : "msg6:.asciiz "\nPecahan 1000 : "msg7:.asciiz "\nCoba lagi(0/1): "msg8:.asciiz "#### Selesai ####".text.globl mainmain:li $v0, 4la $a0,msg1syscallli $v0, 5syscalladd $t0,$zero,$v0 #t0 = inputan userli $t1,1000div $t0,$t1mfhi $t2bne $t2,$zero,main #kembali minta input bila inputan bukan kelipatan 1000li $t1,50000 #t1 = 50000div $t0,$t1mflo $t2 #t2 = t0 div t1li $v0, 4la $a0, msg2syscall #menampilkan message 2move $a0,$t2li $v0, 1syscall #menampilkan hasilmfhi $t0 #t0 = t0 mod t1li $t1,20000div $t0,$t1mflo $t2 #t2 = t0 div t1li $v0, 4la $a0, msg3syscall #menampilkan message 3move $a0,$t2li $v0, 1syscall #menampilkan hasilmfhi $t0 #t0 = t0 mod t1li $t1,10000div $t0,$t1mflo $t2 #t2 = t0 div t1li $v0, 4la $a0, msg4syscall #menampilkan message 4move $a0,$t2li $v0, 1syscall #menampilkan hasilmfhi $t0 #t0 = t0 mod t1li $t1,5000div $t0,$t1mflo $t2 #t2 = t0 div t1li $v0, 4la $a0, msg5syscall #menampilkan message 5move $a0,$t2li $v0, 1syscall #menampilkan hasilmfhi $t0 #t0 = t0 mod t1li $t1,1000div $t0,$t1mflo $t2 #t2 = t0 div t1li $v0, 4la $a0, msg6syscall #menampilkan message 6move $a0,$t2li $v0, 1syscall #menampilkan hasilmessage:li $v0, 4la $a0, msg7syscallli $v0,5syscallli $t1,1beq $v0,$t1,mainbne $v0,$zero, messageexit:li $v0, 4la $a0, msg8syscalljr $ra
Print Screen hasilnya :
No comments:
Post a Comment