简体   繁体   English

汇编程序代码在Linux上不起作用

[英]Assembler code doesn't work on Linux

I'm trying to run the following assembler code in Linux using the JWasm compiler. 我正在尝试使用JWasm编译器在Linux中运行以下汇编代码。 But for all commands, it says, command not found. 但是说,对于所有命令,找不到命令。 Why? 为什么? And it returns an error in the lines which starts with ";". 并且它在以“;”开头的行中返回错误。 Is it a kind of a comment line? 这是一种评论专栏吗? Can I remove this lines? 我可以删除这行吗? Thanks. 谢谢。

;--- "hello world" for 64-bit Linux, using SYSCALL.
;--- assemble: JWasm -elf64 -Fo=Lin64_1.o Lin64_1.asm
;--- link:     gcc Lin64_1.o -o Lin64_1


stdout    equ 1
SYS_WRITE equ 1
SYS_EXIT  equ 60

.data

string  db 10,"Hello, world!",10

.code

_start:
mov edx, sizeof string
mov rsi, offset string
mov edi, stdout
mov eax, SYS_WRITE
syscall
mov eax, SYS_EXIT
syscall

end _start

I am unfamiliar with JWasm, but generally un-indented entries are assembler directives and not instructions. 我不熟悉JWasm,但通常不缩进的条目是汇编器指令,而不是指令。

You want to place a (space/tab) for any actual assembler instructions (things the CPU would run), not assembler directives (things the assembler uses to help you out) 您要为任何实际的汇编程序指令(CPU将运行的内容)而不是汇编程序指令(汇编程序用来帮助您的内容)放置一个(空格/制表符)

; ; usually denotes comments in most kinds of assembly, strange that JWasm doesn't recognize the lines as such. 通常在大多数程序集中都表示注释,奇怪的是JWasm无法识别出这样的行。 Try removing them. 尝试删除它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM