Do you know any other assembly language? In my opinion SH assembly is one of the easy ones.
Do you have the Renesas SH3 documents?
I know a little about 8086 ASM and I don't have the documents.
For example where does it start, how big is it, are there separate memories and memory parts or just one? Where is RAM_SIZE initialized in your code? I couldn't find it
FVM programs has a 16-byte header, see src/fvm/fvm.h( lines 44-55 ).
RAM_SIZE initialized in fvm.c line 133
there are 2 parts memories:
One is BC, the address of bytecode.Another is RAM, store variable, temp variable, calling sequence.
As for the heap, I just use malloc() simply...
Wudy, in your preprocessor, WSC\prepro.c line 108, i thought the correct word is "pragma", not "progma" !
Oh...i am wrong! Thanks for correcting.
There are some unused variables in your code also, e.g in fvm.h:
Line 22: extern const char *codeToStr[];
Line 229: #define CAST_INT(a) (*(int *)(a))
Line 230: #define CAST_FLOAT(a) (*(float *)(a))
What's the use of these?
Line 22: extern const char *codeToStr[];
It's for debugging.There is a version for Windows, I use it for debugging. When I ported FVM to fx-9860, i deleted it.
Line 229: #define CAST_INT(a) (*(int *)(a))
Line 230: #define CAST_FLOAT(a) (*(float *)(a))
I use CAST_INT(RAM+6) to tanslate 4 bytes begin with RAM+6 to integer.
For example, the RAM is
0x12 0x5A 0xC5 0x4A 0x00 0x00 0x30 0x01 0x00 0xAC
CAST_INT(RAM+6) equal to 0x300100AC
but when I ported FVM to fx-9860, I found it did not work. because fx-9860 must read from aligned memory locations.( i.e. RAM + 4, RAM + 8, RAM + 12.. )
So I must use memcpy( RAM+6, &temp, sizeof(int) ); instead.
Edited by Wudy, 26 July 2012 - 01:47 PM.