clr_scr macro
push ax ; save affected registers
push bx
mov ah,15 ; read the video mode
int 10h
mov ah,0 ; set the video mode
int 10h
pop bx ; restore the registers
pop ax
endm
.data
filename db 'f:\16bit\fire.com',0
parameters dw 7 dup(0)
keep_ss dw 0
keep_sp dw 0
signon db 'Press ESC to start the program.$'
not_there db 'File NOT present !!$'
watermark db 'by Andrew Kennedy 2007'
.code
start:
mov ax,@data
mov ds,ax
clr_scr
mov dx,offset signon
mov ah,9
int 21h
;----------------------------------------------------------------------------
; check to see if escape key has been pressed
;----------------------------------------------------------------------------
check:
mov ah,1 ; get keyboard input
int 21h
cmp al,1bh ; ASCII code for ESC
key
jz shell ; jump to shell when ESC
hit
jmp check
shell:
clr_scr
mov bx,zseg ; get paragraph # of end
of prg
mov ax,es ; get paragraph # of
start of prg
sub bx,ax ; calc prog size in
paragraphs
mov ah,4ah
int 21h
mov ax,seg parameters ; es holds segment
mov es,ax
mov bx,offset parameters ; bx holds offset
mov keep_ss,ss ; save SS
mov keep_sp,sp ; save SP
mov dx,offset filename ; offset in dx
mov ax,seg filename ; segment in DS
mov ds,ax
; CF set on error
; AX = error code (01h,02h,05h,08h,0Ah,0Bh) (see #01680 at AH=59h)
mov ah,4bh ; EXEC function
mov al,0 ; choose load and run
option
int 21h ; run it
jnc short next
mov dx,offset not_there; Get error message
mov ah,9
int 21h
next:
mov ax,@data ; restore data segment
mov ds,ax
mov ss,keep_ss ; restore SS
mov sp,keep_sp ; restore SP
exit:
mov ax,4c00h
int 21h
zseg segment ; dummy segment to mark
end
zseg ends ; of code
end start