When using SASM IDE and you use format ELF
in your assembly code, FASM will assemble the file to an ELF object (.o
file) and then use (by default) a MinGW version of GCC and LD to link that ELF object to a Windows executable (PE32). These executables run as native Windows programs, not DOS. You can not use DOS interrupts inside a Windows PE32 executable since the DOS interrupts do not exist in that environment. The end result is that it crashes on the int 21h
.
If you want to create a DOS executable that can run in 32-bit Windows XP you could do this:
format MZ ; DOS executable format
stack 100h
entry code:main ; Entry point is label main in code segment
segment text
msg db 'Hello, world!$' ; DOS needs $ terminated string
segment code
main:
mov ax, text
mov ds, ax ; set up the DS register and point it at
; text segment containing our data
mov dx, msg
mov ah, 9
int 21h ; Write msg to standard output
mov ah, 4Ch
int 21h ; Exit DOS program
This will generate a DOS program with an exe
extension. Unfortunately you can not use SASM IDE to debug or run a DOS program. you can run the generated program from the 32-bit Windows XP command line. 32-bit versions of Windows run DOS programs inside the NTVDM (virtual DOS machine).