[net.micro.cbm] Commodore 64 Stack

jeh@unccvax.UUCP (Jeffrey Holman) (04/15/86)

    Can anyone tell me if there is a way to reset the stack pointer in ML?
I want to move the location of the stack to some bigger area of memory for
use in a possible compiler.  I am afraid that this is impossible since I
have been unable to find any reference to the stack pointer location in 
memory.
    Any info would be greatly appreciated!!

    Also, by the by, has anyone had any luck getting past the screening door
on board the Heart of Gold in Infocom's 'Hithchikers Guide ...'?  Any hints
on Marvin??

                                       Thanx!!

brown@nicmad.UUCP (04/18/86)

In article <493@unccvax.unccvax.UUCP> jeh@unccvax.UUCP (Jeffrey Holman) writes:
>
>    Can anyone tell me if there is a way to reset the stack pointer in ML?
>I want to move the location of the stack to some bigger area of memory for
>use in a possible compiler.  I am afraid that this is impossible since I
>have been unable to find any reference to the stack pointer location in 
>memory.

If I remember the processor correctly, the stack pointer is actually coded
into the chip program, making it non-movable.
-- 

              ihnp4------\
            harvard-\     \
Mr. Video      seismo!uwvax!nicmad!brown
              topaz-/     /
             decvax------/

jrg@hpda.UUCP (Jeff Glasson) (04/18/86)

In article <493@unccvax.unccvax.UUCP> jeh@unccvax.UUCP (Jeffrey Holman) writes:
>
>    Can anyone tell me if there is a way to reset the stack pointer in ML?
>I want to move the location of the stack to some bigger area of memory for
>use in a possible compiler.  I am afraid that this is impossible since I
>have been unable to find any reference to the stack pointer location in 
>memory.

The 6502 processor processer only has an 8-bit stack pointer.
The high order 8 bits are hardwired into the CPU to be page 1 of
memory (address $0100 to $01ff).
There is no way to change this.

Jeff Glasson
Hewlett-Packard ISO
ucbvax!hpda!jrg

lishka@puff.UUCP (Christopher Lishka) (04/18/86)

In article <493@unccvax.unccvax.UUCP>, jeh@unccvax.UUCP (Jeffrey Holman) writes:
>     Can anyone tell me if there is a way to reset the stack pointer in ML?
> I want to move the location of the stack to some bigger area of memory for
> use in a possible compiler.  I am afraid that this is impossible since I
> have been unable to find any reference to the stack pointer location in 
> memory.
>     Any info would be greatly appreciated!!

	As far as I know, the stack space for the 6502 microprocessors
(including the 6510, as in the C-64) has a strict limit of 256 bytes.  I
believe it is located from $0100 to $01ff hex.  This is so that the Stack
Pointer can fit within one byte.  Not very useful, is it?  What I suggest is
to reserve a couple bytes down in zero page for your own Stack Pointer and just
create your own stack.  You could define macros for the 'push' and 'pop'
operations.  OK, so it may not be as fast and efficient as an M.L. implemented
stack, but then again you would have a lot more memory than 256 bytes for stack
space.

>     Also, by the by, has anyone had any luck getting past the screening door
> on board the Heart of Gold in Infocom's 'Hithchikers Guide ...'?  Any hints
> on Marvin??

	Although this probably isn't the best place to get a discussion going
on this game (hell, net.micro.cbm doesn't have THAT much traffic anyway) I
would also be interested in any suggestions on what to do when you've finally
reached the Heart of Gold.  I've been all over this ship and the ONLY points
that I've scored here were negative 'cause I drank the tea substitute (live and
learn :-)  ).  Although I like the humor in this adventure, it has been a lot
harder (and REALLY specific and picky) in how to get anywhere beneficial (and
I've read all four books several times!).  Those who have not read the first
book  be wary in purchasing this game!  Also, can anyone tell me how to go
about attaining a Babel Fish to stick in my ear?  


				Chri Lishka
				U.W Madison

				"You have:
				 no tea..."

grr@cbmvax.cbm.UUCP (George Robbins) (04/19/86)

In article <824@puff.UUCP> lishka@puff.UUCP (Christopher Lishka) writes:
>In article <493@unccvax.unccvax.UUCP>, jeh@unccvax.UUCP (Jeffrey Holman) writes:
>>     Can anyone tell me if there is a way to reset the stack pointer in ML?
>> I want to move the location of the stack to some bigger area of memory for
>> use in a possible compiler.  I am afraid that this is impossible since I
>> have been unable to find any reference to the stack pointer location in 
>> memory.
>>     Any info would be greatly appreciated!!
>
>	As far as I know, the stack space for the 6502 microprocessors
>(including the 6510, as in the C-64) has a strict limit of 256 bytes.  I
>believe it is located from $0100 to $01ff hex.  This is so that the Stack
>Pointer can fit within one byte.  Not very useful, is it?  What I suggest is
>to reserve a couple bytes down in zero page for your own Stack Pointer and just
>create your own stack.  You could define macros for the 'push' and 'pop'
>operations.  OK, so it may not be as fast and efficient as an M.L. implemented
>stack, but then again you would have a lot more memory than 256 bytes for stack
>space.
>	Chri Lishka U.W Madison

Another alternative, and this is really gross, is to have the program call
a routine that checks the stack size, and if it's almost full, copy most of
it to another page, and then reset the stack.  This obviously requires some
careful housekeeping, but can be made to work.  It has been used on the C128,
where there's all that memory just waiting to be used...

The designers of the 6502 didn't plan on their little micro-computer chip
being used the way it was, but things got a little out of control.  The
original programming card showed that an extended version would include a
16 bit stack pointer, but it never happened.

-- 
George Robbins - now working with,	uucp: {ihnp4|seismo|caip}!cbmvax!grr
but no way officially representing	arpa: cbmvax!grr@seismo.css.GOV
Commodore, Engineering Department	fone: 215-431-9255 (only by moonlite)

fox@bnrmtv.UUCP (04/21/86)

> In article <493@unccvax.unccvax.UUCP> jeh@unccvax.UUCP (Jeffrey Holman) writes:
> >
> >    Can anyone tell me if there is a way to reset the stack pointer in ML?
> >I want to move the location of the stack to some bigger area of memory for
> >use in a possible compiler.  I am afraid that this is impossible since I
> >have been unable to find any reference to the stack pointer location in 
> >memory.
> 
> The 6502 processor processer only has an 8-bit stack pointer.
> The high order 8 bits are hardwired into the CPU to be page 1 of
> memory (address $0100 to $01ff).
> There is no way to change this.
> 
> Jeff Glasson
> Hewlett-Packard ISO
> ucbvax!hpda!jrg

But can't you create your own

daveh@cbmvax.cbm.UUCP (Dave Haynie) (04/22/86)

In article <114@cbmvax.cbmvax.cbm.UUCP> grr@cbmvax.UUCP (George Robbins) writes:
>Another alternative, and this is really gross, is to have the program call
>a routine that checks the stack size, and if it's almost full, copy most of
>it to another page, and then reset the stack.  This obviously requires some
>careful housekeeping, but can be made to work. It has been used on the C128,
>where there's all that memory just waiting to be used...
>
>-- 
>George Robbins - now working with,	uucp: {ihnp4|seismo|caip}!cbmvax!grr
>but no way officially representing	arpa: cbmvax!grr@seismo.css.GOV
>Commodore, Engineering Department	fone: 215-431-9255 (only by moonlite)

There's actually absolutely no reason what so ever to do something like that
on the C128.  It has MMU registers which allow the stack (and zero page) to
be located anywhere in the 128K memory.  Its still limited to 256 bytes,
but any machine language routine that decides it needs more stack memory
can save the current SP, reset the SP, and change the pointer, of course
changing every thing back before RTSing.  Not as great as having a 16 bit
pointer, but much more sensible than copying over 256 bytes every time
you want a larger stack.
-- 

Dave Haynie    {inhp4,allegra,seismo}!cbmvax!daveh
               When the going gets tough, the weird turn pro

jrg@hpda.UUCP (Jeff Glasson) (04/23/86)

In article <341@bnrmtv.UUCP> fox@bnrmtv.UUCP (Richard Fox) writes:
>> In article <493@unccvax.unccvax.UUCP> jeh@unccvax.UUCP (Jeffrey Holman) writes:
>> >
>> >    Can anyone tell me if there is a way to reset the stack pointer in ML?
>> >I want to move the location of the stack to some bigger area of memory for
>> >use in a possible compiler.  I am afraid that this is impossible since I
>> >have been unable to find any reference to the stack pointer location in 
>> >memory.
>> 
>> The 6502 processor processer only has an 8-bit stack pointer.
>> The high order 8 bits are hardwired into the CPU to be page 1 of
>> memory (address $0100 to $01ff).
>> There is no way to change this.
>> 
>
>But can't you create your own

You can define a 16-bit zero page variable to be something like a stack
pointer, but then you must write some assembler macros to do stack
operations.  The stack manipulation opcodes (JSB, PHA, PLA, etc.) only work
with the hardware stack.

Jeff Glasson
Hewlett-Packard ISO
ucbvax!hpda!jrg

cuda@ihuxf.UUCP (Mike Nelson) (04/24/86)

> In article <493@unccvax.unccvax.UUCP> jeh@unccvax.UUCP (Jeffrey Holman) writes:
> >
> >    Can anyone tell me if there is a way to reset the stack pointer in ML?
> >I want to move the location of the stack to some bigger area of memory for
> >use in a possible compiler.  I am afraid that this is impossible since I
> >have been unable to find any reference to the stack pointer location in 
> >memory.
> 
> If I remember the processor correctly, the stack pointer is actually coded
> into the chip program, making it non-movable.
> -- 
> 
>               ihnp4------\
>             harvard-\     \
> Mr. Video      seismo!uwvax!nicmad!brown
>               topaz-/     /
>              decvax------/

It really is movable or else it wouldn't work very well as a stack pointer.
:)  I haven't messed much with my computer lately but it should be fairly
easy to manipulate even though probably not directly writeable. The stack
exists in the 1st page of memory where a page is 256 bytes.  0 page is
used extensively by the operating system.  Several tests would have to
be performed.  First, I don't know if the pops are volatile, destroying the
memory as it is read.  I doubt it.  Next try to find where the stack is 
by pushing values on the stack and testing for those values through the
range of the stack.  Then perform the appropriate number of pops or pushes
to arrive at the address you wish.  If you wish to push over data without
erasing it you would probably have to read the particular location and
push that data back in the same spot.

If all else fails, drag out your handy laser and etch you a data path
and read command into the 6510.

Good luck.
Mike Nelson

dean@hyper.UUCP (Dean Gahlon) (04/24/86)

> 
>     Can anyone tell me if there is a way to reset the stack pointer in ML?
> I want to move the location of the stack to some bigger area of memory for
> use in a possible compiler.  I am afraid that this is impossible since I
> have been unable to find any reference to the stack pointer location in 
> memory.
>     Any info would be greatly appreciated!!
> 
>     Also, by the by, has anyone had any luck getting past the screening door
> on board the Heart of Gold in Infocom's 'Hithchikers Guide ...'?  Any hints
> on Marvin??
> 
>                                        Thanx!!

*** REPLACE THIS LINE WITH YOUR MESSAGE ***

     It is possible to change the stack pointer -- use the TXS instruction.
Unfortunately for what you want to do, it isn't possible to change the 
location of the stack in memory. It's fixed on page 1. 
     If you want to have a different stack-like area, you can simulate it
probably using (),Y indexing, but this still gives you only 256 bytes
for the stack, unless you have more than one such area. 
     As to the screening door, (***possible spoiler, hit -n- key now***)

I've heard that you have to recite some Vogon poetry to the door to get
past it.  I haven't tried this myself (having not yet gotten the time
to sit down with the game and run it so as to actually get the
Babel fish so as to understand the Vogon poetry), but this is what I've
heard.