The macros of the SHARP PC1500

Talk in english

Modérateur : Politburo

Répondre
cgh
Fonctionne à 2400 bauds
Fonctionne à 2400 bauds
Messages : 2277
Inscription : 30 août 2011 12:23
Localisation : Vous êtes ici -> .

The macros of the SHARP PC1500

Message par cgh » 03 avr. 2021 11:02

Here is a thread about the macros of the PC1500's ROM.

What is a macro ?
The LH5801 offers 128 macros that are described inside the vector table of the ROM at &FF00 to &FFFF. The assembly mnenomics to "call" a macro is SBR (z80-like) or VME and VEJ(lh5801 official). The ML code are from &C0 to &FE (even bytes) of &CD &nn (for &nn < &C0).
The macro SBR (&34) [ML code CD 34] will jump to address pointed by &FF34, that is &DF23. There are a lot of advantages to use macros instead of CALL:
  • First, macros require 1 byte (if >= &C0) or 2 bytes when CALL requires 3 bytes,
  • Next, the macros could be called with condition, like SBR NZ,(&nn) when CALL must be preceeded by a 'NOT' conditiionnal jump, ie, JR Z,+3 CALL &nnpp,
  • Last and important: the macros are useful for portability; If the address of macro &nn differs between two ROMs, only the vector at &FFnn is updated, and all codes calling SBR (&nn) will work. That is not true with CALL &nnpp where the address &nnpp is hard-coded inside the code and so is dependant from the ROM.
List of the macros
This will be updated dring the coming days. Please correct me if I wrote something wrong because the macros are not really documented...
Here is a list of the macros and a short expalanation In the following n p are 8-bytes values; k is a 16 bits value if the first byte >=&E0 and a 8-bits value else; mn 16-bits value; +d is a positive displacement in bytes starting a the address that immediately follows.
  • SBR (&00), n,p,d - Jump at +d if register L is not >=n and <p or if register H is not 0
  • SBR (&02), n,p,d - Same as SBR (&00) but load register HL with the value pointed by register DE, (see macro &C0)
  • SBR (&04), d - Jump at +d if the register L is not &0D or &3A (while running a program) &3A is the : BASIC separator. Carry is set if register L = &3A, else carry is cleared
  • ...
  • SBR (&34), n,p0,d0[,p1,d1,..] - Check for n+1 peers (pz,dz); jump at +dz if register A = pz (z from 0 to n). This is exactly a swicth... case. The register H is untouched by the macro and can be used to save the value of the register A.
  • ...
  • SBR (&C0) - Load register HL wiith the value pointed by register DE: if (DE) >=&E0 the HL=(DE)(DE+1) else HL=&00(DE); the register DE is incremented by 1 or 2 bytes (if >=&E0)
  • SBR (&C2) k,d - Load register HL with value pointed by register (DE) and jump at +d if register HL != k.
  • SBR (&C4) k,d - Jump at +d if register HL != k.
  • SBR (&C6) - Decrement register DE according to the value in register HL: if H >=&E0, decrement by 2, else decrement by 1
  • SBR (&C8) k,d - Load register HL with value pointed by register (DE) and jump at +d if register HL != &0D and != &3A (while running)
  • SBR (&CA), n - Save register BC to address &78n; (&78n) = B, (&78n+1) = C
  • SBR (&CC), n - Load register BC with the value at address &78n; B = (&78n), C = (&78n+1)
  • ...
  • SBR (&D0), n,d - Convert the content of arithmetic register X-REG to register HL according to the value n, and jump at +d if an error occurs. The value n defines the range for conversion: &00 : unsigned 16 bits value (0.65535), &01 : signed 16-bits value (-32768..32767), &08 : 8-bit value (0..255), &03 : BASIC line number (1..65279), &09 : Increment ?, &0A : a LCD column (0..155), &10 : cursor position 0..25, and others I don't know...
  • ...
  • SBR (&DC), - Load the string pointers from X-REG to register BC (address of the string) and register L (length)
  • SBR (&DE), d - Evaluate the BASIC expression pointed by register DE and jump at +d if an error occurs during the evaluation. The result of the expression (string or number) is stored into the arithmetic register X-REG (&FA00); if it is a string, &FA04 = &D0 (see note about arithmetic registers at the end)
  • ...
    SBR (&E0) - Raise the error using the value of register H; if H=&1A, the macro raises the ERROR 26
    SBR (&E2) - Exit to BASIC with the next address pointed by (DE); continue the execution if a BASIC program is currently running
    SBR (&E4) - Raise the ERROR 1; this is exactly LD H,&01 SBR (&E0)
  • ...
    SBR (&F2) - Clear the screen like the BASIC command CLS
  • SBR (&F4), mn - Load register HL with the value at address &mn; H = (&mn), L = (&mn+1)
  • SBR (&F4), mn - Save register HL to address &mn; (&mn) = H, (&mn+1) = L
  • ...
    SBR (&F8) - Maskable interrupt vector
    SBR (&FA) - Timer vector (used when blinking the cursor...)
    SBR (&FC) - Non-Maskable interrupt vector
    SBR (&FE) - RESET vector : This is the point where the CPU jumps at PowerON, but also when the RESET putton is pushed. This is the well known CALL &E000
Note: the 7 arithmetic registers X-REG, Z-REG, Y-REG, U-REG, V-REG, W-REG and S-REG located from &7A00 (X-REG) to &7A30 (S-REG) are used by the BASIC ROM to evaluate expressions and store multiple arguments. They differ from the BASIC variables X, Z, Y, U, V, W, S.
Dernière édition par cgh le 06 avr. 2021 12:48, édité 2 fois.
Il y a ceux qui voient les choses telles qu'elles sont et se demandent pourquoi, et il y a ceux qui imaginent les choses telles qu'elles pourraient être et se disent... pourquoi pas? - George Bernard Shaw
J'adore parler de rien, c'est le seul domaine où j'ai de vagues connaissances ! - Oscar Wilde
Ce n'est pas parce que les choses sont difficiles que nous n'osons pas. C'est parce que nous n'osons pas que les choses sont difficiles. - Sénèque

kuzja
Fonctionne à 75 bauds
Fonctionne à 75 bauds
Messages : 12
Inscription : 01 avr. 2021 14:26

Re: The macros of the SHARP PC1500

Message par kuzja » 06 avr. 2021 09:48

Thanks for the very useful and detailed description.
I'll give the macros a try and I'll come back if there are some more questions. :)

Avatar de l’utilisateur
Danny
Fonctionne à 1200 bauds
Fonctionne à 1200 bauds
Messages : 640
Inscription : 28 déc. 2013 17:34

Re: The macros of the SHARP PC1500

Message par Danny » 06 avr. 2021 12:25

Thanks cgh 8)
Do all these tricks work on a 1500A too ? :geek:
Casio fx-702P, 750P, 880p, 3900p, 7000G, 6000G, 6500G, 6800G, 8500G, 4500P, 9900GC, 9950GB +, Graph 100+ USB
HP 35, 45, 65, 21, 25, 67, 33E, 41C, 41CX, 20S, 42S, 28S, 32S, 32SII, 48SX, 48S, 48G, 48GX, 48G+, 50g, 35s, Prime
Sharp PC-1245, PC-1500A, PC-1430, PC-1262, EL-9000 | Tandy PC-7

cgh
Fonctionne à 2400 bauds
Fonctionne à 2400 bauds
Messages : 2277
Inscription : 30 août 2011 12:23
Localisation : Vous êtes ici -> .

Re: The macros of the SHARP PC1500

Message par cgh » 06 avr. 2021 12:35

Danny a écrit :
06 avr. 2021 12:25
Thanks cgh 8)
Do all these tricks work on a 1500A too ? :geek:
This works on all ROMs and on all models (1500,1500A, PC2...).
Il y a ceux qui voient les choses telles qu'elles sont et se demandent pourquoi, et il y a ceux qui imaginent les choses telles qu'elles pourraient être et se disent... pourquoi pas? - George Bernard Shaw
J'adore parler de rien, c'est le seul domaine où j'ai de vagues connaissances ! - Oscar Wilde
Ce n'est pas parce que les choses sont difficiles que nous n'osons pas. C'est parce que nous n'osons pas que les choses sont difficiles. - Sénèque

Répondre

Revenir vers « Silicium in english »