SuperH-based fx calculators
fx legacy: PRGM

0x0CA7: char OpcodeType( char**program );
Returns an opcode's type:
1:
2: regular expression, which is calculated via syscall 0x0645

 
0x0CB0: int PRGM_Send( char**program, short*opcode, TBCDvalue result[2] );

Called, when the PRGM-commands Send( or Send38k are invoked.
*opcode is either 0xF711(Send) or 0xF715(Send38k).
**program is the opcode-list, beginning with the value of *opcode. It allows to inspect the passed arguments.
*result receives a result or an error code.
returns 1, if no error occured.

0x0CB1: int PRGM_Receive( char**program, short*opcode, TBCDvalue result[2] );

Called, when the PRGM-commands Receive( or Receive38k are invoked.
*opcode is either 0xF712(Receive) or 0xF716(Receive38k).
For details, see 0x0CB0.

0x0CB2: int PRGM_OpenCloseComPort38k( char**program, short*opcode, TBCDvalue result[2] );

Called, when the PRGM-commands OpenComPort38k or CloseComPort38k are invoked.
*opcode is either 0xF713(Open) or 0xF714(Close).
For details, see 0x0CB0.

PRGM/SDK-interface

Syscalls 0x0CB0..0x0CB2 can be used to redirect the PRGM-commands Send(, Send38k, Receive(, Receive38K, OpenComPort38k and CloseComPort38k (OS-mod). These commands seem to be without much value as such.
They replacement-code has to follow some rules.
It has to process its arguments and increment the actual program-pointer accordingly.
In case of the PRGM-serial-opcode-handler, the program-pointer has to be incremented, until one of the EndOfLine-opcodes or the end of the program occurs.
Fortunatly this can be done by two syscalls 0x0652/PRGM_NextOpcode and 0x06A6/PRGM_IsEndOfLine (see below).
Hence a handler has to call 0x0652 until 0x06A6 returns 1.

The handler has to return 1, if no error occured.
If the replacement code has to report an error to PRGM, it has to return 0 and set the first two bytes of result[0] accordingly.
Some errorcodes are
0xF002: Syntax ERROR
0xF003: Ma ERROR

Important! If the first two bytes of result[0] remain zero and zero is returned by the function to signal an error, the calc crashs.

As the replacement code is responsíble to interpret the passed arguments, nearly any kind of argument can be passed.
PRGM does not heed for the arguments following Send(. They can be any combination of bytes. There is nothing predefined.
PRGM simply expects the actual program-pointer to point to an EndOfLine-code to proceed with.
F. i.:
Send("Hello world!", MYVAR ) could possibly store the string "Hello world!" into a variable named MYVAR.
More flexible would be
Send( 123, ... ). T. i. call a sub-function 123 with whatever arguments.

0x0652: void PRGM_NextOpcode( char opcode[2], char**program );

This call examines opcode[0] first. If the byte is zero, the procedure quits.
Else it copies **program to opcode[0]. If the byte is zero, the procedure quits.
Else it examines the new opcode[0] to be a MB_Lead-code. If not, the actual program-pointer *program is incremented by one and the procedure quits.
If it is a MB_Lead-code, the actual program-pointer *program is incremented by one, the **program is copied to opcode[1], the actual program-pointer *program is incremented again and the procedure quits.

0x06A6: int PRGM_IsEndOfLine( char*opcode );

If *opcode is 0x3A(:), 0x0D, 0x0C or 0x00, the function returns 1.
Else it returns 0.

(28.05.2012 05:58:52)