From: Poul-Henning Kamp <phk@data.fls.dk>
Subject:  v02i039:  buport - Backup port to IO v1.0, Part01/01
Newsgroups: comp.sources.hp48
Followup-To: comp.sys.hp48
Approved: spell@seq.uncwil.edu

Checksum: 4026098954 (verify with brik -cv)
Submitted-by: Poul-Henning Kamp <phk@data.fls.dk>
Posting-number: Volume 2, Issue 39
Archive-name: buport/part01


BEGIN_DOC buport.doc
BUPORT - Backup all items from a port.
======================================

This program will use SEND to send all item in a specified port to a
remote computer using whatever parameters setup in IOPAR.

		        STACK-DIAGRAM
		------------------------------
		n	->   BUPORT   ->
		 port
		------------------------------

One the remote computer one file for each item will be created, with names
constructed to identify the object they contain.  In addition a user-RPL
program is stored that will restore all of these again.

Libraries comes in two sorts, those which used the "HP-naming" and those 
which havn't seen the point :-)
If the name-string of the library has the form ??????:??????...  the result-
ing file will have a name on this form: l_??????.p_? where the part before
the colon goes before the point, and the portnumber goes after the underscore.
Otherwise the file will be l_####.P_? where the number (id) of the library is
used instead of its (unproper) name; again the portnumber goes last.

Backups are all the other objects, they get names on the form b_??????.p_?
where the name stored in the backup is put before the point, and the port-
number goes last.

The Restore program is named restore.p_? where the portnumber goes last.
This program is in user-RPL and is always transmitted in ASCII format,
you can therefore edit it before use, both on the computer and the 
calculator.  The program takes the portnumber to restore into as a real
from the stack.

To give an idea of how it looks, this is my result of 2 BUPORT:
----------------------------------------------------------------------------
 Volume in drive C has no label
 Directory of  C:\BACKUP48

B_NBPAR  P_2	B_UTIL   P_2	B_BASE   P_2	L_NB     P_2	B_PHK    P_2
L_TETRIS P_2	L_1111   P_2	B_GO     P_2	B_INBPAR P_2	L_1092   P_2
L_GAMES  P_2	B_FLAGS  P_2	B_MOVE   P_2	L_PHK    P_2	B_MINE   P_2
L_UTILS  P_2	B_SKY    P_2	B_SKYS   P_2	L_1214   P_2	B_MORSE  P_2
B_CLK    P_2	B_INSTAL P_2	B_EXEC   P_2	RESTORE  P_2	
       24 File(s)  23406592 bytes free
----------------------------------------------------------------------------

Notes:
======
I have not tried to optimize this for time nor space, I don't really used
it that much, feel free to improve it to suit your own taste.

Yes, it works with ROM & write-protected RAM cards also.

Warnings:
=========
This program uses non-documented features, the entry-points of which are
listed in the top of the source.  *** This is tested on rev.E only ***

BYTES: #1c04h 537
END_DOC

BEGIN_SRC buport.s
* BUPORT 1.0 2nov91 phk@data.fls.dk
* ==========
*
* Backup port to remote computer.
*
* ARGS:
*	real	-- Port number
*
* RETURNS:
*	<nothing>
*
* FUNCTION:
*	recals all items in the port, and for each one constructs a new name
*	stores the item in a LAM and uses SEND to transmit it to the remote
*	computer under the new name.  Builds a secondary to pull things back
*	into the calculator.
*
* COPYLEFT:
*	Feel free to use this any way you like, as long as you do give credit
*	where credit is due.
*
ASSEMBLE
    NIBASC /HPHP48-Z/

*
* UnDocumented entrypoints.  Picked up from disassembly of Rev.E Firmware:
*
RclPort		EQU	#21922
LibNbr		EQU	#081ee
LibName		EQU	#081d9
xSEND		EQU	#21ef0
xKGET		EQU	#21f24
xSTO		EQU	#20ccd
x>>O		EQU	#23639
x>>I		EQU	#235FE
x->		EQU	#234c1
xQU		EQU	#23654
xUNQU		EQU	#23679
xPURGE		EQU	#20EFE
xSF		EQU	#1C274

RPL
    ::
    CK1NOLASTWD
    CK&DISPATCH1
    real
	::
	THIRTYFIVE TestSysFlag SWAP
	THIRTYFIVE SetSysFlag
	COERCE
	DUP #>$ ".p_" SWAP&$ 1LAMBIND
	RclPort
	DUP ZERO 1GETABND
	ROT
	{ LAM guf NULLLAM NULLLAM } BIND
	' :: x<< % -36 xSF x-> LAM port x<< ; 
	SWAP
	ZERO_DO (DO)
	    ::
	    SWAP
	    DUP ' LAM guf STO
		::
		CK&DISPATCH1
		    #8f ( Library )
			::
			DUP
			LibName DROP ID>$
			SEVEN SEVEN SUB$ ":" EQUAL ITE
			    ::
			    LibName DROP ID>$
			    DUP " " ONE POS$ DUP#0= ITE
				DROP
				:: #1- ONE SWAP SUB$ ;
			    "l_" SWAP&$ ONE EIGHT SUB$ 2GETLAM &$
			    ;
			    ::
			    LibNbr DROP 
			    #2710 #+ #>$ TWO FIVE SUB$
			    "l_" SWAP&$ ONE EIGHT SUB$ 2GETLAM &$
			    ;
			;
		    #9f ( Backup )
			::
			LibName DROP ID>$
			"b_" SWAP&$ ONE EIGHT SUB$ 2GETLAM &$
			;
		;
	    DUP
	    ' LAM guf SWAP TWO {}N ONE{}N xSEND
	    ' ID tmpvar TWO {}N ONE{}N
	    ' xKGET 
	    ' ID tmpvar
	    ' LAM port
	    ' xSTO 
	    FIVE ::N &COMP
	    ;
	LOOP
	' :: x>>I xQU ID tmpvar xUNQU xPURGE x>>O ; &COMP
	' LAM guf STO
	{ LAM guf }
	THIRTYFIVE ClrSysFlag
	"restore" 2GETLAM &$ >TCOMP ONE{}N xSEND
	ABND
	DROP
	IT
	    :: THIRTYFIVE SetSysFlag ;
	;
    ;
END_SRC

BEGIN_ASC buport.asc
%%HP: T(3)A(D)F(.);
"D9D202BA812BF819FF30D9D20D41404873532230D414013735AEC81881304E76
1C2A20B0000E207F5FE226FC4362291288130FEF306B4365923047A20D6E2030
76576603D4303D43B21300D47079E60D9D20E163233920100000000000063947
2C11C432D6E204007F62747E1632B2130322303C370D9D20322308813079E60D
6E203076576672D70D9D202BF8111920F8000D9D20881309D180442309EB5053
0405304033750C2A2070000A379B308DA16D9D209D180442309EB5088130C2A2
070000029FF301B546662268DA1644230D9D20E0E309FF303223033750B2130C
2A2090000C6F5FE2269FF30F3040337507E31639150B2130D9D20EE180442301
192001720CBD304E761300401204033750C2A2090000C6F5FE2269FF30F30403
37507E31639150B2130B213011920F9000D9D209D180442309EB50C2A2090000
26F5FE2269FF30F3040337507E31639150B2130B21308813079E60D6E2030765
766322303004095450DEE320FE1279E6084E206047D6076716273004095450DE
E3279E6042F1279E6084E206047D60767162779E60D6E204007F6274779E60DC
C021204054450F1250B21304337079E60D9D20EF5324563284E206047D607671
62797632EFE0293632B2130F125079E60D6E203076576672D7047A20D6E20307
65766B2130D414016735C2A203100027563747F627567E31639150AF250DEE32
0FE127947044230CB916D9D20D414013735B2130B2130B213040C1"
END_ASC

BYTES: #1C04h 547.5

BEGIN_UU buport.uu
begin 600 buport
M2%!(4#0X+5J=+2"K&+*/D?\#G2W0%`2$-S4B`TU!$'-3ZHR!&`/D9\&B`@L`
MX`+W]2YBSS0FDB&(,?#^`[8T5BD#="K0Y@(#9W5F,$T#TS0K,0!-!Y=NT-D"
M'C8RDP(!``````!@DW3"$4PC;2Y``/<F1^=A(RLQ,"(#PW/0V0(C,H`8`Y=N
MT.8"`V=U9B=]T-D"LH\1D0*/`-#9`H@QD!T(1#*0O@4U0%`#!#-7P*("!P"@
M<[D#V!K6V0+9@4`D`^E;@!@#+"IP```@^3\06V1F(H:M840RT-D"#CZ0_P,C
M,C!S!2LQP*(""0#`]O4N8OD_\`,$,U=P/F&34;`2`YTMX!X(1#(0D0(0)\#;
M`^1G,0`$(4`P<P4L*I```&Q?[R*6_P,_0#!S!><3-AD%*S&P$@,1*?`)`)TM
MD!T(1#*0O@4L*I```&)?[R*6_P,_0#!S!><3-AD%*S&P$@.(,7#I!FTN,'!6
M9S8B`P-`D$4%[3X"[R&7;H#D`@9T;7!V87(#0)!%!>T^<ND&)!]RZ09(+F!`
MUP9G%R9WZ09M+D``]R9'=^D&S0P2`@1%5/`A!2LQ0#,'EV[0V0+^-4)E(T@N
M8$#7!F<7)I=G(_X.DF,C*S'P(067;M#F`@-G=68G?4"G`FTN,'!69[82`TU!
M$'93+"HP`0!R97-T;W)EYQ,V&07Z4M#N(_`><DD'1#+`FV&=+=`4!#$WM1(#
%*S&P$@,P
`
end
END_UU
-- 
phk@data.fls.dk		  ||  A host is a host from coast to coast,
Poul-Henning Kamp	  ||  & no one will talk to a host that's close,
FLS DATA A/S		  ||  Unless the host (that isn't close)
Phone: (+45) 36 18 12 35  ||  is busy, hung or dead.
Fax:   (+45) 36 18 12 18  || 				Anon (?) 

