Quote Originally Posted by dmantione
Assuming the GBA bios does not destroy registers other than input and output, you should check if the compiler has data stored in r1 before it calls fpc_mod_longint, since r1 is destroyed by your implementation of fpc_mod_longint.
Uhm... well, according wiht your suggestions I have tryied to save r1 value:

[pascal]
mov r8, r1
swi #0x060000
mov r0, r1
mov r1, r8
[/pascal]

I don't really know if this is a suitable way to save and restore r1 value, however it does not work at all

Looking at this doc I have tryied to tell to fpc compiler which register is affected by fpc_mod_longint function:
[pascal]
function fpc_mod_longint(n,z: longint):longint; compilerproc; assembler; [public, alias: 'FPC_MOD_LONGINT'];
asm
swi #0x060000
mov r0, r1
end['r0','r1','r2','r3'];
[/pascal]

or even

[pascal]
function fpc_mod_longint(n,z: longint):longint; compilerproc; [public, alias: 'FPC_MOD_LONGINT'];
begin
asm
swi #0x060000
mov r0, r1
end;
end;
[/pascal]

...but no way. What a headache!! :fuzzy: