グローバル変数の代入
.data
.globl src
src: .word 2001
.globl dst
dst: .word 0
.text
.globl main
main:
la $t0, src
lw $s0, 0($t0)
la $t1, dst
sw $s0, 0($t1)
li $v0, 0
jr $ra
実行。printでメモリアドレスとか内容が表示されるので、runの前後で比較する。
$ spim
SPIM Version 7.4 of January 1, 2009
Copyright 1990-2004 by James R. Larus (larus@cs.wisc.edu).
All Rights Reserved.
See the file README for a full copyright notice.
Loaded: /opt/local/share/spim/exceptions.s
(spim) load "ls.as"
(spim) print dst
Data seg @ 0x10010004 (268500996) = 0x00000000 (0)
(spim) print src
Data seg @ 0x10010000 (268500992) = 0x000007d1 (2001)
(spim) run
(spim) print dst
Data seg @ 0x10010004 (268500996) = 0x000007d1 (2001)
(spim) print src
Data seg @ 0x10010000 (268500992) = 0x000007d1 (2001)