Wednesday, May 20, 2020

Store integer values in MIPS $gp memory

This is a simple MIPS program that stores arbitrary integer values in MIPS $gp memory (in ascending order). The code is fully documented.

Launch EzMIPSthe MIPS assembler simulator, copy the following MIPS code and paste it into EzMIPS. Assemble, Run.

# -------------- store integer values in $gp memory -------------- #

.text

# ................................................................ #
main:

ori $s0, $zero, 0x100           # $s0 = 0x100
sw $s0, 16($gp)                  # MEM[0x10008010]= 0x100

ori $s0, $zero, 0x1             # $s0 = 0x1
sw $s0, 0($gp)                  # MEM[0x10008000] = 0x1

ori $s0, $zero, 0x2             # $s0 = 0x2
sw $s0, 4($gp)                  # MEM[0x10008004] = 0x2

ori $s0, $zero, 0x1000          # $s0 = 0x1000
sw $s0, 20($gp)                 # MEM[0x10008014] = 0x1000

ori $s0, $zero, 0x10            # $s0 = 0x10
sw $s0, 8($gp)                 # MEM[0x10008008] = 0x10

ori $s0, $zero, 0x20            # $s0 = 0x20
sw $s0, 12($gp)                 # MEM[0x1000800c] = 0x20

# ................................................................ #

# Done, terminate program
li $v0, 10
syscall             # all done!

# ................................................................ #

Please let me know of any suggestions or bugs regarding the code above.

Regards,

Antonis

No comments:

Post a Comment