30 likes | 156 Vues
This MIPS assembly program demonstrates basic syscalls, including printing messages and copying strings. It begins by printing a greeting message, then waits for user input, and finally displays a message indicating that the program is done. The string copy function, `strcpy`, is implemented to clone data from one location to another in memory. This code serves as a practical example of handling data in MIPS assembly and utilizing system calls effectively.
E N D
SPIM syscalls • http://www.inf.pucrs.br/~eduardob/disciplinas/arqi/mips/syscall_codes.html
.data msg_hello: .asciiz "Hello! This is CDA3100!\n" msg_empty: .space 400 msg_done: .asciiz "done!\n" .text .globl main main: done: li $v0,1 li $a0,100 syscall li $v0,5 syscall li $v0,4 la $a0,msg_hello syscall li $v0,4 la $a0,msg_empty syscall la $a0,msg_empty #dst la $a1,msg_hello #src jal strcpy li $v0,4 la $a0,msg_empty syscall li $v0,10 #exit syscall strcpy: addi $t0, $a0, 0 addi $t1, $a1, 0 strcpyloop: lb $t3, 0($t1) sb $t3, 0($t0) beq $t3, $0, strcpydone addi $t0, $t0, 1 addi $t1, $t1, 1 j strcpyloop strcpydone: jr $ra