0

I tried to compile Assembly code:

; [Assembly Tests].exe
;
; Tests
; Author: Simpfey

global _start

section .text:

_start:
    mov eax, 0x4
    mov ebx, 1
    mov ecx, message
    mov edx, message_length
    int 0x80

    mov eax, 0x1
    mov ebx, 0
    int 0x80

section .data:
    message: db "Hello World!", 0xA
    message_length equ $-message

using nasm and ld command ld -m32 -o ./build/Assembly.exe ./build/Assembly.o

gives me an error saying: unrecognised emulation mode: 32

To specify more about my Os: Windows 10 x64 Proffesional

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • `ld` doesn't support an `-m32` option. What made you think that it did? You might be thinking of `gcc -m32`. – Nate Eldredge Dec 10 '22 at 18:06
  • 1
    Are you planning to run this under WSL? It's Linux code and won't work natively on Windows. – Nate Eldredge Dec 10 '22 at 18:07
  • 1
    You probably wanted `-m elf_i386` o `-m i386pe`. – Margaret Bloom Dec 10 '22 at 18:18
  • @MargaretBloom It sorta worked, when i tried to run it loadded terminal and window was shown with text saying that : Assembly.exe Stopped working – czlowieczyna-czan Dec 10 '22 at 18:32
  • That's expected if you run an `int 0x80` instruction in a native Windows program; that interrupt number isn't special to the Windows kernel, so it raises a #GP exception which the kernel catches. See [Segmentation Fault: int 80h](https://stackoverflow.com/q/49784186) / [NASM tutorial uses int 80h, but this isn't working on Windows](https://stackoverflow.com/q/38269269) / [Displaying text in command line after executing a .exe file from a compiled .asm file](https://stackoverflow.com/q/72611496) – Peter Cordes Dec 10 '22 at 19:33
  • @PeterCordes Im Confused And, I don't exactly don't know what to do with this information else, that knowing `int 0x80` doesn't work and I should change it to something else – czlowieczyna-czan Dec 10 '22 at 19:48
  • If you want to follow Linux tutorials, set up a Linux VM such as WSL2. Otherwise look for Windows tutorials, either 32 or 64-bit. e.g. [How to write hello world in assembly under Windows?](https://stackoverflow.com/q/1023593) . Windows doesn't have a direct equivalent for `int 0x80`, at least not one that's documented and supported: [System Calls in windows & Native API?](https://stackoverflow.com/q/2489889) - you supported API is via the DLLs, although people have reverse-engineered the 64-bit `syscall` ABI. – Peter Cordes Dec 10 '22 at 19:52

0 Answers0