We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi All, I have this following example program,Here in this code when I simulate,The stack gets initialised to 0x69.
PROG SEGMENT CODE CONST SEGMENT CODE VAR1 SEGMENT DATA BITVAR SEGMENT BIT STACK SEGMENT IDATA RSEG STACK DS 10H ; 16 Bytes Stack CSEG AT 0 USING 0 ; Register-Bank 0 ; Execution starts at address 0 on power-up. JMP START RSEG PROG ; first set Stack Pointer START: MOV SP,#STACK-1 . . .
main_prg segment code main_stack segment idata main_bit segment bit main_var segment data rseg main_stack ds 10h ;reserve 16 bytes of RAM for the stack cseg at 0 using 0 jmp start rseg main_prg start: MOV SP,#main_stack-1
Yes, the best place for the stack is in IDATA (0x80-0xff). The higher the address you start the stack at the more space you have free for variable storage. You (obviously) need to make sure you don't make the stack too small, though. Stefan
It is DANGEROUS to specify the stack at an absolute address. Put ALL data storage in one segment as follows org 030h var1 ds n define var2 var1+n ... define stack varnnn+n and your stack will be 1) at the end of used (i)data and thus as large as possible. Erik PS if you do it in C that is how it happens.