Basically, I am using NASM to create simple .COM files to use. For one of the files(ttcb.asm), it starts out by clearing the screen. This is done by calling a routine in another file, so I used %include 'video.asm'. This includes the file as expected. When I include this file, nothing else following the %include statement in the original file(the file that included video.asm) will be executed, even if I don’t call the separate routine. I also see that the code in video.asm is automatically getting executed. But when I remove the %include statement, everything runs properly. I’ve even tried removing everything in video.asm, but it still did not work. Then I tried making video.asm a blank file, and it worked, but that will be pointless. Then I tried moving the include statement around, but that failed as well. Is there any solution to this, or do I have to insert the subroutine directly into the original file?
ttcb.asm:
[BITS 16]
section .text
%include 'video.asm'
call screen_clear
jmp $ ;should've frozen the .COM, but it didn't, meaning it failed to execute.
section .data
welcomeMsg db 'Welcome to the TitaniumCube ©.',13,10,0,'$'
section .bss
video.asm:
;===================================
;-----------------------------------
;Clears the screen to black
;No input or output
;-----------------------------------
screen_clear:
mov ah,0Fh
int 10h
push ax
mov ah,00
mov al,00
int 10h
pop ax
mov ah,00
int 10h
ret
;-----------------------------------
;===================================
For COM files, use
org 100hto specify the binary base address. The.textsection will be the code start address. So put all functions after the main program block ends.Below is the code. Compile with:
nasm -fbin -o ttcb.com ttcb.asmPS) Under pure DOS, there’s no
©(copyright) character.