0

Please help me. I've been working for three straight hours going through every piece of documentation I can. I'm really new to assembly and I'm trying to print "lol" onto the console. Here is my code:

.386
.model flat,stdcall
.stack 4096
ExitProcess proto,dwExitCode:dword

.data

.code
    
main proc
    mov edx,3
    mov ecx,"lol"
    mov ebx,1
    mov eax,4
    int 80h ;a website told me that this is the system call so i put it here but idrk

main endp
end main

it returns with: Exception thrown at 0x004E1024 in AssemblyLearning.exe: 0xC0000005: Access violation reading location 0xFFFFFFFF.

Michael Petch
  • 46,082
  • 8
  • 107
  • 198
  • 4
    `int 80h` is a 32-bit Linux system call. That will not work in a Windows program. The error clearly suggests you are on Windows (that and you are using MASM). The system call you'd need for Windows is something `WriteConsoleA` (and you'd have to use `GetStdHandle`) or if you are allowed you could call the C library `printf` function. 32-bit examples of doing that can be found in this SO answer: https://stackoverflow.com/questions/64671303/visual-studio-2019-masm-32bit-assembly-hello-world – Michael Petch Oct 05 '22 at 07:44
  • Even if that were the correct syscall it certainly won't read 3 bytes from the `ecx` register. Rather it will take a pointer to a buffer somewhere in memory, that has to hold the data to write. – ecm Oct 05 '22 at 08:47
  • [How can I get nasm assembly interrupts to work on windows(32 bit)?](https://stackoverflow.com/q/62709677) – Peter Cordes Oct 05 '22 at 09:22
  • `WriteConsoleA` is not a syscall – Louis Bernard Oct 05 '22 at 16:04

0 Answers0