sw
, sh
, and sb
Instructions
sw rd, mem
# store word
sh rd, mem
# store halfword
sb rd, mem
# store byte
sw |
sh |
sb |
---|---|---|
.data X: .word 1 .byte 2 Y: .word 3 .text li $t0, 1 sw $t0, X+4 lw $a0, Y li $v0, 1 syscall |
.data X: .byte 1 Y: .half 2 .text li $t0, 1 sh $t0, X+2 lh $a0, Y li $v0, 1 syscall |
.data s: .asciiz "abc" .text li $t0, 'd' # 'd': character d sb $t0, s+2 la $a0, s li $v0, 4 syscall |
Output | Output | Output |
Johnny collected lots of money from trick or treating and he went to the candy store to buy some chocolate. “You should give that money to charity”, said the shopkeeper. “No, I’ll buy the chocolate. YOU give the money to charity!” |