Request for an example x68 assembler portable Hello World script
- Date: Fri, 26 Apr 2019 00:25:12 -0700
- From: Jesse Thompson <jesset@xxxxxxxxx>
- Subject: Request for an example x68 assembler portable Hello World script
I would like to learn how to write assembly programs for the command line
that with as little alteration as is feasable will compile both in Cygwin
and in other flavors of Unix like Linux and/or FreeBSD.
I am targeting only x64 CPUs and I'm perfectly happy to use libc calls
instead of direct syscalls or interrupts. I'm hoping to use nasm+gcc, or
perhaps fasm to do the deed. Crosspiling is not a concern, I'll build
cygwin binaries in cygwin and unix binaries in unix.
But I'm confused by the differences in calling convention/ABI between
Windows and/or Cygwin and Linux?
For example, I can get this to compile and run in Cygwin:
sub rsp, 20h ; Reserve the shadow space
mov rcx, message ; First argument is address
call puts ; puts(message)
add rsp, 20h ; Remove shadow space
db 'Hello', 0 ; C strings need a zero
byte at the end
but it segfaults in Linux (and complains about "Symbol `puts' causes
overflow in R_X86_64_PC32 relocation")
and I can get the following to compile and run in Linux:
db "Hello World",0
but *that* segfaults in cygwin.
TL;DR: I think I could get a lot more done if I could start from a single
Hello World asm file that can compile and run in both places, calling out
to puts or something simple like that.
Any help would be appreciated, I hope everything about my question makes
- - Jesse
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple