This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Stack

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
.
.
.

When I do the same thing to my project,the stack gets initialised to 0x36.what is that I am doing wrong.

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
Is there any settings I have to do.Both the projetcs I have set the device to AT89c52...are there any other settings to do.

Can I intialise the stack at the 0x80...

Rgds
Raj Shetgar

Parents
  • 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.

Reply
  • 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.

Children
No data