[A83] Re: Explaining the stack for registers


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

[A83] Re: Explaining the stack for registers




 push hl
>  call Routine
>
>Routine:
> pop de      ; remove return address
  pop hl      ; get HL, why do you want to this ?????
  push de     ; ret address back to stack
>  ret




-----Original Message-----
From: Ronald Teune [mailto:rtwolf@gmx.net]
Sent: Friday, August 17, 2001 2:46 PM
To: assembly-83@lists.ticalc.org
Subject: [A83] Re: Explaining the stack for registers



>Also note that CALL and RET also use the same stack...
>
>You can't:
>
>  push hl
>  call Routine
>
>Routine:
>  pop hl
>  ret

But is there ANY way to push/pop through calls?

>If you did that, HL would contain the address of the code after the call,
>and the RET would jump to the value of the pushed HL.  In other words,
>CRASH.
>
>(Unless of course HL contained a valid executable address...)
>
>>From: "TypeR unknown" <typerfuture@hotmail.com>
>>Reply-To: assembly-83@lists.ticalc.org
>>To: assembly-83@lists.ticalc.org
>>Subject: [A83] Re: Explaining the stack for registers
>>Date: Thu, 16 Aug 2001 19:51:46 +0200
>>MIME-Version: 1.0
>>X-Originating-IP: [194.69.26.241]
>>Received: from [195.67.128.9] by hotmail.com (3.2) with ESMTP id
>>MHotMailBD45533A006940043156C343800910050; Thu, 16 Aug 2001 10:52:12 -0700
>>Received: from towerguard. (mx-1.sollentuna.net [195.67.128.9])by
>>mx-1.sollentuna.net (Postfix) with ESMTPid D3C331800F; Thu, 16 Aug 2001
>>19:51:49 +0200 (CEST)
>>Received: with LISTAR (v1.0.0; list assembly-83); Thu, 16 Aug 2001
19:51:49
>>+0200 (CEST)
>>Received: from hotmail.com (f116.pav2.hotmail.com [64.4.37.116])by
>>mx-1.sollentuna.net (Postfix) with ESMTP id 54C5F1800Bfor
>><assembly-83@lists.ticalc.org>; Thu, 16 Aug 2001 19:51:48 +0200 (CEST)
>>Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC;
>>Thu, 16 Aug 2001 10:51:46 -0700
>>Received: from 194.69.26.241 by pv2fd.pav2.hotmail.msn.com with HTTP; Thu,
>>16 Aug 2001 17:51:46 GMT
>>>From assembly-83-bounce@lists.ticalc.org Thu, 16 Aug 2001 10:52:13 -0700
>>Delivered-To: lists.ticalc-assembly-83@mx-1.sollentuna.net
>>Message-ID: <F116nPSsYFbRYQ8P6rb0000d8e6@hotmail.com>
>>X-OriginalArrivalTime: 16 Aug 2001 17:51:46.0496 (UTC)
>>FILETIME=[1E0B9400:01C1267C]
>>X-listar-version: Listar v1.0.0
>>Sender: assembly-83-bounce@lists.ticalc.org
>>Errors-To: assembly-83-bounce@lists.ticalc.org
>>X-original-sender: typerfuture@hotmail.com
>>Precedence: bulk
>>X-list: assembly-83
>>
>>
>>Ahh I understand much better now!!!
>>I thought that every register that can be pushed had it's own stack, so I
>>was a bit confused when it appeared that the content of one register could
>>somehow be loaded in another register, but I understand very well now,
>>thank
>>you very much for your explanation!
>>
>>
>> >From: "Michael Vincent" <hookman@worldnet.att.net>
>> >Reply-To: assembly-83@lists.ticalc.org
>> >To: <assembly-83@lists.ticalc.org>
>> >Subject: [A83] Re: Explaining the stack for registers
>> >Date: Thu, 16 Aug 2001 10:12:18 -0700
>> >
>> >
>> >First, "if you push af and then pop bc" the contents will be in BC, not
>>AF.
>> >The reason for this is when you push a register, the values in it are
put
>> >on
>> >the stack, not the name. So if you push af then the value of A and the
>> >flags
>> >byte are on the stack. You can then pop whatever you want. If you pop bc
>> >then the 2 bytes on the stack from the push af will be put in BC. (B
will
>> >have what was in A, and C will have what was in F).
>> >
>> >There is no limit to how many times a register can be pushed, except on
>>the
>> >TI-83 Plus (and I think 83) the stack is only 400 bytes. After that you
>> >will
>> >corrupt RAM. The TI-OS uses a few bytes, but you have like 100 pushes or
>> >more you could do before you overflowed the stack.
>> >
>> >
>> >Michael Vincent
>> >Detached Solutions - www.detacheds.com
>> >Radical Software - www.radicalsoft.org
>> >
>> >----- Original Message -----
>> >From: "TypeR unknown" <typerfuture@hotmail.com>
>> >To: <assembly-83@lists.ticalc.org>
>> >Sent: Thursday, August 16, 2001 10:00 AM
>> >Subject: [A83] Explaining the stack for registers
>> >
>> >
>> > >
>> > > After reading the FAQ in AsmGuru there is a question about the stack
>> >with
>> > > registers. It says that (if I remember correctly) "if you push af and
>> >then
>> > > pop bc, the contents of bc will be in af"
>> > >
>> > > WHY ???
>> > >
>> > > I see no logic in that, and unfortunatly it isn't explained in
AsmGuru
>> > > either, so here I am :)
>> > >
>> > > Also I would like to know how many times a register can be pushed.
>> > >
>> > >
>> > >
>> > >
>> > > _________________________________________________________________
>> > > Get your FREE download of MSN Explorer at
>> >http://explorer.msn.com/intl.asp
>> > >
>> > >
>> > >
>> >
>> >
>> >
>>
>>
>>_________________________________________________________________
>>Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>>
>>
>>
>
>
>_________________________________________________________________
>Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
>
>







Follow-Ups: