Register

Hitachi compiler options

Discuss issues related to the fx-9860G Software Development Kit
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

Re: Hitachi compiler options

Postby SimonLothar » Sat Apr 29, 2017 9:33 am

cakeisalie5 wrote:...Is there a way I could do this using Hitachi's compiler/assembler?
The SDK option "#pragma inline_asm" seems to be not very usable.
Here are some macros, which could come in handy.
CODE: Show
Code: Select all
#define SCA 0xD201D002
#define SCB 0x422B0009
// fx-CG
#define SCE 0x80020070
// fx-9860
// #define SCE 0x80010070
#define SYSCALL_BASE( FUNC_NAME, FUNC_NO ) const unsigned int asm##FUNC_NAME[] = { SCA, SCB, SCE, FUNC_NO };
#define SYSCALL_FUNC( FUNC_NAME ) { return (*(int(*)())asm##FUNC_NAME)();};

// this macros support some basic interfaces
#define SYSCALL0( FUNC_NAME, FUNC_NO ) SYSCALL_BASE( FUNC_NAME, FUNC_NO ) int FUNC_NAME() SYSCALL_FUNC( FUNC_NAME )
#define SYSCALL1( FUNC_NAME, FUNC_NO ) SYSCALL_BASE( FUNC_NAME, FUNC_NO ) int FUNC_NAME(int) SYSCALL_FUNC( FUNC_NAME )
#define SYSCALL2( FUNC_NAME, FUNC_NO ) SYSCALL_BASE( FUNC_NAME, FUNC_NO ) int FUNC_NAME(int,int) SYSCALL_FUNC( FUNC_NAME )
#define SYSCALL3( FUNC_NAME, FUNC_NO ) SYSCALL_BASE( FUNC_NAME, FUNC_NO ) int FUNC_NAME(int,int,int) SYSCALL_FUNC( FUNC_NAME )
#define SYSCALL4( FUNC_NAME, FUNC_NO ) SYSCALL_BASE( FUNC_NAME, FUNC_NO ) int FUNC_NAME(int,int,int,int) SYSCALL_FUNC( FUNC_NAME )
#define SYSCALL5( FUNC_NAME, FUNC_NO ) SYSCALL_BASE( FUNC_NAME, FUNC_NO ) int FUNC_NAME(int,int,int,int,int) SYSCALL_FUNC( FUNC_NAME )

// fx-CG
#define RTC_GetTicks_NO 0x02C1
// fx-9860
//#define RTC_GetTicks_NO 0x003B

SYSCALL_BASE( RTC_GetTicks, RTC_GetTicks_NO );
int bRTC_GetTicks(){ return (*(int(*)())asmRTC_GetTicks)();};

SYSCALL0( RTC_GetTicks0, RTC_GetTicks_NO );
// RTC_GetTicks does not need parameters. This only serves to demonstrate a five-parameter call.
SYSCALL5( RTC_GetTicks5, RTC_GetTicks_NO );

int SyscallTest(){
int result;
   result = bRTC_GetTicks();
   result = RTC_GetTicks0();
   result = (*(int(*)())asmRTC_GetTicks)();
   return RTC_GetTicks5(1,2,3,4,(int)"5");
}
I'll be back!

Senior Member
User avatar
Posts: 101
Joined: Sun Mar 27, 2016 10:24 am
Location: France
Calculators: Casio Afx 1.0, Casio fx-9860GII, Casio fx-CG50

Re: Hitachi compiler options

Postby cakeisalie5 » Sat Apr 29, 2017 10:28 am

Hm, I'm not a great fan of this method... '-'
Isn't there a way to make macros in .src files?

Also (stop me if I'm too quick with questions), did you find out the roles of the different sections (P_TOP, P, C, D, B_BR_Size, B, R), and/or their GNU equivalents (such as .text, .data, etc)?
And do you know how the `pak` files are encoded, and if they contain anything interesting? (it looks like they're used by `lbgsh.exe`, but I still haven't understood the role of this utility)
Part of the Planète Casio community (FR) - main author of Cahute

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

Re: Hitachi compiler options

Postby SimonLothar » Sat Apr 29, 2017 1:00 pm

cakeisalie5 wrote:Isn't there a way to make macros in .src files?
Sure there is. I use an assembler macro myself for my syscall libraries. I wanted to show the pure C-variant first.
syscall template: Show
Code: Select all
   .MACRO SYSCALL FUNO, TAIL=nop
   mov.l \FUNO', r0
   mov.l #h'80010070, r2
   jmp @r2
   \TAIL'
   .ENDM

   .export _StrToBCD

   .SECTION P,CODE,ALIGN=4
_StrToBCD:
   SYSCALL #h'059E

   .END
I'll be back!

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

Re: Hitachi compiler options

Postby SimonLothar » Sat Apr 29, 2017 2:56 pm

cakeisalie5 wrote:...did you find out the roles of the different sections (P_TOP, P, C, D, B_BR_Size, B, R)
These things are discussed starting at page 160 of the SHC Manual (SuperH RISC engine
C/C++ Compiler Assembler Optimizing Linkage Editor). The linker option "start" is used to give the relocatable sections the proper position in the final binary file. The section names are of some importance during this phase.
F. i.
-start P_TOP,P,C,D,C$VTBL,C$INIT/00300000,B_BR_Size,B,R/08100000
C$VTBL,C$INIT are important for C++ classes.
I'll be back!

Previous

Return to Casio fx-9860 SDK

Who is online

Users browsing this forum: No registered users and 15 guests