04-26-2014, 02:37 PM
Quick on the heels of the previous topic ( 41CL: Second Set of Extended memory ) - here comes the follow-up dealing with MAIN memory, i.e. Data registers and Programs.
The method is exactly the same, but one must be careful not to swap the RAM with an invalid copy in the higher page: the status register c in particular is very sensitive to this experiments and balks at improper values!
Therefore it's important to "prime the pump" before executing MMSWAP for the first time - and that's the mission of MMCOPY: use it to copy the current contents of the main RAM to the upper page.
MMSWAP includes status registers c,d, and e - but none of the others. This scheme provides compatible key assignments but leaves alone the program pointer.
Stating the obvious, make sure MMSWAP runs from ROM (HEPAX, or otherwise) - or else you'll get nice pyrotechnics and a likely MEMORY LOST event.
Below the program listings for MMCOPY:
and here's the combined MMSWAP and XMSWAP together (lots of shared code):
Cheers,
'AM
PS. The attached pdf contains both programs in a nicer format - does anybody know how to get the code properly formatted in the post window???
The method is exactly the same, but one must be careful not to swap the RAM with an invalid copy in the higher page: the status register c in particular is very sensitive to this experiments and balks at improper values!
Therefore it's important to "prime the pump" before executing MMSWAP for the first time - and that's the mission of MMCOPY: use it to copy the current contents of the main RAM to the upper page.
MMSWAP includes status registers c,d, and e - but none of the others. This scheme provides compatible key assignments but leaves alone the program pointer.
Stating the obvious, make sure MMSWAP runs from ROM (HEPAX, or otherwise) - or else you'll get nice pyrotechnics and a likely MEMORY LOST event.
Below the program listings for MMCOPY:
Code:
1 LBL "MMCOPY
2 13 register c address
3 ENTER^
4 3 three status registers
5 XEQ 03 copy block
6 "MAIN" main memory
7 AVIEW provide feedback
8 192 origin address
9 ENTER^
10 320 number of registers
11 LBL 03
12 STO M save counter in M
13 X<>Y address-1
14 1024
15 X<>Y
16 + adress-2
17 LASTX
18 LBL 01
19 PEEKR read value in adr-1
20 X<>Y
21 RDN
22 POKER write in in adr-2
23 X<> T
24 E
25 ST+ Z increase adr-1
26 + increase adr-2
27 DSE M decrease counter
28 GTO 01 loop back if not done
29 "DONE" block is done
30 AVIEW
31 END
and here's the combined MMSWAP and XMSWAP together (lots of shared code):
Code:
1 LBL "MMSWAP"
2 3 registers c, d, and e
3 STO M
4 13 reg(c) address
5 XEQ 03
6 "MAIN"
7 AVIEW
8 320 all memory
9 STO M
10 192 origin
11 GTO 03
12 LBL "XMSWAP"
13 "XF/M" base block
14 AVIEW provide feedback
15 CF 00 base block
16 64 origin
17 XEQ 00 swap block
18 "EM-1" first EM module
19 AVIEW provide feedback
20 SF 00 larger block
21 513 origin
22 XEQ 00 swap block
23 "EM-2" second EM module
24 AVIEW provide feedback
25 SF 00 larger block
26 769 origin
27 LBL 00 swap block
28 X<> M address to M
29 128 base size
30 FS?C 00 larger block?
31 239 extended size
32 X<> M store in M
33 LBL 03
34 RCL X origin
35 1024 offset address
36 + destination
37 LBL 01
38 PEEKR read destination value
39 X<> Z
40 PEEKR read source value
41 R^ lift for compare
42 X=Y? are they equal?
43 SF 00 flag it so
44 RDN undo lift
45 FS?C 00 equal values?
46 GTO 02 yes, skip writing
47 X<> T position them crossed
48 POKER write them back
49 RDN
50 X<> Z position them crossed
51 POKER write them back
52 LBL 02 merge code
53 RDN locate addreses in X, Y
54 E
55 ST+ Z increase adr-1
56 + increase adr-2
57 DSE M decrease counter
58 GTO 01 loop back if not done
59 "DONE" block is done
60 AVIEW
61 END
Cheers,
'AM
PS. The attached pdf contains both programs in a nicer format - does anybody know how to get the code properly formatted in the post window???