Re: A83: Question about stack


[Prev][Next][Index][Thread]

Re: A83: Question about stack




Read in the message body:


On Mon, 29 Jan 2001 14:57:52  
 Mike3465 wrote:
>
>Ok, I know how to push and pop stuff to the stack
>But what i would like to know, is there a way to access a certain number in 
>the stack?
>like if i push 5 numbers into the stack
>and i want to get number 3 and not pop the other numbers
>Is there anyway to do this?

Just do:

    ld    hl,2*3   ;its to get the 3rd number
    add   hl,sp
    call  _ldhlind ;hl=number


>oh and i think that you can use the value sp for the stack ^_^ well i've 
>compiled it and not gotten any errors while compileing i don't know about 
>other wise though
>so could i do somethin like this?:

>ld hl,sp    ; <- this instruction doesn't exist

you should replace it with:

  ld   hl,$0000
  add  hl,sp

>dec hl
>ld a,(hl)
>to get the number before the stack begins?
>i would really appreciate any help ^_^ bye all!
>
>

Don't forget that only WORDS are pushed in the stack, so when you talk about "numbers", I assume its 16 bits numbers.


Hope this helps,
 Jean







Get your small business started at Lycos Small Business at http://www.lycos.com/business/mail.html