2016-06-17 4 views
1

私はオンラインで見ましたが、この構文はPI = 3.1415でしたが、これは私が使用しているMIPSシミュレータプログラムでは動作しません。これはMARS 4.5です。 MIPS言語仕様の一部であれば動作するはずです。単純なhelloワールドプログラムをアセンブルしようとすると、コンパイラは私のコードに無効な言語要素があると言います。コード自体は次のとおりです。どのようにMIPSアセンブリ言語で定数を定義しますか?

################################################################################ 
#                    # 
# This is a hello world program in the MIPS assembly language. It prints out # 
# "Hello, World!" on the screen and exits.          # 
#                    # 
################################################################################ 

# System call code constants 
SYS_PRINT_STRING = 4 
SYS_EXIT   = 10 

.data 
    msg: .asciiz "Hello, World!\n" 

.text 
.globl __start 
__start: 
    la $a0, msg    # Load the address of the string "msg" into the 
          # $a0 register 
    li $v0, SYS_PRINT_STRING # Store the system call for printing a string on 
          # the screen in the $v0 register 
    syscall 

    li $v0, SYS_EXIT   # Store the system call to exit the program in the 
          # $v0 register 
    syscall 

答えて

4

代替マクロが必要です。定数は通常、定数変数を参照します。
MIPSは命令セットであり、命令自体の横に何も定義していません。マクロはアセンブラによって実装されるため、アセンブラのドキュメントを確認する必要があります。

MARSの場合、ディレクティブは.eqvです。例:

.eqv SYS_PRINT_STRING 4 

li $v0, SYS_PRINT_STRING 
関連する問題