Searching \ for '16x84 return without call?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/index.htm?key=16x84+return+without
Search entire site for: '16x84 return without call?'.

Truncated match.
PICList Thread
'16x84 return without call?'
1998\01\24@215055 by Arthur Alto

flavicon
face
part 0 661 bytes
!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
If a 16x84 does a gets a RETURN instruction without any CALL, what happens?  Will zeros be popped off the stack and send the program counter back to the Reset Vector, or will the RETURN instruction be ignored and the program counter be unaffected?
 
Art Alto, N6VIG

1998\01\25@005406 by Andrew Warren

face
flavicon
face
Arthur Alto <spam_OUTPICLISTTakeThisOuTspamMITVMA.MIT.EDU> wrote:

> If a 16x84 does a gets a RETURN instruction without any CALL, what
> happens?  Will zeros be popped off the stack and send the program
> counter back to the Reset Vector, or will the RETURN instruction be
> ignored and the program counter be unaffected?

Art:

The RETURN will certainly not be ignored, but what DOES happen
depends on whether any CALLs have previously been executed, since
the return addresses that are pushed onto the stack by a CALL
remain there after the corresponding RETURN is executed... They're
NOT overwritten to "0000" or anything; all that happens is that the
stack pointer moves away from them.

Here's a visual aid:

   At Power-On Reset, the stack contains:

       xxxx <-- Next CALL puts its return address here.
       xxxx
       xxxx
       xxxx
       xxxx
       xxxx
       xxxx
       xxxx <-- Next RETURN pulls its return address from here.


       [It might actually contain all 0000's, but I don't think
       so... As I recall, the stack contents are undefined at
       power-up]

   After a CALL from address 0100, the stack contains:

       0101 <-- Next RETURN pulls its return address from here.
       xxxx <-- Next CALL puts its return address here.
       xxxx
       xxxx
       xxxx
       xxxx
       xxxx
       xxxx

   Let's say that the subroutine we called from address 0100 calls
   another subroutine... And that that one calls one more, etc.,
   until we've executed 8 nested CALLs without a single RETURN.  If
   that happens, the stack will contain something like:

       0101 <-- Next CALL puts its return address here.
       0011
       0021
       0031
       0041
       0051
       0061
       0071 <-- Next RETURN pulls its return address from here.

   Now, let's say that we do 8 RETURNs.  After those 8 RETURNS, the
   PC will be back at address 0101, but the stack will STILL contain
   the same addresses, and the stack pointer will have rotated
   through the stack until it's back to the same point:

       0101 <-- Next CALL puts its return address here.
       0011
       0021
       0031
       0041
       0051
       0061
       0071 <-- Next RETURN pulls its return address from here.

   Ok... So far, all of our CALLs and RETURNs have been balanced.
   If we now do as you suggest, and execute a RETURN without a
   preceding CALL, the program counter will be loaded with 0071.

-Andy

=== Andrew Warren - .....fastfwdKILLspamspam@spam@ix.netcom.com
=== Fast Forward Engineering - Vista, California
=== http://www.geocities.com/SiliconValley/2499

1998\01\25@113204 by Morgan Olsson

picon face
>From Microchip C84 datasheet DS30445B-page 17:
" The stack operates as a circular buffer. That is, after the
stack has been pushed eight times, the ninth push over-writes
the value that was stored from the first push. The
tenth push overwrites the second push (and so on).
If the stack is effectively popped nine times, the PC
value is the same as the value from the first pop.  "

I just wonder if the stack is cleared on startup, but I suppose it«s
content is random. Anyone know?
/Morgan


At 21:52 1998-01-24 -0800, you wrote:
{Quote hidden}

Morgan Olsson, MORGANS REGLERTEKNIK, Sweden, ph: +46 (0)414 70741; fax 70331
============================================================================

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...