G1M Format - MCS - Lists and BCD
3 posts
• Page 1 of 1
- cakeisalie5
- Senior Member
-
- Posts: 102
- Joined: Sun Mar 27, 2016 10:24 am
- Location: France
- Calculators: Casio Afx 1.0, Casio fx-9860GII, Casio fx-CG50
G1M Format - MCS - Lists and BCD
Hi! I have a problem with lists in the G1M format, but as lists are not described in Simon Lothar's documentation, I'll first describe what I know here, so that you correct me if I'm wrong.
So after the MCS header and the MCS file header, then there is a List Header that is the following :
- 8 bytes: probably the title
- 2 bytes: element count (big endian)
- 5 bytes: unknown (align?)
- 1 byte: unknown (but looks like it takes fixed values)
After that, we have the real parts list and, if there is at least one number with an imaginary part, the imaginary parts list. To detect if there is this imaginary parts list, I use the datalength field in the MCS file header and make a check on "is it long enough to contain more than a list header and a real parts list?". If you have a cleaner way of checking this, I'd like it.
So first of all, if I got any of this wrong, or if you know what the unknown bytes mean, please correct me.
Secondly, this method has worked pretty well, until I tried to parse BCD numbers. It works for the list of real-only numbers:
But for a test list with complex, it gets wierder. LIST2 has "5+2i" and "124", and here is the thing, with BCD value (and alignment bytes, in case) logging:
Why does it have 0xD and 0xF values? It thought it would be zero'd, but it isn't, so am I supposed to only read it if valid? If this is the case, how can I know this?
You can grab the source code here ^^
So after the MCS header and the MCS file header, then there is a List Header that is the following :
- 8 bytes: probably the title
- 2 bytes: element count (big endian)
- 5 bytes: unknown (align?)
- 1 byte: unknown (but looks like it takes fixed values)
After that, we have the real parts list and, if there is at least one number with an imaginary part, the imaginary parts list. To detect if there is this imaginary parts list, I use the datalength field in the MCS file header and make a check on "is it long enough to contain more than a list header and a real parts list?". If you have a cleaner way of checking this, I'd like it.
So first of all, if I got any of this wrong, or if you know what the unknown bytes mean, please correct me.
Secondly, this method has worked pretty well, until I tried to parse BCD numbers. It works for the list of real-only numbers:
LIST1: Show
But for a test list with complex, it gets wierder. LIST2 has "5+2i" and "124", and here is the thing, with BCD value (and alignment bytes, in case) logging:
LIST2: Show
Why does it have 0xD and 0xF values? It thought it would be zero'd, but it isn't, so am I supposed to only read it if valid? If this is the case, how can I know this?
You can grab the source code here ^^
Part of the Planète Casio community (FR) - main author of Cahute
- SimonLothar
- Senior Member
-
- 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: G1M Format - MCS - Lists and BCD
If at least one cell of a "LIST n" contains a number with an imaginary part, the BCD-list of real numbers of this "LIST n" is followed by a BCD-list of imaginary numbers of the same count.
It looks as if an imaginary number can be detected by the leftmost bit of the exponent.
F. i.
90 05 00 00 00 00 00 00 00 00 00 00 (5 with some imaginary part)
10 05 00 00 00 00 00 00 00 00 00 00 (5 without imaginary part)
E0 05 00 00 00 00 00 00 00 00 00 00 (-5 with some imaginary part)
60 05 00 00 00 00 00 00 00 00 00 00 (-5 without imaginary part)
T. i., if there is at least one number with an imaginary part, the length of the complete BCD-list is double the size.
In the BCD-list of imaginary parts only these entries are significant, which correspond to an entry in the real part BCD-list, which is designated to have an imaginary part (leftmost bit of the exponent set).
The other entries of the imaginary part BCD-list
f. i. 80 04 2D 78 FF FF FF FF 80 16 39 98
seem to be meaningless. It looks as if they grab some RAM from heap or stack to build the imaginary part BCD-list and only initialize the significant entries, leaving the meaningless parts untouched (f. i. some previously used values on stack or heap, which look to be random).
It looks as if an imaginary number can be detected by the leftmost bit of the exponent.
F. i.
90 05 00 00 00 00 00 00 00 00 00 00 (5 with some imaginary part)
10 05 00 00 00 00 00 00 00 00 00 00 (5 without imaginary part)
E0 05 00 00 00 00 00 00 00 00 00 00 (-5 with some imaginary part)
60 05 00 00 00 00 00 00 00 00 00 00 (-5 without imaginary part)
T. i., if there is at least one number with an imaginary part, the length of the complete BCD-list is double the size.
In the BCD-list of imaginary parts only these entries are significant, which correspond to an entry in the real part BCD-list, which is designated to have an imaginary part (leftmost bit of the exponent set).
The other entries of the imaginary part BCD-list
f. i. 80 04 2D 78 FF FF FF FF 80 16 39 98
seem to be meaningless. It looks as if they grab some RAM from heap or stack to build the imaginary part BCD-list and only initialize the significant entries, leaving the meaningless parts untouched (f. i. some previously used values on stack or heap, which look to be random).
I'll be back!
- cakeisalie5
- Senior Member
-
- Posts: 102
- Joined: Sun Mar 27, 2016 10:24 am
- Location: France
- Calculators: Casio Afx 1.0, Casio fx-9860GII, Casio fx-CG50
Re: G1M Format - MCS - Lists and BCD
Works great ! Thanks a lot 

Part of the Planète Casio community (FR) - main author of Cahute
3 posts
• Page 1 of 1
Return to Calculator Hacking/Modding Discussions
Who is online
Users browsing this forum: No registered users and 8 guests