News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

about register SS:SP

Started by n0noper, October 20, 2015, 01:20:47 AM

Previous topic - Next topic

n0noper

...
stack segment
dw 8 dup (0)
stack ends
...
mov ax, stack
mov ss, ax
mov sp, 10
;----------------------
look the SS:0000
from SS:SP to SS:0000, the result not the 0, analyze and get that: some register saved.
Why and What? which register was saved??? why??

THANKS!!!!!!!!

dedndave

if you are creating a 16-bit EXE, you don't have to set the stack segment and stack pointer
the initial SS:SP values are stored in the EXE header
the initial SS will point to the stack segment
and SP will point to the last word in that segment
if you have 512 bytes of stack space, SP will be 01FEh (512 - 2, in hex)

and, 8 words of stack space isn't enough   :P
i wouldn't even think of using less that 512 bytes stack space in 16-bit code
because it is a single-task, single-user operating system,
INT's and whatever else goes on in the background use the same stack

finally, to simplify your code, use the shortcuts

here's a template for small model 16-bit EXE's
        .MODEL  Small
        .STACK  4096
        .DOSSEG
        .386
        OPTION  CaseMap:None

;####################################################################################

        .DATA

s$Msg   db 'Hello World !',0Dh,0Ah,24h

;************************************************************************************

        .DATA?

;####################################################################################

        .CODE

;************************************************************************************

_main   PROC    FAR

        mov     dx,@data
        mov     ds,dx

        mov     dx,offset s$Msg
        mov     ah,9
        int     21h

        mov     ax,4C00h
        int     21h

_main   ENDP

;####################################################################################

        END     _main

n0noper

Thank you very much!!!
thanks for your help!   :t :t :t :t

MichaelW

Quote from: dedndave on October 20, 2015, 02:35:16 AM
INT's and whatever else goes on in the background use the same stack.

Doesn't DOS, by default, switch stacks to service hardware interrupts?
Well Microsoft, here's another nice mess you've gotten us into.

FORTRANS

Hi,

   The "MS-DOS Programmer's Reference" says that the DOS handler
switches stacks for a large number of interrupts.  In an explanation
it says the list mentioned was to support hardware interrupts.
Later on, it says:  "Stack-switching handlers are enabled only if the
stacks command in the CONFIG.SYS file specifies eight or more
stacks."  IIRC, DOS maintains at least three internal stacks for its
own usage.

Regards,

Steve N.