07-27-2021, 08:57 PM
Has any work been done on determining the internal object format that the Prime uses? I started poking around for fun, but I thought I'd check to make sure I wasn't wasting my time on something that has already been solved.
struct THPObj {
uint16_t reference_count;
// definition of flag bits varies with type,
// but the least significant bit indicates a heap allocated object
uint8_t flags:4;
ObjTag tag:4; // Indicates the type of this object
};
enum ObjTag {
TAG_REAL = 0,
TAG_INT = 1,
TAG_STRING = 2,
TAG_COMPLEX = 3,
TAG_MATRIX = 4,
TAG_ERROR = 5,
TAG_LIST = 6,
TAG_IDENT = 7,
TAG_FUNC_CALL = 8,
TAG_UNIT = 9,
TAG_INSTRUCTION_SEQUENCE = 10, // Just a list with special semantics
TAG_USERFUNC = 11,
TAG_LIST_PROCESSOR = 12,
TAG_EVALUATOR_REQUEST = 13,
TAG_GEN = 14 // Wrapper around a giac::gen object
struct Real: public THPObj{
int8_t sign_stuff;
int32_t exponent;
uint64_t mantissa; // Packed BCD
};
struct Integer: public THPObj {
int8_t num bits; // rage of [-64,64]. Negative values indicated a signed value
uint8_t padding[4];
uint64_t data;
};
struct String: public THPObj {
uint8_t padding;
TSize num_chars;
TChar data[];
};
struct FunctionCall: public THPObj {
uint8_t param_count;
uint8_t padding[4]; // Probably only on 64-bit, but haven't verified.
THPObj* unknown_obj;
void* definition; // pointer to some kind of data structure which describes the function.
THPObj* params[];
};
(08-02-2021 05:15 PM)jfelten Wrote: [ -> ]where did you get this information?
(08-02-2021 10:43 PM)rprosperi Wrote: [ -> ]So, while I'd never (ever!) suggest you should not explore and document this stuff, I can say you should not be surprised if the current details and access methods change as a result.
(08-04-2021 06:45 PM)devin122 Wrote: [ -> ](08-02-2021 05:15 PM)jfelten Wrote: [ -> ]where did you get this information?
Most of it was obtained by reverse engineering the firmware / using AFiles() to save and reload objects. A couple of the more obscure tag values I got from Cyrilles HPCC presentation
(08-04-2021 06:45 PM)devin122 Wrote: [ -> ](08-02-2021 10:43 PM)rprosperi Wrote: [ -> ]So, while I'd never (ever!) suggest you should not explore and document this stuff, I can say you should not be surprised if the current details and access methods change as a result.
I have very much been keeping that in mind, as I would hate to see more restrictions put on the calculator. In fact, I have picked up some details about exam mode which I have no intention of sharing for the reason that it would really not serve any purpose other than defeating the exam mode. This info however I felt might be interesting to some people, and the risk of abuse seems relatively low. Plus, in order to use this info for nefarious purposes would require a level of skill which means you could figure it out on your own.
(08-04-2021 06:45 PM)devin122 Wrote: [ -> ]I have very much been keeping that in mind, as I would hate to see more restrictions put on the calculator. In fact, I have picked up some details about exam mode which I have no intention of sharing for the reason that it would really not serve any purpose other than defeating the exam mode. This info however I felt might be interesting to some people, and the risk of abuse seems relatively low. Plus, in order to use this info for nefarious purposes would require a level of skill which means you could figure it out on your own.