How to initialize stack pointer in assembly language?

Dear all,

         I have a problem in my assembly code while intialising the stack pointer.By default its being initialized by 0FF.In the assembler SRA 740 ,code has already been written by some other people.I need to make some i am trying to run the code already being used,but couldnot go beyond the below instruction.

stack :        .blkb 47;

stack_top :  .blkb 1;

{some code has given in between}

s = > stack_top;(stucked)

debugger is encountering a problem with this instruction.My point is how to decide the RAM area,and out of RAM how to fine the range of stack memory locations so that i can intialize my stack pointer.Due to this problem HEW has crashed.Any help will be appreciated.Thanks in advance.

  • OK, and which address is your stack_top?

    Which processor do you use with how much memory?

    Please not the stack can only be in page 0 OR page 1.

    If it should be in page 1 you have to set the "Stack page selection bit" in the CPU Mode Register.

  • Hi frank,

         I have mentioned in the previous post s = > stack_top(0FF,address of stack_top)).I am using M38D59FFHP processor which has the capcity of ROM size 61440B and RAM size is 2048B.This code has written for the old processor M38203M4XXXGP/HP(ROM isze -16254B,RAM=512B).I am not sure how to intialise the stack pointer according to the new processor memory mapping and how to decide the stack range which is of 47 bytes..Its really confusing,so please help me out.I will give u the piece of code for reference.Thank you.

    stack :        .blkb 47;

    stack_top :  .blkb 1;

    .func main

    {some code has given in between PULLA and PULLB intialisation}

    s = > stack_top;(stucked)

    CPUM=%00001100;(i am closely observing the cpum stack page selction bit also)

  • OK, but the linker should give some address where stack_top is located. Please check that this is a valid address.

  • In the cmd.dat file which is generated by the linker S=0ffc2,but stack pointer is a 8-bit register.How to intialize the stack pointer according to the new processor RAM locations.And tell me how to modify the stack pointer value in the CMD.DAT?

  • So, next questions.

    Which tools do you use? HEW or TM?

    I think a dat-file as linker control is generated by TM. Then you should be able to modify the start address in the linker options. But it is many years that I have last used TM so I cannot describe this procedure any more.

  • I found the solution with the help of memory map in the new processsor.Since the stack is occupying 47 bytes and it is under the .section r,and r=100(Given in the dat file),I got to know the stack pointer is assigned  with the address 147H.I made some modification in the CPUM register ,selected the bit "stack selection page 1" and set the clock also .Then it started executing the program.Thanks.