Here is a very simple ARM assembly source.
When I build it and EVAL I get : Error Undefined FPTR Name
Why ?
" !RPL
CODE
SAVE
!ARM
STMDB sp! {R4 R5 R6 R7 R8 LP}
LDMIA sp! {R4 R5 R6 R7 R8 PC}
!ASM
LOADRPL
ENDCODE
;
@"
(03-31-2017 08:30 AM)sunhp Wrote: [ -> ]Here is a very simple ARM assembly source.
When I build it and EVAL I get : Error Undefined FPTR Name
Why ?
"!RPL
CODE
SAVE
!ARM
STMDB sp! {R4 R5 R6 R7 R8 LP}
LDMIA sp! {R4 R5 R6 R7 R8 PC}
!ASM
LOADRPL
ENDCODE
;
@"
Not so simple. You can't embed ARM code in Saturn assembler and expect the emulated CPU to switch modes automatically. You have to tell it to execute the ARM code with the ARMSYS and ARMSAT instructions. Also, ARM code must be word-aligned (word=32 bits in this context), therefore you can't simply embed it, it needs to be copied in memory to an aligned position, then executed.
In other words you need a "launcher" like
the one discussed here.
You could also install the ARM Toolbox from hpcalc.org and create a string, also as explained on the same old post. The Toolbox will align and launch the code for you, but the small launcher discussed there will do the job well with a lot less overhead for small programs.
You could also create self-modifying code. Pad in some nibbles (of value 0) in front of and behind the ARM code. During compile time, calculate the offset of the start of the SATURN code to the ARM code (and embed it into the SATURN code; the offset should include the width of the offset itself). Use this offset during runtime to determine whether you need to move the ARM block a few nibbles so that it is byte aligned. If you do move it, adjust the offset for future runs. Then do a jump to the start of the ARM code after moving the ARM code within the SATURN code.
Thank you guys for your clear explanations !