Post Reply 
(PC-1211) Engineering format
05-10-2022, 02:32 PM
Post: #1
(PC-1211) Engineering format
Most of the Sharp pocket computers don't have any built in engineering display format, so I whipped up this quickie to somewhat fill this gap. I wrote it on my PC-1211, but it should work on pretty much any model of Sharp that adheres to the INT function always rounding down (i.e. not truncate/round toward zero).

Usage

From the keyboard: press SHIFT (or DEF) = to display current input/result in engineering format. Note that attempting to do this in the middle of a running program will terminate the running program.

From a program: GOSUB "ENG" to convert X to mantissa and exponent stored in M and E respectively. You can then format these values as desired in your PRINT/USING statements.

Code:
1:"="AREAD X:GOSUB "ENG":PRINT M;"E";E:END
2:"ENG"E=0:M=0:IF X=0RETURN
3:E=3*INT (LOG ABS X/3):M=X/10^E:RETURN
Visit this user's website Find all posts by this user
Quote this message in a reply
05-10-2022, 05:15 PM (This post was last modified: 05-10-2022 05:19 PM by Dan C.)
Post: #2
RE: (PC-1211) Engineering format
Nice! Can i use this on my PC-1262 also? Is the basic in PC-1211 the same as in later SHARP machines, like the PC-1262 and many others?
Find all posts by this user
Quote this message in a reply
05-10-2022, 05:19 PM
Post: #3
RE: (PC-1211) Engineering format
Your nifty solution reminds me of the decimal places and scientific display DEF assignments I've used in the past on my Sharp PC-1350 in the 80s:

Code:
' <expr> DEF-S scientific notation with #=? decimal places
' <expr> DEF-D fixed notation with #=? decimal places, may cause error if value exceeds 1E10

1 "S" AREAD X: USING: INPUT "#=";O: PRINT USING LEFT$("##.#########", O+3)+"^";X: END
2 "D" AREAD X: USING: INPUT "#=";O: PRINT USING "###########."+LEFT$("#########", O);X: END

Works on other Sharp PC, but unfortunately not on the PC-1211. Allows the output to be used as an answer to continue calculations.

One of the reasons I kept using the Sharp pocket computers is because it was so easy to add features. Modern advanced calculators like the wonderful HP Prime have everything already built-in of course Smile

- Rob

"I count on old friends to remain rational"
Visit this user's website Find all posts by this user
Quote this message in a reply
05-10-2022, 06:03 PM
Post: #4
RE: (PC-1211) Engineering format
(05-10-2022 05:15 PM)Dan C Wrote:  Nice! Can i use this on my PC-1262 also? Is the basic in PC-1211 the same as in later SHARP machines, like the PC-1262 and many others?

Yup! I just typed it in on my 1261 to test (it's basically identical to the 1262). I think this will work on nearly any Sharp, though the "=" label depends on having the user-definable keys and AREAD available, which a few models lack (PC-E500, Sharp Wizard BASIC cards...). The GOSUB routine probably would still work the same, though.


(05-10-2022 05:19 PM)robve Wrote:  Your nifty solution reminds me of the decimal places and scientific display DEF assignments I've used in the past on my Sharp PC-1350 in the 80s:

Code:
' <expr> DEF-S scientific notation with #=? decimal places
' <expr> DEF-D fixed notation with #=? decimal places, may cause error if value exceeds 1E10

1 "S" AREAD X: USING: INPUT "#=";O: PRINT USING LEFT$("##.#########", O+3)+"^";X: END
2 "D" AREAD X: USING: INPUT "#=";O: PRINT USING "###########."+LEFT$("#########", O);X: END

Works on other Sharp PC, but unfortunately not on the PC-1211. Allows the output to be used as an answer to continue calculations.

One of the reasons I kept using the Sharp pocket computers is because it was so easy to add features. Modern advanced calculators like the wonderful HP Prime have everything already built-in of course Smile

- Rob

That's a clever way to do it. You could probably get this to work on the 1211 by using a calculated GOTO/GOSUB and a bunch of different sized string literals, but it wouldn't be terribly efficient in terms of RAM usage!

I agree that the Sharp models are nice for customizing by adding small routines like this to memory. I just wish they had something resembling the multiple program spaces of Casios, and a simple way to overload/switch your DEF key assignments on the fly.
Visit this user's website Find all posts by this user
Quote this message in a reply
05-10-2022, 08:47 PM
Post: #5
RE: (PC-1211) Engineering format
(05-10-2022 06:03 PM)Dave Britten Wrote:  I agree that the Sharp models are nice for customizing by adding small routines like this to memory. I just wish they had something resembling the multiple program spaces of Casios.

Ha, my machine can do that already:

[Image: PC-1350.jpeg]

- Rob

"I count on old friends to remain rational"
Visit this user's website Find all posts by this user
Quote this message in a reply
05-10-2022, 09:16 PM
Post: #6
RE: (PC-1211) Engineering format
A quick-and-dirty combination of the two programs to display scientific or engineering notation with a given number of digits (0 to 9):

Code:
1 "=" AREAD X: INPUT "SCI#";O: PRINT USING LEFT$("##.#########",O+3)+"^";X: END
2 IF X<>0 INPUT "ENG#";O: USING "###########."+LEFT$("#########",O): O=3*INT(LOG ABS X/3): PRINT X/10^O;"E"+STR$ O: END
3 USING: PRINT X: END

DEF= to display the current value scientific notation with the specified SCI# digits. Press ENTER (to skip SCI#) to display in engineering with the specified ENG# digits. Press ENTER to display normally "as is" .

Won't work on the PC-1211 but should work on all other PC that have 24 character wide LCDs.

- Rob

"I count on old friends to remain rational"
Visit this user's website Find all posts by this user
Quote this message in a reply
05-11-2022, 02:14 AM
Post: #7
RE: (PC-1211) Engineering format
(05-10-2022 08:47 PM)robve Wrote:  
(05-10-2022 06:03 PM)Dave Britten Wrote:  I agree that the Sharp models are nice for customizing by adding small routines like this to memory. I just wish they had something resembling the multiple program spaces of Casios.

Ha, my machine can do that already:

- Rob

Oh yes, I think I've seen that before. Very nice little hack. Haven't tried it on my 1360 to see if it'll work yet. Of course, I have approximately a gallon of 8 KB RAM cards, so I can just swap between a handful of those easily enough too. Smile
Visit this user's website Find all posts by this user
Quote this message in a reply
05-11-2022, 10:38 PM
Post: #8
RE: (PC-1211) Engineering format
(05-11-2022 02:14 AM)Dave Britten Wrote:  Oh yes, I think I've seen that before. Very nice little hack. Haven't tried it on my 1360 to see if it'll work yet. Of course, I have approximately a gallon of 8 KB RAM cards, so I can just swap between a handful of those easily enough too. Smile

Yep, RAM cards work well too.

The MultiPC machine program won't work on the PC-1360 without updating it to call the appropriate ROM routines. It uses a few ROM routine calls. In that respect the PC-1360 is slightly more complex to program in assembly since the routines reside in ROM banks. Switching banks isn't as easy as on the PC-E500 CPU that has a 20 bit address space.

I could perhaps write a new machine program to allow multiple BASIC programs to be used in a different way than MultiPC. This machine program I have in mind simply moves one of the earlier MERGEd BASIC programs on top that you select with a CALL, so it can be edited. Kind of like a Rolodex of BASIC programs from which you can pick one to work on. It is also possible to create a new (MERGEd) BASIC program on top to start writing a new BASIC program, without having to MERGE from cassette or serial. This should always work, because MERGE already supports multiple BASIC programs "stacked" (i.e. not really merging the BASIC lines as other BASIC dialects typically do). The BASIC program on top of the "stack" can be edited. I suspect that this machine program I have in mind will be small and won't need much ROM routine support, if any. Only the addresses of the BASIC start, BASIC end and the last MERGE address are needed, which all Sharp PC have in RAM (and on RAM cards) and those are well documented.

- Rob

"I count on old friends to remain rational"
Visit this user's website Find all posts by this user
Quote this message in a reply
05-11-2022, 11:19 PM
Post: #9
RE: (PC-1211) Engineering format
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.
Visit this user's website Find all posts by this user
Quote this message in a reply
05-13-2022, 05:43 PM (This post was last modified: 05-13-2022 08:01 PM by robve.)
Post: #10
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?\

I dusted off some of my old PC-1350 notes. The following is for S-BASIC for most Sharp PCs. I don't know for sure if this also holds for the earlier PC-1211 BASIC, probably not. Also the PC-1500, PC-1600, PC-E500 and PC-G850 use variations of this memory layout.

MERGEd programs are separated by 255 byte markers:

255 <- BASIC START ADDRESS
hi <- hi line number byte
lo <- lo line number byte
len <- line length, including 0xD (13)
BASIC tokenized line
13 <- 0xD end of line (carriage return)
hi
lo
len
... etc ...
255 <- MARGE MARKER
hi <- hi line number byte
lo <- lo line number byte
len <- line length, including 0xD (13)
BASIC tokenized line
13 <- 0xD
hi
lo
len
... etc ...
255 <- LAST MERGE MARKER AT BASIC MERGE ADDRESS
hi <- hi line number byte
lo <- lo line number byte
len <- line length, including 0xD (13)
BASIC tokenized line
13 <- 0xD
hi
lo
len
... etc ...
255 <- BASIC END ADDRESS


A program ends when the next hi byte of the line number is 255, which is either the next MERGEd program or the BASIC END ADDRESS with marker.

The last MERGEd program is editable, stored in memory starting at the BASIC MERGE ADDRESS.

For the PC-1360 there are two pairs of addresses for START, END and MARGE. One extra set resides on the RAM card, so RAM card with BASIC (merged) programs can be swapped. The internal START, END and MERGE are copies that must be synched.

PC-1360 BASIC addresses with low/high address byte pairs pointers are stored at the following locations in RAM:
  • 65495 BASIC START
  • 65497 BASIC END
  • 65499 BASIC MERGE
  • 32775 RAM BASIC START
  • 32777 RAM BASIC END
  • 32779 RAM BASIC MERGE
Other relevant addresses with pointers:
  • 65266 BASIC LAST LINE
  • 65268 BASIC BREAK POINT
  • 65270 BASIC ERROR POINT
For example, PEEK 65495+256*PEEK 65496 gives the BASIC START ADDRESS. The other addresses are not relevant, unless the locations of BASIC programs are changed by moving code in memory, which means that these pointers are no longer valid e.g. with cursor up to show the last executed line. Shift-CLS (CA) prevents that.

So all that we need to do to create a new "MERGEd" program is manipulate these pointers and POKE a small new program in memory with this 3 liner:

Code:
1 "NEW" L=PEEK 65497,H=PEEK 65498,E=L+256*H: POKE 65499,L,H: POKE 32779,L,H
2 POKE E,255,0,1,5,34,42,42,34,13,255: E=E+9,H=INT(E/256),L=E-256*H
3 POKE 65497,L,H: POKE 32777,L,H: END

To create a new "MERGEd" program:
  • RUN "NEW
  • then edit the label "**" at line 1 to define a new label for the program of your liking
To delete the last program MERGEd:
  • DELETE 1,
  • WARNING: DELETE has a bug that deletes the last program that was RUN or edited, instead of the last program merged. To avoid this, delete one line of the program first, then execute DELETE 1,
A machine code routine to rotate MERGEd programs in memory would be handy indeed. That would allow for any of the programs to be rotated to the top so it can be edited. I will work on that later.

(05-11-2022 11:19 PM)Dave Britten Wrote:  Some kind of catalog command to list all the labels in memory would be nice too.

Here you go:

Code:
1 "CAT" WAIT 0: A=PEEK 65495+256*PEEK 65496+1,E=PEEK 65497+256*PEEK 65498
2 IF PEEK A<>255 IF PEEK(A+3)<>34 LET A=A+PEEK(A+2)+3: GOTO 2
3 IF A>=E END
4 IF PEEK A=255 LET A=A+1: PRINT "/ ";: GOTO 2
5 FOR B=A+4 TO E:C=PEEK B:IF C>31 IF C<127 IF C<>34 PRINT CHR$ C;: NEXT B
6 B=E: NEXT B: PRINT " ";: A=A+PEEK(A+2)+3: GOTO 2

It would be a whole lot faster in machine code, but this works reasonably quickly.

These two programs work for most Sharp PC, if you can find the BASIC START and BASIC END addresses with the pointers to manipulate. The above was for the PC-1360.

For the PC-1350:
28417 BASIC START
28419 BASIC END
28421 BASIC MERGE
But the RAM card BASIC pointers differ depending on the RAM card size:
RAM card address + 7: RAM BASIC START
RAM card address + 9: RAM BASIC END
RAM card address + 11: RAM BASIC MERGE
No RAM card address = &6000, 8K RAM card address = &4000, 16K RAM card address = &2000

For the PC-1403 (no RAM cards):
65281 BASIC START
65283 BASIC END
65285 BASIC MERGE

For the PC-1262 (no RAM cards):
26337 BASIC START
26339 BASIC END
26341 BASIC MERGE

I've tested this on the PC-1360 without any issues so far. Feedback is appreciated if you encounter a problem. The "NEW" program assumes that at least a 9 bytes are available to POKE the new program in memory. It does not check for available space (adding a MEM check might be useful).

Minor edit: changed "LIST" to "CAT" as suggested to catalog labels.

- Rob

"I count on old friends to remain rational"
Visit this user's website Find all posts by this user
Quote this message in a reply
05-13-2022, 06:01 PM
Post: #11
RE: (PC-1211) Engineering format
Neato, thanks Rob! I'll try to play around with these this weekend.

The PC-1211 doesn't have PEEK/POKE, so information on that system's internals would largely be academic, I think.
Visit this user's website Find all posts by this user
Quote this message in a reply
05-13-2022, 08:12 PM
Post: #12
RE: (PC-1211) Engineering format
(05-13-2022 06:01 PM)Dave Britten Wrote:  Neato, thanks Rob! I'll try to play around with these this weekend.

The PC-1211 doesn't have PEEK/POKE, so information on that system's internals would largely be academic, I think.

Quite right. It has no MERGE either!

- Rob

"I count on old friends to remain rational"
Visit this user's website Find all posts by this user
Quote this message in a reply
05-13-2022, 08:37 PM (This post was last modified: 05-13-2022 08:50 PM by Dave Britten.)
Post: #13
RE: (PC-1211) Engineering format
(05-13-2022 08:12 PM)robve Wrote:  
(05-13-2022 06:01 PM)Dave Britten Wrote:  Neato, thanks Rob! I'll try to play around with these this weekend.

The PC-1211 doesn't have PEEK/POKE, so information on that system's internals would largely be academic, I think.

Quite right. It has no MERGE either!

- Rob

It actually does! But it's some syntax variation of the CLOAD command (which I always forget), rather than a separate MERGE command.

EDIT: Or maybe not? I'm not seeing it in the manual. Maybe I'm thinking of a different computer... Hmm...

EDIT AGAIN: Okay, I'm NOT losing my marbles! The command is CLOAD1. This is the same as MERGE on the later models, as far as I can tell.

CLOAD1"filename"
Visit this user's website Find all posts by this user
Quote this message in a reply
05-13-2022, 11:26 PM
Post: #14
RE: (PC-1211) Engineering format
One of the best uses of the DEF key is to define:

1 " " AREAD A$: GOTO A$

Now, just type CAT DEF-SPC (DEF then SPACE key) to run "CAT". Much quicker than RUN "CAT" or GOTO "CAT". With several MERGEd programs, this can be a handy addition, I think.

The "119 Practical Programs for the TRS-80 Pocket Computer" book suggested something similar, but with INPUT Z$: GOTO Z$ to call routines.

PS. today I got a mint (no signs of use whatsoever) PC-1350 with manual from eBay. The seller has 6 of these that are (almost) unused, he said. He sold 2. The listing is still up.

- Rob

"I count on old friends to remain rational"
Visit this user's website Find all posts by this user
Quote this message in a reply
05-14-2022, 12:23 AM (This post was last modified: 05-14-2022 12:29 AM by Dave Britten.)
Post: #15
RE: (PC-1211) Engineering format
(05-13-2022 11:26 PM)robve Wrote:  One of the best uses of the DEF key is to define:

1 " " AREAD A$: GOTO A$

Now, just type CAT DEF-SPC (DEF then SPACE key) to run "CAT". Much quicker than RUN "CAT" or GOTO "CAT". With several MERGEd programs, this can be a handy addition, I think.

The "119 Practical Programs for the TRS-80 Pocket Computer" book suggested something similar, but with INPUT Z$: GOTO Z$ to call routines.

PS. today I got a mint (no signs of use whatsoever) PC-1350 with manual from eBay. The seller has 6 of these that are (almost) unused, he said. He sold 2. The listing is still up.

- Rob

Oh yeah, that's a good way to use DEF. Even more succinct than the little "command prompt" program in the book you mentioned.

It's weird, the ONLY mention I can find of the CLOAD1 command for merging in programs on the PC-1211 is on pages 62-63 of "Problem-Solving on the TRS-80 Pocket Computer". Not sure how the author got that seemingly insider information! I don't see it anywhere in the manuals.

EDIT: Oh, it's in the TRS-80 version of the manual, on page 96. Weird that it's not in the Sharp manual - my PC-1211 seems to respond to CLOAD1"filename"... I'll have to test it and see if it actually behaves as expected on the Sharp version.
Visit this user's website Find all posts by this user
Quote this message in a reply
05-15-2022, 09:24 PM (This post was last modified: 05-15-2022 09:26 PM by robve.)
Post: #16
RE: (PC-1211) Engineering format
(05-13-2022 05:43 PM)robve Wrote:  [...]
So all that we need to do to create a new "MERGEd" program is manipulate these pointers and POKE a small new program in memory with this 3 liner:

Code:
1 "NEW" L=PEEK 65497,H=PEEK 65498,E=L+256*H: POKE 65499,L,H: POKE 32779,L,H
2 POKE E,255,0,1,5,34,42,42,34,13,255: E=E+9,H=INT(E/256),L=E-256*H
3 POKE 65497,L,H: POKE 32777,L,H: END

To create a new "MERGEd" program:
  • RUN "NEW
  • then edit the label "**" at line 1 to define a new label for the program of your liking
To delete the last program MERGEd:
  • DELETE 1,
  • WARNING: DELETE has a bug that deletes the last program that was RUN or edited, instead of the last program merged. To avoid this, delete one line of the program first, then execute DELETE 1,

After a bit of experimentation with the PC-1350/60, I found that LIST may show incomplete listings after running "NEW". The programs are still there, but aren't always LISTed, unless you use LIST "label" and everything looks OK again. Deleting the last program shows nothing with LIST afterwards. Again, the programs are still there and are perfectly RUNnable. Deleting the last program does not seem to be a good idea since things may get unstable as I had noted.

Apparently, there is an internal flag in RAM to indicate merged programs are present, because the problem does not happen after executing a normal MERGE, which presumably sets this flag. It's not a big problem to use the "NEW" program, just don't delete the last program. To work around this, before using the "NEW" program, it might be best to CLOAD/LOAD a program (like the "NEW" program), then MERGE another program to activate this state properly. This way the LIST and delete problem never happens on the PC-1350 and PC-1360 and the "NEW" program creates new program slots without issues. Now, if I could just find the location of this darn flag in RAM to activate. Also still need to finish the MERGEd program rotator in assembly.

- Rob

"I count on old friends to remain rational"
Visit this user's website Find all posts by this user
Quote this message in a reply
05-16-2022, 12:38 AM
Post: #17
RE: (PC-1211) Engineering format
With a bit of logical guessing and a few PEEK and POKE experiments, I found the BASIC MERGE flags. The 8th bit of this flag is set when BASIC programs were merged. This resolves the problem with the "NEW" program garbling the LIST command.

For the PC-1360:
65512 BASIC FLAGS (128=merged programs are present)
32792 RAM BASIC FLAGS (128=merged programs are present)

For the PC-1350:
28434 BASIC FLAGS (128=merged programs are present)
RAM card address + 24: BASIC FLAGS (128=merged programs are present

For the PC-2500:
28066 BASIC FLAGS (128=merged programs are present)
RAM card address + 24: BASIC FLAGS (128=merged programs are present)

I don't have access to other Sharp PC for a while to look for the flag address. My bet is that the PC-1262 uses 26354 and the PC-1403 uses 65298

The updated PC-1360 "NEW" program:
Code:
1 "NEW" L=PEEK 65497,H=PEEK 65498,E=L+256*H: POKE 65499,L,H: POKE 32779,L,H
2 POKE E,255,0,1,5,34,42,42,34,13,255: E=E+9,H=INT(E/256),L=E-256*H
3 POKE 65497,L,H: POKE 32777,L,H: POKE 65512,PEEK 65512 OR 128: POKE 32792,PEEK 32792 OR 128: END

And a PC-1350 "NEW" program (note that &60xx in the program must be replaced with the RAM card starting address when a RAM card is present, &40xx for 8K and &20xx for 16K):
Code:
1 "NEW" L=PEEK 28419,H=PEEK 28420,E=L+256*H: POKE 28421,L,H: POKE &600B,L,H
2 POKE E,255,0,1,5,34,42,42,34,13,255: E=E+9,H=INT(E/256),L=E-256*H
3 POKE 28419,L,H: POKE &6009,L,H: POKE 28434,PEEK 28434 OR 128: POKE &6018,PEEK &6018 OR 128: END

- Rob

"I count on old friends to remain rational"
Visit this user's website Find all posts by this user
Quote this message in a reply
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 to remain rational"
Visit this user's website Find all posts by this user
Quote this message in a reply
05-21-2022, 09:44 PM
Post: #19
RE: (PC-1211) Engineering format
I've created a new GitHub repository with an improved version named "prolly" (program roll-y) to reduce the code size after installation on a machine, taking only about 220 bytes of RAM space. The repository includes the full documentation in a README and the annotated assembly source code. Bootloader bas and wav files are included for the Sharp PC-1350 and PC-1360 to install the program.

The program should be portable to the Sharp PC-126x and PC-1403 with some modifications. However, I don't have these machines to work with until much later and the PockEmul emulator doesn't appear to offer a way to load machine code for testing. But perhaps I find a way. Nothing is impossible, after all Smile

- Rob

"I count on old friends to remain rational"
Visit this user's website Find all posts by this user
Quote this message in a reply
05-24-2022, 02:38 PM
Post: #20
RE: (PC-1211) Engineering format
Cool stuff, Rob. I've been super busy lately and haven't had a chance to really tinker with this, but it's on my to-do list.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




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