1

I'm trying to print hello word with assembly on Windows 10. I successfully converted the object file to executable file with nasm -f elf64 hello.asm and ld hello.o -o hello but when I run the file nothing print on screen .

My code:

section .text
   global _start     ;must be declared for linker (ld)

_start:             ;tells linker entry point
   mov  edx,len     ;message length
   mov  ecx,msg     ;message to write
   mov  ebx,1       ;file descriptor (stdout)
   mov  eax,4       ;system call number (sys_write)
   int  0x80        ;call kernel

   mov  eax,1       ;system call number (sys_exit)
   int  0x80        ;call kernel

section .data
msg db 'Hello, world!', 0xa  ;string to be printed
len equ $ - msg     ;length of the string
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
karam
  • 33
  • 7
  • 1
    `int 0x80` is for 32-bit Linux. You'll have to use Windows API functions, such as `WriteConsole` if you want this to run on Windows. – Michael Mar 06 '20 at 11:02
  • 2
    And in case you are using WSL, that only supports 64 bit so find a 64 bit example. – Jester Mar 06 '20 at 11:27
  • i used windows api and evrything work fine i joind alink that solved my problem in the comment below thank you all for the help – karam Mar 06 '20 at 11:57
  • 1
    i used windows api and evrything worked fine i joind a link to somone who solved my problem https://stackoverflow.com/questions/1023593/how-to-write-hello-world-in-assembler-under-windows thank you all for the help – karam Mar 06 '20 at 12:00
  • @karam Cool! I've marked that question as a duplicate of yours because it answers the question you had. If you have further questions, feel free to make a new question. – fuz Mar 06 '20 at 12:12

0 Answers0