Register

Syscall problem

Discuss issues related to the fx-9860G Software Development Kit
Junior Member
Posts: 17
Joined: Sun May 27, 2012 4:38 pm
Location: Germany
Calculators: Casio fx-9860 GII

Syscall problem

Postby Canta » Sun May 27, 2012 5:10 pm

Hello
I would like to work with a syscall to generate a randomnumber (I think then I need this syscall). So I added the source file syscall.src :

Code: Select all
   .SECTION P,CODE,ALIGN=4

MACRO SYSCALL FUNO, SYSCALLNAME, TAIL=nop
   .export \SYSCALLNAME'
\SYSCALLNAME'
   mov.l #h'\FUNO, r0
   mov.l #H'80010070, r2
   jmp @r2
   \TAIL'
   .ENDM


   SYSCALL 003B,   _RTC_GetTicks
   .end



but when I tried to build it:

Code: Select all
syscall.src(1) : C2500 (E) Illegal token "."
syscall.src(4) : C2400 (E) Illegal character "\"
syscall.src(4) : C2401 (E) Incomplete character constant
syscall.src(5) : C2400 (E) Illegal character "\"
syscall.src(5) : C2401 (E) Incomplete character constant
syscall.src(6) : C2400 (E) Illegal character "#"
syscall.src(6) : C1005 (W) Undefined escape sequence
syscall.src(6) : C2401 (E) Incomplete character constant
syscall.src(7) : C2400 (E) Illegal character "#"
syscall.src(7) : C2401 (E) Incomplete character constant
syscall.src(8) : C2400 (E) Illegal character "@"
syscall.src(9) : C2400 (E) Illegal character "\"
syscall.src(9) : C2401 (E) Incomplete character constant


What did I do wrong?

Senior Member
User avatar
Posts: 603
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750 G II, Casio fx-9750 G II (SH4), Casio fx-9860G, Casio fx-9860 G SD, Casio fx-9860G Slim, Casio fx-9860 GII SD, Casio fx-9860 GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG 20, Casio Classpad fx-cp400, Casio fx-CG 50

Postby SimonLothar » Sun May 27, 2012 6:14 pm

replace
Code: Select all
MACRO SYSCALL FUNO, SYSCALLNAME, TAIL=nop

by
Code: Select all
       .MACRO SYSCALL FUNO, SYSCALLNAME, TAIL=nop


But this does not explain the error messages.
Do you use the CASIO SDK?
I'll be back!

Junior Member
Posts: 17
Joined: Sun May 27, 2012 4:38 pm
Location: Germany
Calculators: Casio fx-9860 GII

Postby Canta » Mon May 28, 2012 9:52 am

Do you use the CASIO SDK?
-Yes

my new code:
Code: Select all
   .SECTION P,CODE,ALIGN=4

.MACRO SYSCALL FUNO, SYSCALLNAME, TAIL=nop
   .export \SYSCALLNAME'
\SYSCALLNAME'
   mov.l #h'\FUNO, r0
   mov.l #H'80010070, r2
   jmp @r2
   \TAIL'
   .ENDM


   SYSCALL 003B,   _RTC_GetTicks
   .end

and my new errors:
Code: Select all
syscall.src(3) : 202 (E) ILLEGAL SYMBOL OR SECTION NAME
syscall.src(3) : 300 (E) ILLEGAL MNEMONIC
syscall.src(4) : 202 (E) ILLEGAL SYMBOL OR SECTION NAME
syscall.src(5) : 202 (E) ILLEGAL SYMBOL OR SECTION NAME
syscall.src(6) : 101 (E) SYNTAX ERROR IN SOURCE STATEMENT
syscall.src(9) : 300 (E) ILLEGAL MNEMONIC
syscall.src(10) : 616 (E) MACRO DIRECTIVES MISMATCH
syscall.src(13) : 300 (E) ILLEGAL MNEMONIC
syscall.src(13) : 876 (W) ASSEMBLER OUTPUTS BRA INSTRUCTION
  *****TOTAL ERRORS       8
  *****TOTAL WARNINGS     1


Should I write something in my main program to make it work?

Senior Member
User avatar
Posts: 603
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750 G II, Casio fx-9750 G II (SH4), Casio fx-9860G, Casio fx-9860 G SD, Casio fx-9860G Slim, Casio fx-9860 GII SD, Casio fx-9860 GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG 20, Casio Classpad fx-cp400, Casio fx-CG 50

Postby SimonLothar » Mon May 28, 2012 12:51 pm

Canta wrote:-Yes

my new code:
Code: Select all
   .SECTION P,CODE,ALIGN=4

.MACRO SYSCALL FUNO, SYSCALLNAME, TAIL=nop
   .export \SYSCALLNAME'
\SYSCALLNAME'
   mov.l #h'\FUNO, r0
   mov.l #H'80010070, r2
   jmp @r2
   \TAIL'
   .ENDM


   SYSCALL 003B,   _RTC_GetTicks
   .end

and my new errors:
Code: Select all
syscall.src(3) : 202 (E) ILLEGAL SYMBOL OR SECTION NAME
syscall.src(3) : 300 (E) ILLEGAL MNEMONIC
syscall.src(4) : 202 (E) ILLEGAL SYMBOL OR SECTION NAME
syscall.src(5) : 202 (E) ILLEGAL SYMBOL OR SECTION NAME
syscall.src(6) : 101 (E) SYNTAX ERROR IN SOURCE STATEMENT
syscall.src(9) : 300 (E) ILLEGAL MNEMONIC
syscall.src(10) : 616 (E) MACRO DIRECTIVES MISMATCH
syscall.src(13) : 300 (E) ILLEGAL MNEMONIC
syscall.src(13) : 876 (W) ASSEMBLER OUTPUTS BRA INSTRUCTION
  *****TOTAL ERRORS       8
  *****TOTAL WARNINGS     1


Should I write something in my main program to make it work?


No. First indent .MACRO... with one or more spaces or a tab.
I'll be back!

Junior Member
Posts: 17
Joined: Sun May 27, 2012 4:38 pm
Location: Germany
Calculators: Casio fx-9860 GII

Postby Canta » Mon May 28, 2012 3:30 pm

Great! Now it builds without an error.:) Even I don't understand why...

Can you please tell me now how do I get the random number in my main program?

Senior Member
User avatar
Posts: 603
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750 G II, Casio fx-9750 G II (SH4), Casio fx-9860G, Casio fx-9860 G SD, Casio fx-9860G Slim, Casio fx-9860 GII SD, Casio fx-9860 GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG 20, Casio Classpad fx-cp400, Casio fx-CG 50

Postby SimonLothar » Mon May 28, 2012 3:42 pm

Canta wrote:Great! Now it builds without an error.:) Even I don't understand why...

Because of the missing indentation. That are the assembler's syntax rules for directives.

Canta wrote:Can you please tell me now how do I get the random number in my main program?

use
srand( RTC_Ticks() )
to initialize the random-generator (once at the beginning of your program)

use
rand()
to get a random-number throughout your program

the interfaces of both functions are in stdlib.h (hence include it)
I'll be back!

Junior Member
Posts: 17
Joined: Sun May 27, 2012 4:38 pm
Location: Germany
Calculators: Casio fx-9860 GII

Postby Canta » Mon May 28, 2012 5:18 pm

Something is still wrong. This code builds, but displays first always 1 :

Code: Select all
#include "fxlib.h"
#include "stdlib.h"
#include "stdio.h"


int AddIn_main(int isAppli, unsigned short OptionNum)
{

unsigned int x;
char buffer[3];
unsigned int RTC_GetTicks();
Bdisp_AllClr_DDVRAM();

x = rand() % 10 + 1;

sprintf(buffer,"%d",x);
PrintMini(10,10,(unsigned char*)buffer,MINI_OVER);
  Bdisp_PutDisp_DD();
 Sleep(500);

return 1;
}


#pragma section _BR_Size
unsigned long BR_Size;
#pragma section


#pragma section _TOP

int InitializeSystem(int isAppli, unsigned short OptionNum)
{
    return INIT_ADDIN_APPLICATION(isAppli, OptionNum);
}

#pragma section

Senior Member
User avatar
Posts: 603
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750 G II, Casio fx-9750 G II (SH4), Casio fx-9860G, Casio fx-9860 G SD, Casio fx-9860G Slim, Casio fx-9860 GII SD, Casio fx-9860 GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG 20, Casio Classpad fx-cp400, Casio fx-CG 50

Postby SimonLothar » Mon May 28, 2012 7:11 pm

Call
Code: Select all
  srand( RTC_GetTicks() );

at the beginning of the program.
I'll be back!

Junior Member
Posts: 17
Joined: Sun May 27, 2012 4:38 pm
Location: Germany
Calculators: Casio fx-9860 GII

Postby Canta » Tue May 29, 2012 8:56 am

Thanks. Now it works.:o

Return to Casio fx-9860 SDK

Who is online

Users browsing this forum: No registered users and 8 guests