I'm on Windows 11 in 64 bits and I wrote this code in assembly a64 but after being compiled and linked (with nasm and then ld) it just wait 3sec average and just stop :
bits 64
section .data
message db 'Hello World !', 10
section .text
global _start
_start:
mov rax, 1
mov rdi, 1
mov rsi, message
mov rdx, 13 1
syscall
mov rax, 60
mov rdi, 0
syscall
nasm command typed in powershell : nasm -f win64 file.asm -o file.o
then ld command : ld file.o -o file.exe
When I start this file in powershell it just wait 3 sec and stop. Same for cmd.
It's a test program for my compiler to see if it works and I don't know if I didn't write correctly the code or if those compiler or linker don't work on Win 11.
Note : also my processsor is an Intel
CodePudding user response:
- Windoze programs [generally] do not use
syscall
/sysenter
; you usually use the WinAPI. - Apart from adapting the “Hello World” referred to in David Wohlferd’s comment, you can meanwhile use the WSL, Windoh’s Subsystem for Linux, so you can still program with the familiar
syscall
interface. Obviously this requires an‑felf64
executable to begin with, but (without having tried that out) something likewsl ‑‑exec myProgram
should do the trick then. - Some style comment:
Filling
rdx
with13 1
is prone to error. Use anequ
constant instead.
CodePudding user response:
Two possibilities: 1. "The linux syscalls are not going to work on Windows".
Try it on Linux.
2.syscall instruction use MSR regsisters as target.Traditional eax syscall-number will not work.
Try replace "syscall" with "int 0x80"
Please provide more infomation