このプログラムのドキュメントは非常に限られています。それを行うために私が引き出すことができるものはほとんどありません。プログラムの PDF に加えて、これだけがあります。
.data
format_str: .asciiz "%dth of %s:\n%s version %i.%i is being tested!"
s1: .asciiz "June"
s2: .asciiz "EduMIPS64"
fs_addr: .space 4
.word 5
s1_addr: .space 4
s2_addr: .space 4
.word 0
.word 5
test:
.code
daddi r5, r0, format_str
sw r5, fs_addr(r0)
daddi r2, r0, s1
daddi r3, r0, s2
sd r2, s1_addr(r0)
sd r3, s2_addr(r0)
daddi r14, r0, fs_addr
syscall 5
syscall 0
ここで確認できます。EDU/WINMIPS64 は、通常の MIPS アセンブリとは大きく異なります。
これを説明する段落がいくつかありますが、あまり役に立ちません。いずれにせよ、これはいくつかの文字列パラメーター (s1 と s2 に格納されている) と整数パラメーター (どこに格納されているのでしょうか?) とともに、フォーマットされた文字列を出力します。
2 つの配列がメモリに格納されています。私はそれらに個人的に指示を実行しましたが、今はそれらを印刷したいと思っています。このようなフォーマットされた文字列に、これらの 2 つの整数 (ダブル ワードであり、格納するには 8 バイトが必要です) を指定するにはどうすればよいですか? ヘルプ資料には説明がありません。
これは、私がこの時点までに作成できたコードです(コメントが多い):
....
dadd $s4, $zero, $zero ; i = 0
printOutput: ; print results from the 2 arrays
beq $s4, 960, end ; if (i = size = 960 / 8) goto end
dadd $s1, $s4, $s2 ; full address of 1st array
dadd $s0, $s4, $s3 ; full address of 2nd array
daddi $a3, $zero, printString ; address ofstring to be printed stored in $a3
ld $v0, 0($s1) ; $v0 will be used to print 1st array[i]. Is this right?
ld $v1, 0($s2) ; $v1 will be used to print 2nd array[i]. Is this right? Which register to use for supplying a formatted string to print integers? It is not explained anywhere!
dadd $14, $zero, $a3 ; print string. $14 is the register to syscall instructions. But i'm just guessing with this. I really don't know how it should handle. I just supplied $a3 because it seems more intuitive.
syscall 5 ; prints ouput (on the MEM stage)
daddi $s4, $s4, 8 ; i++
j printOutput
end:
誰かがこれを行う方法を知っているなら、彼/彼女が共有できればとてもうれしいです. これに関する例はどこにもありません。ありがとう。
アップデート
Michael の助けを借りて試行錯誤を重ね、問題の主な原因を突き止めました。出力文字列とその他のメモリ アドレスのラベルを提供する順序は非常に重要です。試行錯誤の結果、次の順序に従わなければならないことがわかりました。
.data
format_string .asciiz "%d and %i etc.."
start_address .space 4
syscallArg1 .space 4 ; 1st parameter to syscall 5
syscallArg2 .space 4 ; 2nd parameter to syscall 5
---other labels go here---
.text
---code---
$14
start_address ラベルに指定する必要があることに注意してください。これには何も含まれてはなりません (使用可能な空きスペースのみ)。この文字列の前にフォーマットされた文字列があり、この文字列の後にsyscall 5
must への引数があります。他のラベルは、それらすべての後または前に配置できます。