Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

nuclear war (Miscellaneous)

posted by kerravon, Ligao, Free World North, 17.11.2022, 23:40

> > And only about 24 hours ago (part of the delay here)
> > I realized I didn't know (and still don't know) how
> > it is technically possible for compilers to support
> > the small memory model, given that a buffer can
> > reside on either the stack or in the data segment.
>
> "Small model" in x86-16 coding simply means that there are two program
> segments, one for code, and one for data — and stack! So within the
> program you have cs ? ds =
> ss: the stack segment is the same as the data segment.

Thanks for clearing up that mystery!!!

Does this look correct to you?

https://sourceforge.net/p/pdos/gitcode/ci/master/tree/pdpclib/dosstart.asm#l72

; In tiny, small and medium memory models, you need to set
; ss to ds (MSDOS will have set them to different values
; when it loaded the executable).

if @DataSize
else
mov bx,ss
mov ax,ds
sub bx,ax
mov cl,4
shl bx,cl

endif

...

; It appears that in the tiny memory model, you are still required
; to set ds to the same as cs yourself, presumably because ds is
; pointing to the PSP while cs is probably pointing to the beginning
; of the executable. DGROUP may also get the correct value, presumably
; zero. es is set to ds a bit later. And you need to set ss to that
; value too

if @Model eq 1
push cs
pop ds
push cs
pop ax
mov bp, sp
sub bp, bx
mov ss, ax
mov sp, bp
; And that null PSP thing needs to be redone
mov ax, 0
push ax
else
mov ds,dx

; small and medium memory models have ds and ss the same so that
; near pointers can refer to either stack or data and still work
if @DataSize
else
mov bp, sp
sub bp, bx
mov ss, dx
mov sp, bp
; And that null PSP thing needs to be redone
mov ax, 0
push ax
endif

endif

 

Complete thread:

Back to the forum
Board view  Mix view
22049 Postings in 2034 Threads, 396 registered users, 74 users online (0 registered, 74 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum