Post by ***@gmail.comIs there any reason why small memory model can't
be used to make a .com file?
Thanks. Paul.
No there isn't. However CMD.EXE starting around Win8 won't load it if it is > 64k.
Prior to that CMD.EXE would, as would all the pcDOS's as the Loader would load the entire file size.
I experimented with doing such circa Win 97.
The .cseg must come first, with the code ORG'ed to 0100h. The reason is the Loader prepends a 0100h
Program Segment Prefix, even for .com files prior to jumping to 0100h to start the execution.
This begs the question of what tools to use. I used NASM and it has the directives to make life easier to
do a couple of things.
o align 16, db 00h, placed at the last point in each segment to make them and even paragraph in length.
This is done to figure a segments length, evenly,
;;---------------------------------------------------55
;; End Code Segment
;;---------------------------------------------------55
[SECTION .cseg]
align 16, db 0CCh
cmd_cend:
codelength equ (cmd_cend - cmd_cstart) >> 4
codemin equ codelength
So that this works...
;;
%IF pcDos
ORG 100h
[SECTION .cseg] ;; initial
%ELSE
[SECTION .cseg vstart=0 align=16]
%ENDIF
;;---------------------------------------------------55
cmd_cstart:
;;--- setup runtime segment registers from current CS
;; Note: this assumes real mode contiguous binary.
mov bx,CS
add bx,codemin ;;segm_sz of code + CS = DSEG
So CS plus its length in 'segments' so to speak, now is the segment number of the next segment, DS.
%IF pcDos
add bx,10h ;; adj for 0100h orging
%ENDIF
mov DS,bx
add bx,datamin ;; + segm_sz data = ESEG
%IF pcDos
add bx,10h
%ENDIF
mov ES,bx
add bx,extramin ;; + segm_sz extra = SSEG
%IF pcDos
add bx,10h
%ENDIF
mov SS,bx
mov sp,stack_sp ;;offset in SSEG
main:
call START
jmp alldone
{START code block}
. . .
;;---exit program---
alldone: ;;return to here, exit.
;; do dos exit in this version...
%IF pcDos
mov ax,4C00h
int 21h
%ELSE ;; binary exit thru RomBios.
mov ah,0
int 16h ;;pause until keypress.
int 19h ;;reboot.
%ENDIF
;;---------------------------------------------------55
;; End Code Segment
;;---------------------------------------------------55
[SECTION .cseg]
align 16, db 0CCh
cmd_cend:
codelength equ (cmd_cend - cmd_cstart) >> 4
codemin equ codelength
;;----EO CSeg--------
;;---------------------------------------------------55
;; Data Ends
;;---------------------------------------------------55
[SECTION .dseg] ;;
align 16,db 0F6h
cmd_dend:
datalength equ (cmd_dend - cmd_dstart) >> 4
datamin equ datalength
;;----EO DSeg--------
;;---------------------------------------------------55
;; Extra Ends
;;---------------------------------------------------55
[SECTION .eseg]
cmd_eend:
extralength equ (cmd_eend - cmd_estart) >> 4
extramin equ extralength
;;--- EO ESeg ---
;;---------------------------------------------------55
;; Stack Ends
;;---------------------------------------------------55
[SECTION .sseg]
align 16, db 0CCh
cmd_send:
stack_sp equ (cmd_send - cmd_sstart)
stacklength equ (cmd_send - cmd_sstart) >> 4
stackmin equ stacklength
;;----EO SSeg--------
(rough idea, not final running code ~~ .eseg looks suspect from what I remember)
..an ex. make file for nasm
nasm -@ test.mak
-f bin
-l diskview.lst
-o diskview.bin
diskview.nsm
..Rename the *.bin to *.com
hth,
Steve