Register

Add functions to Basic Casio programs

Topics on released projects. Only the author of a program should start a topic on it.
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

Postby helder7 » Wed May 30, 2012 5:42 pm

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

Member
User avatar
Posts: 33
Joined: Sat Apr 07, 2012 10:08 am
Location: France

Postby Purobaz » Wed May 30, 2012 9:29 pm

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).

Junior Member
Posts: 2
Joined: Tue May 08, 2012 1:16 am

Postby gjk00 » Thu May 31, 2012 9:21 am

On OS 2.xx, can i put an code to 0x220000 -- 0x24FE00?
This area seems free in OS image file.

Junior Member
Posts: 2
Joined: Tue May 08, 2012 1:16 am

Postby gjk00 » Thu May 31, 2012 9:26 am

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

Senior Member
User avatar
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

Postby SimonLothar » Thu May 31, 2012 2:42 pm

Purobaz wrote:...just a small system error
What error? This is possibly important to be solved, before proceeding.

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!

Member
User avatar
Posts: 33
Joined: Sat Apr 07, 2012 10:08 am
Location: France

Postby Purobaz » Thu May 31, 2012 5:13 pm

What error? This is possibly important to solve, before proceeding.

System ERROR
REBOOT:[EXIT]
INITIALIZE:[EXE]
ADDRESS(W)
TARGET=880239F7
PC=88023DC8

Because there is not code yet.


Thanks for all your informations. I try to perform the next step.

Member
User avatar
Posts: 23
Joined: Fri Apr 20, 2012 6:13 am

Postby Eiyeron » Thu May 31, 2012 7:28 pm

Good Luck, Puro! ;)
ImageImageImage
ImageImage

Member
User avatar
Posts: 33
Joined: Sat Apr 07, 2012 10:08 am
Location: France

Postby Purobaz » Fri Jun 01, 2012 11:39 pm

On Windows I have an error when I execute SHCPP with the PRGM0CB0.hmk :
- expected a declaration line 1
- parsing restart after previous syntax error at the end

Do you have any idea ?

Senior Member
User avatar
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

Postby SimonLothar » Sat Jun 02, 2012 5:10 am

The lines

"SHCPP" -subcommand=<<
"OPTLNK" -subcommand=<<
"ASMSH" -subcommand=<<

have to be indented with a TAB (I corrected the original post, too).
I'll be back!

Member
User avatar
Posts: 33
Joined: Sat Apr 07, 2012 10:08 am
Location: France

Postby Purobaz » Wed Jun 06, 2012 5:55 pm

So, I have done several tests today but I can't create CLIB.obj
Each time it says : expected a declaration on line 1.

I think it's because I don't use the .hmk correctly.
Is there a special way to use it ? Can I did it on Windows ?

Thanks for your help.

PreviousNext

Return to Released Projects

Who is online

Users browsing this forum: No registered users and 1 guest