## ECE2030 Intro to Computer Engineering ## ## Array.s ## ## Author: Prof. Hsien-Hsin S. Lee ## ## School of Electrical & Computer Engineering ## Georgia Institute of Technology ## Atlanta, GA 30332 ## ## leehs@gatech.edu ## ## .data .globl array_A array_A: .ascii "MIPS----SPIM " .ascii "O:-) " .word 0x64636261 .word 0x33323130 .word 0x00000000 .word 0x00000000 array_B: .space 64 .word 0x00000000 A_name: .asciiz "array_A= " # end with a NULL character B_name: .asciiz "array_B= " caret: .asciiz "\n" # Standard startup code. Invoke the routine main with no arguments. .text .globl __start __start: jal main addu $0, $0, $0 # Nop addiu $v0, $0, 10 syscall # syscall 10 (exit) .globl main main: addu $20, $0, $31 # Save return PC divu $20, $0 la $8, array_A la $13, array_B loop: lw $15, ($8) beqz $15, end_loop lb $9, ($8) lb $10, 1($8) lb $11, 2($8) lb $12, 3($8) sb $12, ($13) sb $11, 1($13) sb $10, 2($13) sb $9, 3($13) addiu $13, $13, 4 addiu $8, $8, 4 j loop end_loop: li $v0, 4 la $a0, A_name syscall # system call (type 4) for printing out string (See fig A.17 in Appendix A) la $a0, array_A # point the base address of crypt to register $a0 (=$4) syscall # make system call, this will print out all the strings pointed by address in $a0, i.e. crypt, which # is unreadable la $a0, caret syscall la $a0, B_name syscall # system call (type 4) for printing out string (See fig A.17 in Appendix A) la $a0, array_B # point the base address of crypt to register $a0 (=$4) syscall # make system call, this will print out all the strings pointed by address in $a0, i.e. crypt, which # is unreadable la $a0, caret syscall Exit: jr $31