4 ms·
I'd love to see a version of this done using the linux amd64 syscall abi. I've written similar programs for 32bit linux (I know the syscall instruction by heart
by shanemhansen 12y ago
I'd love to see a version of this done using the linux amd64 syscall abi. I've written similar programs for 32bit linux (I know the syscall instruction by heart: int 0x80), but I understand 64bit is more complex.
- nitrogen 12y agoSounds complicated, if AMD and Intel both use different instructions for system calls: http://wiki.osdev.org/Sysenter http://wiki.osdev.org/Sysenter http://articles.manugarg.com/systemcallinlinux2_6.html http://articles.manugarg.com/systemcallinlinux2_6.html
- oso2k 12y agosyscall is the standard ABI for a 64-bit kernel in Long Mode [0]. [0] http://wiki.osdev.org/SYSENTER#Compatibility_across_Intel_and_AMD http://wiki.osdev.org/SYSENTER#Compatibility_across_Intel_an...
- oso2k 12y agoThe syscall version isn't much more complex. You can compare the syscall ABIs here [0] [0] http://en.wikibooks.org/wiki/X86_Assembly/Interfacing_with_Linux#Making_a_syscall http://en.wikibooks.org/wiki/X86_Assembly/Interfacing_with_L...
- tbirdz 12y agoI don't know if I would call it harder, it's just a bit different is all. Here you go: ; Hello World, linux x86_64, nasm syntax section .rodata ; Begin read only data section hello: db "Hello, World",0x0a ; String, 0x0a is \n hello_len equ $-hello ; $ is current address, length is address after string - address of start of string section .text ; begin code section global _start ; export _start so the linker can see it _start: ; program entry point mov rax, 1 ; write(2) syscall number mov rdi, 1 ; stdout mov rsi, hello ; string address mov rdx, hello_len ; string length syscall ; execute the write syscall mov rax, 60 ; exit(2) syscall number mov rdi, 0 ; exit status syscall ; execute the exit syscall