我在线查看,但我唯一能找到的就是这种语法PI = 3.1415,但由于一些莫名其妙的原因,这在我正在使用的MIPS模拟器程序中不起作用,这是MARS 4.5.我认为它应该工作,如果它是MIPS语言规范的一部分.在尝试组装一个简单的hello world程序时,编译器说我的代码中有一个无效的语言元素.这是代码本身:
################################################################################
# #
# 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
Run Code Online (Sandbox Code Playgroud)
你想要的是一个替代宏.常量通常指常量变量.
MIPS是一个指令集,它不会在指令本身旁边定义任何内容.宏由汇编程序实现,因此您需要检查汇编程序文档.
对于MARS,指令是.eqv.示例:
.eqv SYS_PRINT_STRING 4
li $v0, SYS_PRINT_STRING
Run Code Online (Sandbox Code Playgroud)