如何解决在mackbook上编译并运行程序集
我正在上一门计算机结构课程,我迷路了。 我得到了以下文件:Hello.s:
#This is a simple "Hello World!" program
.section .rodata #read only data section
str: .string "Hello World!\n"
########
.text #the beginnig of the code
.globl main #the label "main" is used to state the initial point of this program
.type main,@function # the label "main" representing the beginning of a function
main: # the main function:
pushq %rbp #save the old frame pointer
movq %rsp,%rbp #create the new frame pointer
movq $str,%rdi #the string is the only paramter passed to the printf function (remember- first parameter goes in %rdi).
movq $0,%rax
call printf #calling to printf AFTER we passed its parameters.
#return from printf:
movq $0,%rax #return value is zero (just like in c - we tell the OS that this program finished seccessfully)
movq %rbp,%rsp #restore the old stack pointer - release all used memory.
popq %rbp #restore old frame pointer (the caller function frame)
ret #return to caller function (OS)
我尝试了最幼稚的事情,走进航站楼,然后写道:
gcc Hello.s
我收到以下消息:
Hello.s:2:19: error: unexpected token in '.section' directive
.section .rodata #read only data section
^
Hello.s:7:2: error: unknown directive
.type main,@function # the label "main" representing the beginning of a function
^
我完全迷路了,我不知道该怎么办。我的教授没有帮助,几乎所有其他学生都拥有一台Windows pc,并以不同的方式解决了这个问题。
我该怎么办?有我应该下载的程序吗?在购买Windows计算机之前,我能做些什么?
请谨慎回答,因为我不是专家。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。