Assembler code doesn't work on Linux
I'm trying to run the following assembler code in Linux using the JWasm compiler. 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.
;--- "hel开发者_开发百科lo 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.
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)
; usually denotes comments in most kinds of assembly, strange that JWasm doesn't recognize the lines as such. Try removing them.
精彩评论