Search code examples
assemblyconsolex86dosmasm32

MASM32, display string and integer


I am using MASM32 (version 10), and I would like to know what is the easiest way to output a string and an integer on screen. Please provide the full source code, and not just the specific lines.

Thank you.

Edit:

.386
.model flat, stdcall
.stack
.data
stest db "This is a test", 0
.code
main proc
    mov ah, 09h
    lea dx, stest
    int 21h
main endp
end main

It crash without outputting anything. I tried several other things, with different problems, the only common thing is that I don't get the string displayed on screen :)


Solution

  • Note that int21/09 requires the string to be terminated by a dollar sign ($). Also, even if your code did print something, it would crash immediately afterward since you don't terminate your program at all (see int21/4c) so it continues executing undefined memory. Depending on memory model and environment, you might also have to set up the segment registers and the stack for yourself first. All of this assumes that you indeed have access to int21 services to start with.

    Finally, as a general advice, get a debugger working and trace your program.