Hello World in assembly on x86-64 Windows vs. Linux with int 0x80 system call

36 views Asked by At

I'm just starting out in the world of Assembly and I made this little code in a Linux environment with the help of a book, but I'd like to compile and run the code in a Windows environment.

section .data
  var_msg db 0xA,'hello world', 0xA, ; Nessa sessão armazena-se variáveis
  var_len equ $ - var_msg                ; Variavel len que  recebe o tamanho da string


section .text
global _start

_start:
  mov eax, 4            ; Metodo de escrita (sys_write)
  mov ebx, 1            ; Metodo de saida (std_out)
  mov ecx, var_msg      ; Armazenar Mensagem
  mov edx, var_len      ; Armazenar Tamanho
  int 0x80              ; Chamando o Kernel

  mov eax, 1            ; Metodo de Saída
  int 0x80              ; Chamando o Kernel

I am compiling on Linux using:

nasm -f elf64 hello.asm -o hello.o
ld -s -o hello hello.o
./hello

And Windows:

nasm -f win64 hello.asm -o hello.o
ld hello.o -o hello.exe

When I compile in Windows it doesn't give any errors, but running it doesn't show hello world on the screen the way it does on Linux.

0

There are 0 answers