User RAM (Cards of 8 Kb, 16 Kb or 32 Kb in two slots)
All my clues and the given addresses will only work if you have only one RAM card set in slot #1, using SET MEM "C" mode.
Knowledge of the RAM Card memory map
When you refer to the memory map, you find out that the RAM cards have a different first address according to their size, but always have the same last address of &FFFF which is the maximum address that can be managed by a 16 bits address pointer (see PC and DP registers in my page about the
Sharp PC-1360 CPU and Machine Language Quick Manual).
Card Type | Start Address | End Address | Conversion to 32 Kb Card |
---|
4 Kb | &F000 | &FFFF | + &7000 |
---|
8 Kb | &E000 | &FFFF | + &6000 |
---|
16 Kb | &C000 | &FFFF | + &4000 |
---|
32 Kb | &8000 | &FFFF | + &0000 |
---|
All RAM cards will be organized the same way, according to the following map :
- Small System RAM : 48 bytes
- Big System RAM : 1584 bytes, including :
- Reserve Area : 144 bytes
- standard Variables : 208 bytes
- copy of Small System RAM : 48 bytes
- "real" Big System RAM : 1184 bytes
- Basic Space : RAM Card capacity - 1632 bytes, for Basic programs and variables
Notice : it is not worth giving all addresses for each memory card size. I will give addresses for the 32 Kb card. You will find the addresses for all other cards by adding the value found in the
Conversion to 32 Kb Card column of the above table, except for the Big System RAM which is directly correlated to the to top of the card, which has always the same address of &FFFF.
Small System RAM
This is a very small memory area of 48 bytes that holds some important addresses. It ranges from &8000 to &8030 (for 32 Kb RAM card). The Big System RAM has a full copy of the Small System RAM. So PEEKING and POKING in one or the other will have the same result.
Actually, the only interesting thing about the Small System RAM is that it is the only area of the System RAM that you will still be able to read if you use two RAM cards in SET MEM "B" or SET MEM "D" mode.
Function | Small System RAM | Big System RAM |
---|
Basic Start Address | [&8007] + 256 x [&8008] | [&FFD7] + 256 x [&FFD8] |
---|
Basic End Address | [&8009] + 256 x [&800A] | [&FFD9] + 256 x [&FFDA] |
---|
Merge Basic Start Address | [&800B] + 256 x [&800C] | [&FFDB] + 256 x [&FFDC] |
---|
Basic Variables Start Address | [&800D] + 256 x [&800E] | [&FFDD] + 256 x [&FFDE] |
---|
Password of Basic programs | [&8010]..[&8016] | [&FFE0]..[&FFE6] |
---|
Clue : if you feel like protecting your PRO mode by a password, you have to know that reading the range of addresses for the Password will not give you any result but an Error 1. So, I highly recommand you to insert the following 2 lines of code at the end of your Basic program to recover your password if you were to forget it... by simply typing
DEF and
= keys.
64999 "=":A$="":FOR J=&FFE0 TO &FFE6:A$=A$+CHR$(PEEK J):IF PEEK J=0 LET J=&FFE6
65000 NEXT J:PRINT A$:ENDBig System RAM
This area deals with many relationships and parameters between the PC and mainly its Basic interpreter. It is 1584 bytes long and ranges from &F9D0 to &FFFF.
Function | Big System RAM |
---|
standard Variables | [&F9D0]..[&FA9F] |
---|
real Big System RAM | [&FAA0]..[&FF3E] |
---|
Reserve area | [&FF3F]..[&FFCF] |
---|
copy of Small System RAM | [&FFD0]..[&FFFF] |
---|
- Standard Variables
These are the 26 variables that have to be used in priority since their storage space is reserved whether you use them or not (in opposition to Basic variables space which changes upon use).
Variable stockage | Num. | Alpha. | Num. Table | Alpha. Table |
---|
[&F9D0]..[&F9D7] | Z | Z$ | A(26) | A$(26) |
---|
[&F9D8]..[&F9DF] | Y | Y$ | A(25) | A$(25) |
---|
[&F9E0]..[&F9EF] | X | X$ | A(24) | A$(24) |
---|
... | ... | ... | ... | ... |
---|
[&FA90]..[&FA97] | B | B$ | A(2) | A$(2) |
---|
[&FA98]..[&FA9F] | A | A$ | A(1) | A$(1) |
---|
- Alphanumerical variables
Since a good example is always better than a long explanation, let's put the word "ALDWEBGOOD" in Z$ by simply typing : Z$="ALDWEBGOOD"
Here is what will succeed :
Address | Z$ | Comment |
---|
&F9D0 | 245 | Token indicating alphanumerical value |
---|
&F9D1 | 65 | ASCII code of A |
---|
&F9D2 | 76 | ASCII code of L |
---|
&F9D3 | 68 | ASCII code of D |
---|
&F9D4 | 87 | ASCII code of W |
---|
&F9D5 | 69 | ASCII code of E |
---|
&F9D6 | 66 | ASCII code of B |
---|
&F9D7 | 71 | ASCII code of G |
---|
Now, let's change the value of Z$ to ZEN, by typing : Z$="ZEN"
Address | Z$ | Comment |
---|
&F9D0 | 245 | Token indicating alphanumerical value |
---|
&F9D1 | 90 | ASCII code of Z |
---|
&F9D2 | 69 | ASCII code of E |
---|
&F9D3 | 78 | ASCII code of N |
---|
&F9D4 | 0 | Token indicating end of alphanumerical value |
---|
&F9D5 | 69 | ASCII code of E |
---|
&F9D6 | 66 | ASCII code of B |
---|
&F9D7 | 71 | ASCII code of G |
---|
Let's just note that standard alphanumerical variables cannot be bigger than 7 characters which is very small indeed. Hopefully user defined variables will allow greater sizes (it is just funny to note that this system of standard Variables already existed in the first Pocket TRS-80).
- Numerical variables
The PC-1360 uses a very smart coding system that can store all numbers ranging from 1.E-99 to 9.999999999E+99. It is called BCD and stands for Binary Coded Decimal. The principle is that one byte is made of 8 bits. A group of 4 bits, that we will call a "quartet", can store up to 16 combinations which is enough for our needs.
Let's explain this BCD system with an example : Z=-1.2E+39
Address | Z | Quartet 1 | Quartet 2 |
---|
&F9D0 | &03 | 0 = Positive Exponent | 3 = Exponent #1 |
---|
&F9D1 | &98 | 9 = Exponent #2 | 8 = Negative Sign |
---|
&F9D2 | &12 | 1 = Number #1 | 2 = Number #2 |
---|
&F9D3 | &00 | 0 = Number #3 | 0 = Number #4 |
---|
&F9D4 | &00 | 0 = Number #5 | 0 = Number #6 |
---|
&F9D5 | &00 | 0 = Number #7 | 0 = Number #8 |
---|
&F9D6 | &00 | 0 = Number #9 | 0 = Number #10 |
---|
&F9D7 | &00 | Not used | Not used |
---|
- real Big System RAM
This area holds many of the parameters and data for the Basic interpreter.
Just note that from address &FD80 to address &FDDF are stored all ASCII codes for the characters displayed on the LCD screen. This memory storage is 96 bytes long (because 4 lines x 24 characters per line = 96 characters).
- Reserve area
This 144 bytes long area is ment to store commands that you input in the Reserve mode.
The coding is quite strange but I figured it out : a first byte related to the letter pressed in addition to the Shift key (see table below) followed by the data attributed to that letter key. Data is not put in a specific order, the order works according to the rule "last inputed or modified, last in the list". If you delete an entry, the void space is replaced by the data of further commands. Data follows the same rules as for Basic (see below) in its coding rule : 254 coding + Basic Token code + arguments data.
Reserve Letter | Letter Code |
---|
A | 1 |
---|
S | 19 |
---|
D | 4 |
---|
F | 6 |
---|
G | 7 |
---|
H | 8 |
---|
J | 10 |
---|
K | 11 |
---|
L | 12 |
---|
= | 28 |
---|
Z | 26 |
---|
X | 24 |
---|
C | 3 |
---|
V | 22 |
---|
B | 2 |
---|
N | 14 |
---|
M | 13 |
---|
SPC | 27 |
---|
- copy of Small System
See above paragraph about Small System RAM.
Basic Space
The Basic space is divided in two areas : the Basic programs themselves and the Variables storage.
- Basic Programs
Basic programs are put between the Basic Start Address and the Basic End Address (see Small System RAM). These two addresses are filled with a 255 value. The Basic End Address will change according to the size of your Basic programming.
The Basic lines have a very simple structure :Line number HB | Line number LB | Length of Line | Data of Line | End code of Line = CR |
---|
Line number = 256 x HB + LB
CR : stands for Carriage Return
The Data of Line has itself a very easy to understand structure :Instruction Token = 254 | Basic Instruction Token | Basic Instruction arguments | ... |
---|
Let's see how everything works with an example of a simple Basic program :
10 CLS:WAIT 0
20 FOR I=0 TO 9
30 PRINT I;:NEXT I
40 END
Address(es) | Value(s) | ASCII Code(s) | Comment |
---|
&8030 | 255 | | Basic Start Address |
---|
&8031 - &8032 | 0 10 | | Line number : 0 *256 + 10 = 10 |
---|
&8033 | 7 | | Line length = 7 bytes (including CR of End of Line) |
---|
&8034 - &8035 | 254 80 | | CLS Instruction |
---|
&8036 | 58 | : | Link between instructions |
---|
&8037 - &8038 | 254 42 | | WAIT Instruction |
---|
&8039 | 48 | 0 | Argument for WAIT Instruction |
---|
&803A | 13 | | CR value. End of line 10 |
---|
&803B - &803C | 0 20 | | Line number : 0 *256 + 20 = 20 |
---|
&803D | 9 | | Line length = 9 bytes |
---|
&803E - &803F | 254 87 | | FOR Instruction |
---|
&8040 - &8042 | 73 61 48 | I = 0 | Argument for FOR Instruction |
---|
&8043 - &8044 | 254 82 | | TO Instruction |
---|
&8045 | 57 | 9 | Argument for TO Instruction |
---|
&8046 | 13 | | CR value. End of line 20 |
---|
&8047 - &8048 | 0 30 | | Line number : 0 *256 + 30 = 30 |
---|
&8049 | 9 | | Line length = 9 bytes |
---|
&804A - &804B | 254 96 | | PRINT Instruction |
---|
&804C - &804D | 73 59 | I ; | Argument for PRINT Instruction |
---|
&804E | 48 | : | Link between instructions |
---|
&804F - &8050 | 254 91 | | NEXT Instruction |
---|
&8051 | 73 | | Argument for NEXT Instruction |
---|
&8052 | 13 | | CR value. End of line 30 |
---|
&8053 - &8054 | 0 40 | | Line number : 0 *256 + 40 = 40 |
---|
&8055 | 3 | | Line length = 3 bytes |
---|
&8056 - &8057 | 254 90 | | END Instruction |
---|
&8058 | 13 | | CR value. End of line 40 |
---|
&8059 | 255 | | Basic End Address |
---|
As from the above explanations, here is the table of all Basic Instructions Tokens :
Basic Hex Dec Instruction Token Token ABS &99 153 ACS &9E 158 AREAD &63 099 ARUN &74 116 ASC &D0 208 ASN &9D 157 ATN &9F 159 AUTOGOTO &75 117 BASIC &36 054 BEEP &29 041 CALL &31 049 CHAIN &67 103 CHR$ &F0 240 CIRCLE &6F 111 CLEAR &2E 046 CLOAD &16 022 CLOSE &22 034 CLS &50 080 COLOR &44 068 CONSOLE &24 036 CONT &12 018 COS &96 150 CROTATE &6E 110 CSAVE &20 032 CSIZE &43 067 CURSOR &51 081 DATA &5E 094 DEG &9B 155 DEGREE &26 038 DELETE &1B 027 DIM &30 048 DMS &9C 156 END &5A 090 ERASE &3A 058 EXP &93 147 FOR &57 087 GCURSOR &68 104 GLCURSOR &6C 108 GOSUB &62 098 GOTO &2B 043 GPRINT &33 051 GRAD &28 040 GRAPH &41 065 IF &56 086 INKEY$ &E9 233 INPUT &61 097 INT &98 152 LEFT$ &EB 235 LEN &D2 210 LET &58 088 LF &42 066 LINE &69 105 LIST &14 020 LLINE &6A 106 LLIST &15 021 LN &91 145 LOAD &18 024 LOG &92 146 LPRINT &64 100 LTEXT &40 064 MDF &80 128 MEM &AF 175 MERGE &17 023 MID$ &EA 234 NEXT &5B 091 NEW &11 017 ON &55 085 OPEN &21 033 OPEN$ &E8 232 PAINT &70 112 PASS &13 019 PAUSE &5F 095 PEEK &A4 164 PI &AE 174 POINT &AD 173 POKE &32 050 PRESET &35 053 PRINT &60 096 PSET &34 052 RADIAN &27 039 RANDOM &25 037 READ &5D 093 REM &59 089 RENUM &19 025 RESTORE &66 102 RETURN &65 101 RIGHT$ &EC 236 RLINE &6B 107 RND &A0 160 RUN &10 016 SAVE &23 035 SET (MEM) &3F(&AF) 063(175) SGN &9A 154 SIN &95 149 SORGN &6D 109 SQR &94 148 STEP &53 083 STOP &5C 092 STR$ &F1 241 TAN &97 151 TEXT &37 055 THEN &54 084 TO &52 082 TROFF &2D 045 TRON &2C 044 USING &2F 047 VAL &D1 209 WAIT &2A 042 |
- Basic Variables
Basic variables are put between the Basic Variables Start Address and the Big System RAM Start Address (see Big System RAM). The Basic Variables Start Address will change according to the size of your Basic variables.
Address | Content of Address / Meaning | Comment |
---|
Byte #1 | First ASCII Code | Always First ASCII Code of variable |
---|
Byte #2 | 1-26 : Second ASCII Code - 64 65-90 : Second ASCII Code 128 : {null} 129-154 : Second ASCII Code + 64 160 : {null} 193-218 : Second ASCII Code + 128 | 1-26 : two letters string array. Ex : LD$(10). 65-90 : two letters number variable. Ex : LD. 128 : one letter number array. Ex : L(10). 129-154 : two letters string variable. Ex : LD$. 160 : one letter string array. Ex : L$(10). 193-218 : two letters number array. Ex : LD(10). |
---|
Byte #3 | HB : Distance to End of Array | Distance to End of Array (in bytes) : EoA = HB x 256 +LB |
---|
Byte #4 | LB : Distance to End of Array |
---|
Byte #5 | Second Index (*,i) | 0 if variable |
---|
Byte #6 | First Index (i,*) | 0 if variable or if simple array variable (non matrix variable) |
---|
Byte #7 | Length of a Variable/Array's values | 8 if number variable/array 16 if string variable/array (unless specified otherwise in the DIM instruction) |
---|
Byte #8 to EoA | Data | Groups of bytes according to Byte #7 value. |
---|
Let's visualize this stuff with an example :
CLEAR
DIM L$(1,0)*2
L$(0,0)="LD"
L$(1,0)="SL"
Address | Value | Comment |
---|
&F9C5 | 76 | ASCII code of L |
---|
&F9C6 | 160 | One letter string array, so L$ |
---|
&F9C7 | 0 | HB = 0 |
---|
&F9C8 | 7 | LB = 7, so End of Array in 7 bytes |
---|
&F9C9 | 0 | L$(*,0) |
---|
&F9CA | 1 | L$(1,*), so L$(1,0) |
---|
&F9CB | 2 | Length of one array's value (*2) |
---|
&F9CC | 76 | L$(0,0) : ASCII code of L |
---|
&F9CD | 68 | L$(0,0) : ASCII code of D |
---|
&F9CE | 83 | L$(1,0) : ASCII code of S |
---|
&F9CF | 76 | L$(1,0) : ASCII code of L |
---|