From: bson@rice-chex.ai.mit.edu (Jan Brittenson) Newsgroups: comp.sys.hp48 Subject: Shadowing Memory Date: 9 Sep 91 08:24:38 GMT Here are two small utilities, that let you map around your cards. [Note: Both SHADOW and ZEROMAP are contained in the SHADOW directory on this disk. -jkh-] SHADOW maps a card to shadow another device. The contents of the device are first copied to the card so you can modify them. Of course, if your card is ROM (or write-protected RAM), then the copy is ignored and the contents of the card will effectively overlay those of the second device. It takes two arguments: the address of your card and the destination address. SHADOW Copy and map card to shadow another device #card_address #destination_address --> ZEROMAP is similar to SHADOW, except the contents of the card are cleared instead of copied. Some examples: #80000 #10000 SHADOW Shadow parts of the system ROM (#10000-#1ffff) with a copy in the card in port 1. This would allow full MLDB breakpointing in the area 10000-1ffff. It could also be used from a program that subsequently modifies the "ROM." #10000 #80000 ZEROMAP Restore from previous example. If we didn't clear the card we would lose parts of it, and the next time we yanked it and plugged it back in, we would get an "Invalid card data" error. This has to do with the sort of trickery SHADOW resorts to in order to avoid "Invalid card data" errors. #C0000 #C0000 ZEROMAP Clear card in port 2. About ports and such: A single plug-in card will always be in port 1, even if plugged into connector 2. Port 1 is at #80000 and port 2 at #C0000. There is also a third config table entry which I'm not sure what it's used for, maybe a debug ROM. The default address for the third "port" is #D0000. The system ROM is in the region #00000-#6FFFF. Notice that I will not be responsible for any data or other forms of lossage. If properly used, you should be able to work miracles. Improperly used, you better have you backups readily available! Also, using these routines assumes a certain knowledge of HP-48SX internals. Do not attempt to store data on a card remapped by means of the routines included here: that is almost guaranteed lossage. The only argument checking performed is simple type checking. Have fun, -- Jan Brittenson bson@ai.mit.edu O / \/ /\ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ O \ ; shadow.star - shadow device with port ; ; Jan Brittenson, September 1991 ; This program is in the public domain. ; Assemble with (in order) hp48.star and stdsyms.star radix 0x10 header ; SHADOW ; ; In: ; 2: old address (short) ; 1: new address (short) conf_tbl = 70428 ; System configuration table rpl Prg Need_2_args Switch_on_argtype _Short 0xbb ; Two binary integers Prg Two_bins_to_shorts ; Convert addresses to shorts endrpl code ; Pop address, find fake pointer (all pages have one) call getshort ; A.A = shadow address move a, r2 call getshort ; A.A = RAM address swap a, r2 ; R2.A = RAM address call save_regs ; Save system RPL registers move 3, p clr.wp a ; Clear low 4 nybbles of address clr p move a, r0 ; R0.A = shadow location move a, d0 dec d0 $1: inc d0 move.a @d0, c brnz.a c, $1 swap c, d0 ; C.A = fake config address move c, r1 ; R1.A = fake config address ; Copy ROM and remap RAM clrb 0xf, st ; Disable interrupts move r2, c ; C.A = RAM adress move c, d1 move.p5 10000, c ; 32kB move a, d0 ; D0 = shadow page address call blkcopy ; Copy 32kB from #10000->#80000 move r2, c ; C.A = RAM adress uncnfg ; Unconfig RAM card move.p5 0xf0000, c ; 32kB Mask config move r0, c ; New location config ; Update system config table move r1, c ; Value to stick in config table move.5 conf_tbl+^d10, d0 ; D0 = & P1 config address move.a c, @d0 ; Update config address call calc_conf_crc ; Calculate config table CRC ; D0 = & CRC, C.A = new CRC move.4 c, @d0 ; CRC = new CRC ; Finished setb 0xf, st ; Enable interrupts brbc 0xe, st, $100 ; No interrupts occured rsi ; Service pending interrupts $100: jump rr_rplcont ; Restore RPL registers and continue even endcode rpl EndObj EndObj endrpl O / \/ /\ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ O \ ; zeromap.star - remap and clear port ; ; Jan Brittenson, Septembet 1991 ; This program is in the public domain. ; Assemble with (in order): hp48.star and stdssyms.star radix 0x10 header ; ZEROMAP ; ; In: ; 2: old address (short) ; 1: new address (short) conf_tbl = 70428 ; System configuration table rpl Prg Need_2_args Switch_on_argtype _Short 0xbb ; Two binary integers Prg Two_bins_to_shorts ; Convert addresses to shorts endrpl code ; Pop address, find fake pointer (all pages have one) call getshort ; A.A = shadow address move a, r2 call getshort ; A.A = RAM address swap a, r2 ; R2.A = RAM address call save_regs ; Save system RPL registers move 3, p clr.wp a ; Clear low 4 nybbles of address clr p move a, r0 ; R0.A = shadow location ; Clear remap RAM clrb 0xf, st ; Disable interrupts move r2, c ; C.A = RAM adress move c, d1 ; D0 = RAM address move.p5 10000, c ; 32kB call blkzero ; Clear RAM move r2, c ; C.A = RAM adress uncnfg ; Unconfig RAM card move.p5 0xf0000, c ; 32kB Mask config move r0, c ; New location config ; Update system config table move.5 conf_tbl+^d10, d0 ; D0 = & P1 config address move.a c, @d0 ; Update config address call calc_conf_crc ; Calculate config table CRC ; D0 = & CRC, C.A = new CRC move.4 c, @d0 ; CRC = new CRC ; Finished setb 0xf, st ; Enable interrupts brbc 0xe, st, $100 ; No interrupts occured rsi ; Service pending interrupts $100: jump rr_rplcont ; Restore RPL registers and continue even endcode rpl EndObj EndObj endrpl O / \/ /\ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ O \ ;; stdsyms.star - some common symbols nlistblock radix 0x10 Not_bool = 3af2 Doerr_string = 15048 Text = 1314d Toggle_text = 132c5 Cmd_DOERR = 1a339 Cmd_EVAL = 1a3be Cmd_PATH = 1a125 Cmd_HOME = 1a140 Home = 8d92 Path = 1848c Purge_global = 1854f Sto_any_global = 18513 Rcl_global = 797b Cmd_STO = 20ccd GROB_null = 505b2 OpenIO = 2eb37 CloseIO = 315c6 Freeze = 142fb Cllcd = 5046a Eval = 18eba Eval_prev_context = 6fd1 Push_next = 6e97 Char_000 = 6541e Add_string_char = 52ee Add5 = 6258a Inc = 3def Dup_Inc = 628eb Short_200h = 64f0e Short_100h = 64e32 Short_60h = 64c8e Short_c0h = 64dd8 Short_bbh = 64dce Short_31h = 64b44 String_to_grob_pitch8 = 11d00 Turn_menu_off = 4e2cf Nullstring = 55df Nullstring_copy = 1613f Program_null = 40788 Realloc = 61c1c Copy = 6657 Num = 1410f Add = 3dbc Add_string_string = 5193 LeftLess1_string_short = 63259 ArrayTo_array = 1d0ab ArrayTo = 1d0ab Dec = 3e0e Dup = 3188 EndObj = 312b Equalp = 3d19 Nonzerop = 3cc7 No_args = 18a15 Zerop = 3ca6 Dup_Zerop = 62266 Get_2Lastlocal = 613e7 Get_3lastlocal = 6140e Get_4lastlocal = 61438 Get_lastlocal = 613b6 If_then_else = 61ad8 If_true_then = 619bc Dup_If_zero_then_exec = 618a8 If_User_flag_then_else = 63ed9 Pview_short_short = 4f052 Listob = 2a74 ListAlgPrgTo = 54af ListTo = 54af ListTo_StoreLocals = 74d0 Local_M = 0xe4c1 Local_N = 0xe4ae Local_S = 41bea Mul = 3ec2 Mul2 = 3e6f Mul_array_real = 362dc Next = 7334 Prg = 2d9d True = 3a81 False = 3ac0 Bin_to_short = 5a03 Two_Bins_to_shorts = 4f3d1 Real_to_short = 18cea Real_to_short_Swap = 62e7b Swap_Over = 61380 Roll = 3325 Drop = 3244 Swap_Drop = 60f9b Drop2 = 3258 Drop4 = 60f7e Xlib_to_Rpl = 7e99 Error_Bad_arg_type = 18cb2 Error_Undef_Name = 18c92 Short_0bh = 405d Clear_lastargs = 4d33 Reset_lastargs = 53842 Need_1_arg = 18ab2 Need_2_args = 18a8d Need_4_args = 18b9f SL_Need_1_arg = 18aa5 Switch_on_argtype = 18fb2 SL_Switch_2_argtypes = 18edf SL_Switch_on_argtype = 18ece SL_Switch_4_argtypes = 18f01 SaveLast_Need_1_arg = 18aa5 Lastkey = 4714 Short_0 = 3fef Short_1 = 3ff9 Short_2 = 4003 Short_3 = 400d Short_4 = 4017 Short_5 = 4021 Short_6 = 402b Short_8 = 403f Short_0dh = 4071 Short_0eh = 407b Short_0fh = 4085 Short_10h = 408f Short_16h = 40cb Short_1fh = 4125 Short_20h = 412f Short_21h = 4139 Short_40h = 64bda Short_7fh = 1cd16 Short_83h = 64d24 Pdim = 4b323 Equal2p = 6229a Real_1 = 2a2c9 Real_2 = 2a2de Real_3 = 2a2f3 Real_4 = 2a308 Real_5 = 2a31d Real_7 = 2a347 Short_to_real = 18dbf Start_1_to_N = 73db Store_2lastlocal = 615f0 Store_3lastlocal = 61600 Store_4lastlocal = 61610 Store_lastlocal = 615e0 Store_local = 61625 Swap = 3223 Array_dims = 35a9 ToArray_real = 1d02c ToArray_list = 1d040 Size_list = 567b ToList = 5459 ToList2 = 631b9 TwoShorts_to_reals = 1950b TwoReals_to_shorts = 194f7 Short_to_bin = 59cc Swap_Over = 61380 Over = 32c2 Rot = 3295 Rolld3 = 60fac Rolld4 = 6109e Div2 = 3e8e Div = 3ef7 Disp_any_real = 140ab Disp_pitch8Str_line0 = 1245b Disp_pitch8Str_line1 = 1246b Disp_pitch8str_line2 = 1247b Disp_pitch8str_line3 = 1248b Disp_pitch8str_line4 = 1249b Disp_pitch8str_line5 = 124ab Disp_pitch8str_line6 = 124bb Disp_pitch8str_line7 = 124cb Attach_Home_short = 7709 Loop = 71a2 Exit_loop = 71e5 Until = 71c8 Next = 7334 If_ATTN_then_FlushKbd_Kill = 4243e If_ATTN_then_End = 4245c Pr1 = 318fe Error_bad_arg_value = 18ca2 If_not_equal_then_short = 6336c Get_StkGrob = 12655 Repl_Grob_short = 11679 ;; ML routines getshort = 6641 get2shorts = 3f5d pushshort_r0r1 = 6529 pushshort_r0_rplret= 18d0a pushobj_a = 54266 pushobj_a_rplret = 6ec9 strlen_a = 120cc strlen_d1 = 120cf stralloc_nibbles = 5b7d blkcopy = 670c blkzero = 675c save_regs = 679b restore_regs = 67d2 rplcont = 71be rr_rplcont = 5143 kbflush = 0xd57 indicate_not_busy = 42359 int_mask = 10e uart_xmit = 116 adjust_parity = 3113d uart_xmit_rdy_p = 310ca recv_getc = 31289 calc_conf_crc = 9b73 ATTN_p = 4988 clear_ATTN = 0xd8e start_of_stack = 7057e keybuf = 704ea graph_grob_ptr = 70565 stack_grob_ptr = 70556 Copyright = ch^^d169 Beta = ch^^d223 CR = ch^015 LF = ch^012 -- Jan Brittenson bson@ai.mit.edu