Post Reply 
(PC-1211) Engineering format
05-20-2022, 02:23 AM (This post was last modified: 05-21-2022 09:23 PM by robve.)
Post: #18
RE: (PC-1211) Engineering format
(05-11-2022 11:19 PM)Dave Britten Wrote:  That would be extremely handy to have. How do the Sharp computers distinguish between MERGEd programs? Do they just look for out-of-order line numbers? Some kind of catalog command to list all the labels in memory would be nice too.

The MERGEd BASIC Programs Rotator "prot" code is complete Smile

I'm quite happy with it. It makes it much more convenient to store and run multiple programs on the early Sharp pocket computer models that lack a RAM file system.

I've tested "prot" on a PC-1360 and a PC-1350. I wanted to make sure that the code is fully compatible with the internals of these machines. So the machines won't hang or otherwise misbehave. To do so, I had to research materials on the memory organization of these machines to find the flags that control program editing and the display of the last line when cursor up is pressed. The START, END and MERGE pointers are not sufficient to update. Other flags must be set. However, there was not a single source of information I could find among many online resources that I've collected over years that point to the 0x35 internal RAM register used by the BASIC interpreter. After dumping and comparing external and internal RAM and much experimenting, I am convinced that I found the right flags in register 0x35 as well as the external RAM flags and pointers to update.

Installation
  • load the BASIC program for the specific machine (and RAM card for PC-1350) and run it (DEF-A to skip checksum)
  • after running the installer the code is installed and the installer deletes itself

Now you have two CALLs, one to create a new MERGEd BASIC program that is added to the list at the bottom and one to rotate the programs so that the previous MERGEd program rotates to the bottom of the list and can be edited.

For example, suppose we have one program "A" already in memory:

    1 "A" REM my first program
    2 PRINT "I am program A"


To add a new program, CALL 32818 (PC-1360) to create a new MERGEd program consisting of one line with a quote:

    1 "A" REM my first program
    2 PRINT "I am program A"
    1 "


Note that the new line 1 " starts a new program that is independent of the previous programs, even when the listing appears to be continuous. To verify, LIST only lists the last merged program's first lines. In this case:

    LIST
    1 "


Complete the new program by adding a label "B" and the rest of the code:

    1 "A" REM my first program
    2 PRINT "I am program A"
    1 "B" REM my second program
    2 PRINT "I am program B"


Executing RUN will run program "B", because it is the last MERGEd just as LIST list program "B". Program "A" is executed with RUN "A". Program "A" stops at line 2 and will not run program "B". Programs are internally separated when MERGEd. Separate programs can call each other using GOTO and GOSUB with labels or string expressions. RESTORE of labelled data in another program is also possible. In this way, libraries of routines and data can be created and shared among several programs.

CALL 32820 (PC-1360) rotates the programs, effectively switching "A" and "B":

    1 "B" REM my second program
    2 PRINT "I am program B"
    1 "A" REM my first program
    2 PRINT "I am program A"


Program "A" can now be edited, which was not possible before the rotation:

    1 "B" REM my second program
    2 PRINT "I am program B"
    1 "A" REM my first program
    2 PRINT "I am the first program"


Note that only the last program MERGEd can be edited, as stated in the Sharp manuals. If you try to edit a line of an older MERGEd program, it will end up in the last program!

Use the "CAT" program to list program labels (see earlier post.)

The last program can be deleted with DELETE, (with comma) or just type the line numbers until the program is deleted. When the last program is deleted, the one before it will become the last program that can be edited. Note that NEW, LOAD/CLOAD and MERGE can be used and work fine. SAVE/CSAVE saves all programs.

The "prot" machine code takes only about 245 bytes of RAM space.

Program source and usage on the PC-1360

Code:
100 CLEAR:V=1
101 "P" REM ** prot.ihx **
102 POKE 32816,44,85,44,106,16,255,232,214,128,56,75,130,16,255,215,0
103 POKE 32832,5,24,132,21,130,19,4,11,120,128,221,132,16,255,215,26
104 POKE 32848,134,19,4,10,3,0,36,66,56,7,4,36,132,20,45,9
105 POKE 32864,130,16,255,217,26,21,81,20,59,25,16,255,219,134,27,0
106 POKE 32880,5,130,16,255,215,24,19,6,10,16,128,7,130,25,16,254
107 POKE 32896,240,27,181,96,0,55,16,255,247,87,101,129,218,2,35,0
108 POKE 32912,5,132,19,2,8,4,16,255,215,130,25,45,45,0,3,130
109 POKE 32928,16,255,215,24,5,19,4,10,132,21,56,28,6,130,19,6
110 POKE 32944,10,19,6,10,16,255,219,130,27,16,128,11,27,16,255,232
111 POKE 32960,213,128,16,128,24,213,128,35,38,66,38,66,38,2,34,38
112 POKE 32976,2,13,38,2,255,38,16,255,217,134,27,45,109,138,19,2
113 POKE 32992,0,5,8,120,129,2,130,19,14,10,19,10,10,132,21,130
114 POKE 33008,10,20,130,19,4,11,138,21,140,20,120,129,2,130,19,10
115 POKE 33024,10,10,134,19,4,10,134,20,218,210,218,210,67,42,4,195
116 POKE 33040,58,17,136,219,137,5,7,85,36,83,6,39,73,43,8,195
117 POKE 33056,43,11,55,255,255
118 A=32816:B=245:C=19182
119 IF V FOR I=A TO A+B-1:C=C-PEEK I:NEXT I:IF C<>0 PRINT "CRC ERR":END
9000 CALL A:END
9001 "A" V=0:GOTO "P"
  • CALL 32818 creates a new MERGEd BASIC program with line 1
  • add a label after the quote to name the new program, then complete the program
  • CALL 32820 rotates the MERGEd programs
To prevent forgetting and mistyping the CALL addresses, in RESERVE MODE define SHIFT-M to CALL 32818 and SHIFT-SPC to CALL 32820

Disclaimer: I have only tested with ONE RAM card in slot S1!! Not sure if a second card in slot S2 works.

Program source and usage on the PC-1350 with 16K RAM card

Code:
100 CLEAR:V=1
101 "P" REM ** prot.ihx **
102 POKE 8240,44,85,44,101,16,111,18,214,128,56,75,130,16,111,1,0
103 POKE 8256,5,24,132,21,130,19,4,11,120,32,216,132,16,111,1,26
104 POKE 8272,134,19,4,10,3,0,36,66,56,7,4,36,132,20,45,9
105 POKE 8288,130,16,111,3,26,21,81,20,59,25,16,111,5,134,27,0
106 POKE 8304,5,130,16,111,1,24,19,6,10,16,32,7,130,25,16,111
107 POKE 8320,28,27,181,96,0,55,2,30,3,33,0,5,132,19,2,8
108 POKE 8336,4,16,111,1,130,25,45,40,0,3,130,16,111,1,24,5
109 POKE 8352,19,4,10,132,21,56,28,6,130,19,6,10,19,6,10,16
110 POKE 8368,111,5,130,27,16,32,11,27,16,111,18,213,128,16,32,24
111 POKE 8384,213,128,35,38,66,38,66,38,2,34,38,2,13,38,2,255
112 POKE 8400,38,16,111,3,134,27,45,104,138,19,2,0,5,8,120,32
113 POKE 8416,253,130,19,14,10,19,10,10,132,21,130,10,20,130,19,4
114 POKE 8432,11,138,21,140,20,120,32,253,130,19,10,10,10,134,19,4
115 POKE 8448,10,134,20,218,210,218,210,67,42,4,195,58,17,136,219,137
116 POKE 8464,5,7,85,36,83,6,39,73,43,8,195,43,11,55,255,255
117 A=8240:B=240:C=13771
118 IF V FOR I=A TO A+B-1:C=C-PEEK I:NEXT I:IF C<>0 PRINT "CRC ERR":END
9000 CALL A:END
9001 "A" V=0:GOTO "P"
  • CALL 8242 creates a new MERGEd BASIC program with line 1
  • add a label after the quote to name the new program, then complete the program
  • CALL 8244 rotates the MERGEd programs
To prevent forgetting and mistyping the CALL addresses, in RESERVE MODE define SHIFT-M to CALL 8242 and SHIFT-SPC to CALL 8244

Program source and usage on the PC-1350 without RAM card

Code:
100 CLEAR:V=1
101 "P" REM ** prot.ihx **
102 POKE 24624,44,85,44,101,16,111,18,214,128,56,75,130,16,111,1,0
103 POKE 24640,5,24,132,21,130,19,4,11,120,96,216,132,16,111,1,26
104 POKE 24656,134,19,4,10,3,0,36,66,56,7,4,36,132,20,45,9
105 POKE 24672,130,16,111,3,26,21,81,20,59,25,16,111,5,134,27,0
106 POKE 24688,5,130,16,111,1,24,19,6,10,16,96,7,130,25,16,111
107 POKE 24704,28,27,181,96,0,55,2,30,3,97,0,5,132,19,2,8
108 POKE 24720,4,16,111,1,130,25,45,40,0,3,130,16,111,1,24,5
109 POKE 24736,19,4,10,132,21,56,28,6,130,19,6,10,19,6,10,16
110 POKE 24752,111,5,130,27,16,96,11,27,16,111,18,213,128,16,96,24
111 POKE 24768,213,128,35,38,66,38,66,38,2,34,38,2,13,38,2,255
112 POKE 24784,38,16,111,3,134,27,45,104,138,19,2,0,5,8,120,96
113 POKE 24800,253,130,19,14,10,19,10,10,132,21,130,10,20,130,19,4
114 POKE 24816,11,138,21,140,20,120,96,253,130,19,10,10,10,134,19,4
115 POKE 24832,10,134,20,218,210,218,210,67,42,4,195,58,17,136,219,137
116 POKE 24848,5,7,85,36,83,6,39,73,43,8,195,43,11,55,255,255
117 A=24624:B=240:C=14219
118 IF V FOR I=A TO A+B-1:C=C-PEEK I:NEXT I:IF C<>0 PRINT "CRC ERR":END
9000 CALL A:END
9001 "A" V=0:GOTO "P"
  • CALL 24626 creates a new MERGEd BASIC program with line 1
  • add a label after the quote to name the new program, then complete the program
  • CALL 24628 rotates the MERGEd programs
To prevent forgetting and mistyping the CALL addresses, in RESERVE MODE define SHIFT-M to CALL 24626 and SHIFT-SPC to CALL 24628

What about other Sharp PC?

The "prot" program (for lack of a better name) should in principle work on other Sharp PC with some modifications, because it does not use non-portable syscalls. If there is some interest in this, then we should create a new thread. I will create a GitHub repo with the source code, installers and documentation.

- Rob

"I count on old friends" -- HP 71B,Prime|Ti VOY200,Nspire CXII CAS|Casio fx-CG50...|Sharp PC-G850,E500,2500,1500,14xx,13xx,12xx...
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (PC-1211) Engineering format - Dan C - 05-10-2022, 05:15 PM
RE: (PC-1211) Engineering format - robve - 05-10-2022, 08:47 PM
RE: (PC-1211) Engineering format - robve - 05-11-2022, 10:38 PM
RE: (PC-1211) Engineering format - robve - 05-10-2022, 05:19 PM
RE: (PC-1211) Engineering format - robve - 05-10-2022, 09:16 PM
RE: (PC-1211) Engineering format - robve - 05-13-2022, 05:43 PM
RE: (PC-1211) Engineering format - robve - 05-15-2022, 09:24 PM
RE: (PC-1211) Engineering format - robve - 05-20-2022 02:23 AM
RE: (PC-1211) Engineering format - robve - 05-13-2022, 08:12 PM
RE: (PC-1211) Engineering format - robve - 05-13-2022, 11:26 PM
RE: (PC-1211) Engineering format - robve - 05-16-2022, 12:38 AM
RE: (PC-1211) Engineering format - robve - 05-21-2022, 09:44 PM



User(s) browsing this thread: 1 Guest(s)