50 likes | 194 Views
SPIM syscalls. I/O. Appendix A: SPIM syscalls. usage. Put in the proper code in $v0 Put in the proper argument in $a0, if required syscall See examples following. .text # Other code # write("How many pennies?"); la $a0, manyPennies li $v0, 4 syscall
E N D
SPIM syscalls I/O
usage • Put in the proper code in $v0 • Put in the proper argument in $a0, if required • syscall • See examples following
.text # Other code # write("How many pennies?"); la $a0, manyPennies li $v0, 4 syscall # read(pennies); li $v0, 5 syscall sw $v0, pennies .data pennies: .space 4 manyPennies: .asciiz "How many pennies? "
# write(totalCents); write integer lw $a0, totalCents li $v0, 1 syscall # write(" cents"); write string la $a0, cents li $v0, 4 syscall # System.exit(0) li $v0, 10 syscall .data # other data definitions / initializations .align 2 totalCents: .space 4 cents: .asciiz “ cents”