[comp.sys.handhelds] HELP!!!

efinley%ug.utah.edu@cs.utah.edu (Elliott Finley) (02/06/90)

Today I entered the PIG and BAG programs from the following post:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
I do not like the regular peek program.  It is pig slow, and when 
it creates variables in the home directory, it can move the thing 
you were peeking at.  I have written a better program, called PIG 
in honour of the original.

But first I had to write a better poke program.  It is best if objects 
you are modifying do not move unexpectedly.  It would also be nice to 
control the number of bytes that are modified.  My replacement for poke, 
called BAG, lets you do that.

BAG only changes as many nibbles as are required to store an #integer in
the word size set by STWS.  With BAG the SPEED program becomes:

SPEED
<< RCLF 4 STWS R->B #FFFF00h BAG STOF
>>

You must be a little careful if the word size is less than the 20 bits
required for an address.  Binary values are truncated to the word size
only when you perform operations on them.  That is why the #FFFF00h does 
not get truncated to 4 bits.  You cannot tell real size by the display.

The following MBAG program creates the BAG program in the HOME directory.
Once it is created, BAG can be moved elsewhere via RCL and STO.  Because
it contains a System Object, you cannot edit BAG.  Any changes can be
made by editing MBAG and rerunning it.  You can modify anything up to the
first hex number.  Usage is:  #value #address BAG

SWAP OVER #0h AND OR SWAP does three things

	1 truncates #value to word size but leaves #address alone
	2 checks the type of both
	3 makes a copy of #value so that overwriting it does not change 
	  other programs and variables.  This would happen otherwise.

MBAG
<<
  << SWAP OVER # 0h AND OR SWAP
    # D6471341301231h
    # D6461431471741h
    # D6631581631641h
    # C67E16514610D08h
    # D6031241961031h
    # C62412313111451h
    # CFF4AC808461027Eh
  >>  
  HOME 'BAG' DUP PURGE STO
  # 301231000B102C96h
  # CFF40h #CFFF1h SYSEVAL
>>

SYSEVAL solves the bootstrap problem by calling into BAG to patch the 
sequence of 7 numbers into an inline machine code object, yielding:

BAG
<< SWAP OVER # 0h AND OR SWAP System Object
>>

You can purge MBAG once you know BAG works.

The following MPIG program creates PIG, the replacement for PEEK.
PIG is very fast and can be stored anywhere.  PIG returns its value
by patching the top of the stack.  RCWS SWAP 64 STWS # 0h OR SWAP STWS
ensures that this number is a copy of a 64 bit binary integer.  You
can omit the RCWS SWAP SWAP STWS if you don't mind your word size being
upped to 64 everytime.  Usage:  #address PIG

MPIG
<<
  << RCWS SWAP 64 STWS # 0h OR SWAP STWS
     "ABCDEFGHIJKLMNOPQRSTUVWXYZ1"
  >>
  HOME 'PIG' DUP PURGE STO
  # 3012310003B02C96h  # CFFB6h  BAG
  # 1631641961031341h  # CFFC6h  BAG
  # 3117451961031765h  # CFFD6h  BAG
  # C808461241231h     # CFFE6h  BAG
>>

yielding:

PIG
<< RCWS SWAP 64 STWS # 0h OR SWAP STWS System Objectg
>>

Next, I'll post a little scan program that makes use of PIG and a
machine code hex-to-string converter to give a scrolling display
of memory.

Programs can be made to work for the 28C by substituting 4FF for
CFF and removing HOME.

Alonzo Gariepy
alonzo@microsoft
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
After entering these, my clock program stopped working. (it always
reports the same time +- 1 second) And also, the famed CHK program
started giving me erroneous checksums of all my programs...

If you even have the faintest idea of what is wrong, please tell...
I have WAY too much stuff loaded into this calculator to do a memory
reset and type it all back in.

The above programs create system objects, what exactly IS a system
object, and if I delete the program that uses it, does it also delete
the system object?

                      PLEASE HELP,
                            Elliot Finley