I think the easiest way is to use DOSBOX like emulator on Linux and use NASM inside it. That way you can test your code directly in MS-DOS environment (even if just emulated).
I am not a Linux user so I do not know if DOSBOX works correctly on Linux but simple google search DOSBox - Runs Old MS-DOS Games/Programs in Linux - Tecmint suggest it does. Just do not forget to increase the number of CPU tics to match desired Speed.
Both NASM and TASM works under Windows DOSBOX so I see no reason why it should not work in Linux either. Here few relate SO/SE QAs of mine (all are *.com
however):
You just need NASM binaries for MS-DOS to make this work.
IIRC To create an *.exe
file from NASM the code should look a bit differently than the *.com
file and also the switches are a bit different.
In NASM the *.com
file looks like this:
[BITS 16]
[ORG 100h]
[SEGMENT .text]
;here goes the code
ret
And this is my vc.ext
entry to compile it in Volcov commander:
asm:@cls
@c:\language\compil\nasm\nasm.exe -ic:\language\source\nasm\inc\ -w+orphan-labels -o !.com !.!
I did not do *.exe
files at that time so I do not have any example. All I found is some protected mode demo and from it the source code for exe is different:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Init Flat 32 bit ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
%include "pmode.lib"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Main: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
bits 32
_main: sti
mov bx,101h
mov ax,4f02h
int 10h
call _getselector
mov edx,0A0000h
call [_setselector]
mov es,ax
mov edi,0
mov al,13
mov ecx,65535
rep stosb
mov ax,0
int 16h
mov ax,3
int 10h
mov ax,es
call _freeselector
mov es,[_seldata]
jmp _exit
CODEEND
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; End. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Where pmode.inc
contains subroutines macros and stuff defined under:
section code
bits 16
The compilation and link vc.ext
entry using turbo assembler linker:
asm:@cls
@c:\language\compil\nasm\nasm.exe -ic:\language\source\nasm\inc\ -w+orphan-labels -f obj !.!
@c:\language\compil\tasm\tlink.exe /3 /x !.obj , !.exe
@del !.obj
So without protected mode all the stuff should be in 16 bit I think...
Do not forget to use your own paths in the vc.ext
file...