Add functions to Basic Casio programs
44 posts
• Page 4 of 5 • 1, 2, 3, 4, 5
- helder7
- Senior Member
- Posts: 369
- Joined: Tue Jan 03, 2012 11:24 pm
- Calculators: Casio Afx 1.0, Casio fx-9860GII SD, Casio Classpad 330, Casio fx-CG20, Casio Classpad fx-CP400
Eiyeron wrote:It's a it uninimaginable... Os Modding... Never saw something like this?
there are other OS Modding discussion here: http://www.casio-scene.com/showthread.php?1085 (2008)
SiO2 + CaCO3 ----------> CaSiO3 + CO2
On fx9860-OSes 2.xx it is the sum of the bytes in the OS address-range 0x80010000 to 0x8024FFF7.
It is stored as int at 0x8024FFF8
EDIT
F. i. on-calc it could look like that:
Code:
result = 0;
for ( address = 0x80010000; address <= 0x8024FFF7; address++ ) result += *(unsigned char*)address;
So you need a program that simply adds the bytes in the fileoffset-range 0x00010000 to 0x0024FFF7 into an int-variable.
Then the program has to write the sum to fileoffset 0x0024FFF8.
Thanks a lot.
I adjusted the checksum, replaced the OS to my calculator and it works fine.
The calculator didn't request any OS update, just a small system error

Now, can you help me with the HMAKE-files to to assembled and linked the code (I have already programmed the code I want to inject).
- SimonLothar
- Senior Member
-
- Posts: 605
- Joined: Sat Sep 15, 2012 6:59 am
- Location: Krautland ****
- Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400
What error? This is possibly important to be solved, before proceeding.Purobaz wrote:...just a small system error
Purobaz wrote:Now, can you help me with the HMAKE-files to to assembled and linked the code (I have already programmed the code I want to inject).
OK. I usually prefer small steps, if it comes to solve difficult problems, but here is the whole bunch for a start.
Sorry, if it seems to be overwhelming.
There is no doubt, that depending on different work environments, this scheme may not work at once and will lead to some complaints. But usually such inconveniences can be mended by minor adjustments. Do not despair. Simply ask instead.
You need a replacement function. You could write it in assembler, but more convenient is C/C++, of course. I prefer SHCPP because it issues a lot more warnings than SHC and so helps to prevent some avoidable errors. Lets call the source module CLIB.CPP.
The interface must be
- Code: Select all
int CLIB_entry( char**program, short*opcode, TBCDvalue result[2] );
In the old documentation, the parameters program and opcode have been arranged in the wrong order! Sorry for that.
Here is the minimum frame for this function. It has to process the opcodes until an EndOfLine has been encountered, before returnning control to PRGM! Two syscalls are needed for that. What you do around this absolutely necessary frame is up to you. Return 1 if you want to report success. Return 0 if you want to report failure. In case of failure, you have to provide for some error information in TBCDvalue result[2]. If you do not provide for error information, the calc will crash!
- Code: Select all
// instant syscalls (fx-9860)
#define SCA 0xD201D002
#define SCB 0x422B0009
#define SCE 0x80010070
typedef void(*sc_vv)(void);
typedef int(*sc_iv)(void);
const unsigned int iPRGM_NextOpcode[] = { SCA, SCB, SCE, 0x0652 };
const unsigned int iPRGM_IsEndOfLine[] = { SCA, SCB, SCE, 0x06A6 };
//
void PRGM_NextOpcode( short*opcode, char**program ){
(*(sc_vv)iPRGM_NextOpcode)();
}
//
int PRGM_IsEndOfLine( short*opcode ){
return (*(sc_iv)iPRGM_IsEndOfLine)();
}
// instant syscalls end
typedef char TBCDvalue[12];
//
int CLIB_entry( char**program, short*opcode, TBCDvalue result[2] ){
int iresult = 1;
while( 1 ){
PRGM_NextOpcode( opcode, program );
if ( PRGM_IsEndOfLine( opcode ) == 1 ) break;
// this is the part, where the parameters could be analyzed
}
// this is the part, where the repalcement-code will be placed
return iresult;
}
Now the makefile PRGM0CB0.hmk:
- Code: Select all
!MESSAGE
!MESSAGE Executing Hitachi SHCPP phase
!MESSAGE
CPROG=CLIB
"$(CPROG).obj" : $(CPROG).cpp
"SHCPP" -subcommand=<<
$(CPROG).cpp
-I=...
-OB=$(CPROG).OBJ
-L=$(CPROG).LST
-CPU=sh3
-show=source
-size
-noinline
-chgincpath
-errorpath
-nodebug
-nomessage
<<
The SHCPP-option -I= must be set to the comma-separated list of INCLUDE-directories, if needed.
The machine's path must contain the directory, where the CASIO SDK-binaries reside: usually ...\CASIO\fx-9860G SDK\OS\SH\BIN
The compiler needs the following environment variables:
SET SHC_LIB=usually ...\CASIO\fx-9860G SDK\OS\SH\BIN
SET SHC_TMP=some directory, where the user has write-rights (with CASIO SDK it is the directory called "..\debug")
Then a main assembler frame is required to ensure, that the entry of your replacement code will be at the top of the resulting binary. It could look like this (f. i. PRGM0CB0.ASM). CLIB_entry is the function in your CLIB.obj, which must be called, when the redirected syscall is invoked:
- Code: Select all
.import _CLIB_entry
.SECTION P_TOP,CODE,ALIGN=4
entry:
bra _CLIB_entry
nop
.END
The following makefile will assemble the main frame:
- Code: Select all
!MESSAGE
!MESSAGE Executing Hitachi ASMSH phase
!MESSAGE
PROG=PRGM0CB0
"$(PROG).obj" : $(PROG).asm
"ASMSH" -subcommand=<<
$(PROG).asm
-LIST=$(PROG).LST
-CPU=sh3
-endian=big
-round=zero
-denormalize=off
-debug
-literal=pool,branch,jump,return
-nologo
-chgincpath
-errorpath
<<
Finally PRGM0CB0.obj and CLIB.OBJ has to be linked together to give the resulting binary.
- Code: Select all
!MESSAGE
!MESSAGE Executing Hitachi OPTLNK phase
!MESSAGE
PROG=PRGM0CB0
CPROG=CLIB
"$(PROG).bin" : $(PROG).OBJ $(CPROG).obj
"OPTLNK" -subcommand=<<
noprelink
nomessage
list "$(PROG).map"
show symbol
nooptimize
start P_TOP,P,C,D/88070000
fsymbol P
nologo
input $(PROG).obj
input $(CPROG).obj
input setup.obj
output "$(PROG).abs"
-nomessage=1100
end
input "$(PROG).abs"
form binary
output "$(PROG).BIN"
exit
<<
setup.obj can be found in the CASIO SDK directory ...\CASIO\fx-9860G SDK\OS\FX\lib.
Depending on the complexity of CLIB.CPP, additional input- and/or library-declarations possibly must be included.
Before transferring the binary to the calculator the file PRGM0CB0.MAP should be inspected to ensure, that the entry is at 0x88070000. Maybe CLIB.LST and PRGM0CB0.LST should be inspected, too.
I'll be back!
- SimonLothar
- Senior Member
-
- Posts: 605
- Joined: Sat Sep 15, 2012 6:59 am
- Location: Krautland ****
- Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400
The lines
"SHCPP" -subcommand=<<
"OPTLNK" -subcommand=<<
"ASMSH" -subcommand=<<
have to be indented with a TAB (I corrected the original post, too).
"SHCPP" -subcommand=<<
"OPTLNK" -subcommand=<<
"ASMSH" -subcommand=<<
have to be indented with a TAB (I corrected the original post, too).
I'll be back!
44 posts
• Page 4 of 5 • 1, 2, 3, 4, 5
Who is online
Users browsing this forum: No registered users and 12 guests