The Dump.RPL method is painfully slow.

The following dump program uses xmodem to dump a direct binary image of
memory area #00000-#7FFFF.

To dump:
	Upload 'dump' to your HP48 S/SX/G/GX
	Execute 'dump'
	Start xmodem receive on your PC/whatever

To convert the dump for sadhp105 use the following program (slightly modified
version of sport.c). It will read 'dump' and output '.core'. Basically all it
does is to convert the binary image so that only 1 nibble is stored to each
byte.

Note: On S/SX memory area #70000-#7FFFF is RAM. If you wish to dump the
      hidden ROM instead better use the internal dump program.

--------------------CLIP----------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <ctype.h>

int main(argc, argv)
    int argc;
    char **argv;
{ 
     int value, counter, chr;
     FILE *in, *out;

     value = 0;
     
     if(!(in=fopen("dump","r")))
      {
	   perror("dump");
	   exit(1);
      }
     if(!(out=fopen(".core","w")))
      {
	   perror(".core");
	   exit(1);
      }
     while( (chr = getc(in) ) != EOF)
      {
		 value= chr & 0xF;
		 putc(value,out);
		 value=(chr/16) & 0xF ;
		 putc(value,out);
      }
     return 0 ; 
}
-------------------------CLIP-----------------------------------------


*******************************************************************************
*       Used entries
*******************************************************************************
ASSEMBLE
=AllowIo        EQU #324C8      ** Unsupported **
=xBUFLEN        EQU #22087      ** Unsupported **
=xSRECV         EQU #21E95      ** Unsupported **
RPL
*******************************************************************************
::
  CK0NOLASTWD
  :: AllowIo xBUFLEN DROP xSRECV 2DROP
     $ "Sending.." DISPSTATUS2

CODE
* CPU                           A       C       D0      R0      R1
	GOSBVL  =SAVPTR

* Experiments for hackers:

*       LC(5)   #70000          SX RAM (run dump from a card)
*       LC(5)   #80000          SX slot 1
*       LC(5)   #C0000          SX slot 2
*       UNCNFG
*       LC(5)   #80000          GX RAM (run dump from a card)
*       LC(5)   #C0000          GX slot1 & 2
*       UNCNFG
*       UNCNFG

* Set dump start address
	C=0     A               ( 1 )   #00000-#7FFFF
*       LC(5)   #80000          ( 2 )   #80000-#BFFFF
*       LC(5)   #C0000          ( 3 )   #C0000-#FFFFF
*       LC(5)   #80000          ( 4 )   #80000-#FFFFF
	R0=C.F  A                                       ->start
* Dump N 256 byte blocks
	LC(5)   #7FF-#000       ( 1 )   #00000-#7FFFF
*       LC(5)   #BFF-#800       ( 2 )   #80000-#BFFFF
*       LC(5)   #FFF-#C00       ( 3 )   #C0000-#FFFFF
*       LC(5)   #FFF-#800       ( 4 )   #80000-#FFFFF
	R1=C.F  A                                               blocks

	LC(2)   #1              * Init block number
	R2=C.F  B
* Send object
* CPU                           C       D       D0      D1
Snd     LC(2)   #1              * Send block opening sequence
	GOSUB   SndChr
	C=R2.F  B
	GOSUB   SndChr
	C=R2.F  B
	C=-C-1  B
	GOSUB   SndChr
	C=R0.F  A               ->ob
	D1=C                                            ->ob
	LC(2)   #7F             * Set char counter to D[B]
	D=C     B
	C=0     B               * Init CRC counter to R4[B]
	R4=C.F  B
* CPU                           A       C       D       D0      D1
SndBlock C=DAT1 B                       chr
	A=R4.F  B               crc
	A=A+C   B               crc'
	R4=A.F  B               * Save new crc
	D1=D1+  2                                               ->nxtchr
	GOSUB   SndChr          * Send chr
	D=D-1   B               * Decr char counter
	GONC    SndBlock        * Block not sent yet?
	C=R4.F  B               * Block sent, now send crc
	GOSUB   SndChr

	GOSUB   WaitAck
	LC(2)   #15             * Sending not in progress?
	?A#C    B
	GOYES   Snd1Ok
	GOTO    Snd             * Retry sending

* CPU                           A       C       D0      D1
Snd1Ok  LC(2)   #6              * Block not ok?
	?A#C    B
	GOYES   BlkNok
	A=R0.F  A               * Fix ->ob with lenght of 1 block
	LC(5)   #100
	A=A+C   A
	R0=A.F  A       
	A=R2.F  B               * Increment block number
	A=A+1   B
	R2=A.F  B
	A=R1.F  A               * Decrement block counter
	A=A-1   A
	GOC     ObDone          * Was it last block?
	R1=A.F  A
	GOTO    Snd
ObDone  LC(2)   #4              * Send end char until acknowledged
	GOSUB   SndChr
	GOSUB   WaitAck
	LC(2)   #6
	?A#C    B
	GOYES   ObDone
	GOTO    SndExit

BlkNok  LC(2)   #18
	?A=C    B
	GOYES   SndExit
	GOTO    Snd
*******************************************************************************
* Exit if key pressed
?Exit   LA(2)   #3F
	LC(3)   #1FF
	GOSBVL  =CINRTN
	C=C&A   B
	?C=0    B
	RTNYES
	LC(2)   #18
	D0=(5)  =TBR
	DAT0=C  B
SndExit GOSBVL  =Flush          * Clear keybuffer
	GOVLNG  =GETPTRLOOP
*******************************************************************************
* Wait response character
WaitAck D0=(5)  =IOC            * Set SON
	LC(2)   #88
	DAT0=C  B
	D0=(2)  =RCS
WaitLp  GOSUB   ?Exit
	C=DAT0  B
	?CBIT=0 0               * RBF clear?
	GOYES   WaitLp
	LC(1)   #8              * Clear RER, RBZ, RBF
	DAT0=C  1
	D0=(2)  =RBR            * Get received char, clears RBF
	A=DAT0  B
	RTN
*******************************************************************************
* Send character in C[B]

SndChr  B=C     B
	D0=(5)  =IOC            * Set SON, RBZ, RBF
	LC(2)   #B8
	DAT0=C  B
	D0=(2)  =TCS
SndLp   GOSUB   ?Exit
	C=DAT0  B
	?CBIT=1 1               * TBF set?
	GOYES   SndLp           * Then wait until can send next char
	D0=(2)  =TBR            * Send, sets TBF
	C=B     B
	DAT0=C  B
	RTN
ENDCODE

    FLUSHRSBUF
 ;
;
--
--->    Mika Heiskanen, mheiskan@delta.hut.fi

