EEC V file conversion

All hardware related, disassembly / programming and code discussions belong here.
wwhite
Posts: 401
Joined: 2021 Feb 16, 15:53
Location: Victoria, BC, Canada
Vehicle Information: 1994 Flarside, XLT, 351w E4OD
SD48b, Quarter Horse, Burn2

Re: EEC V file conversion

Unread post by wwhite »

tvrfan wrote: 2024 Dec 11, 15:58 PIVOT TABLES ?? My other half thinks they are a total waste of time, and reckons everything you can do in a pivot table can be done with more straightforward (and easier?) cell logic formulae like IF-THEN-ELSE and collection filters and sometimes adding a 'type' column to filter with. She has a strong background in finance, so I believe her (I have never done much in excel myself, so I'm just passing this on...).
So, in my mind(which only I can read), I'll try to explain.

I still think this should be another topic, maybe I'll start that soon, I have a couple weeks off work coming up.

Database Design:
We have known calibration constants, variables, functions and tables with known descriptions(strategy docs).
We have known hardware, strategies and calibrations.

This could be the start of base tables in database:
- CalibrationConstants, RAMVariables, FoxFunctions.
- HardwareCode, StrategyCode

So, my idea of a pivot table would be where a HardwareCode_Strategy(hardwarecode_id, strategycode_id);
Its basically a many to many pivot table.

Code: Select all

HardwareCode(id, code)
1, SD47
2, SD48
3, ML1441

CalibrationCode(id, code)
1, KID
2, HEN
3, JOG
4, LAW

CalibrationCode_Revision(id,calibration_id, revision)
1, 1, 0
2, 1, 1
3, 1, 2
4, 2, 0
5, 2, 1
6, 2, 2

StrategyCode(id, name)
1, CRAI8
2, LHBH1
3, CDAN2
4, GFUB

Now with many to many (pivot table, probably different terminology than what financials use)

Code: Select all

CalibrationCode_StrategyCode(calibration_id, strategy_id)
2, 1
2, 3
2,4

HardwareCode_Strategy(hardware_id, strategy_id)
2, 2
With the above pivot tables, lets throw this information into ChatGPT and see what kind of results we get when selecting SD48 hardware

Code: Select all

SELECT 
    hc.id AS hardware_id,
    hc.code AS hardware_code,
    sc.id AS strategy_id,
    sc.name AS strategy_name,
    cc.id AS calibration_id,
    cc.code AS calibration_code,
    ccr.revision AS calibration_revision
FROM 
    HardwareCode_Strategy hs
JOIN 
    HardwareCode hc ON hs.hardware_id = hc.id
JOIN 
    StrategyCode sc ON hs.strategy_id = sc.id
JOIN 
    CalibrationCode_StrategyCode ccs ON sc.id = ccs.strategy_id
JOIN 
    CalibrationCode cc ON ccs.calibration_id = cc.id
LEFT JOIN 
    CalibrationCode_Revision ccr ON cc.id = ccr.calibration_id
WHERE 
    hc.code = 'SD48'  -- Filter for SD48 hardware
ORDER BY 
    hc.code, sc.name, cc.code, ccr.revision;
Results

Code: Select all

hardware_id	hardware_code	strategy_id	strategy_name	calibration_id	calibration_code	calibration_revision
2	SD48	2	LHBH1	3	KID	0
2	SD48	2	LHBH1	3	KID	1
2	SD48	3	LHBH1	3	KID	2
Anyways, this took 15minutes of my brain dump, hope you get the idea.
The above is not necessarily good data, I just typed it out from my brain.

What I'm trying to explain is:
A pivot table is a specific database table used to implement a many-to-many relationship, containing foreign keys to both related tables.
tvrfan
Posts: 130
Joined: 2023 Oct 22, 22:13
Location: New Zealand
Vehicle Information: Several Kit cars, Ford (Europe), EEC-IV, TVR Vixen, Tasmin (a.k.a Wedge),
Engine - Cologne 2.8 V6 (Europe) catch code 'AA'.

EEC_Disassembler https://github.com/tvrfan/EEC-IV-disassembler

Re: EEC V file conversion

Unread post by tvrfan »

BOOSTEDEVERYTHING wrote: 2024 Dec 11, 18:39
So code has used a pointer of 3d9c to get to that data structure at 3da0 ..... so I hope you can see the 'trick' in there.
Sorry…I do not see it. How did you determine that you needed to add 4 to the pointer to get to the structure? Sorry if that’s a stupid question. Just trying to determine how I could find the same info in crai8 or any other file for that matter.
A9L was designed to allow for 4,6, or 8 cyl engines, so the ROM value (num_cyls) can only be one of those values. In fact the A9L was only used for 8 cyl engines in production (as far as I know). This was just intended as an example of how pointers don't always point directly to their 'targets' if it's a list or multiple structure.

The pointer actually points to the middle of an opcode (and yes on first sight I too thought "WTF?" ) but then later when I saw the ldw code that refers to it I knew it had to be an offset of 4,6, or 8 and then it makes sense.
BOOSTEDEVERYTHING
Posts: 427
Joined: 2023 Sep 06, 13:11
Location: Charlotte NC , USA
Vehicle Information: 1999 Ford Ranger with 2000 Explorer v8 swap, FLN0
2003 Ford F150 Harley Davidson, Built 5.4L SOHC with 3.4L Whipple and Built 4R100

Re: EEC V file conversion

Unread post by BOOSTEDEVERYTHING »

tvrfan wrote: 2024 Dec 12, 13:15
BOOSTEDEVERYTHING wrote: 2024 Dec 11, 18:39
So code has used a pointer of 3d9c to get to that data structure at 3da0 ..... so I hope you can see the 'trick' in there.
Sorry…I do not see it. How did you determine that you needed to add 4 to the pointer to get to the structure? Sorry if that’s a stupid question. Just trying to determine how I could find the same info in crai8 or any other file for that matter.
A9L was designed to allow for 4,6, or 8 cyl engines, so the ROM value (num_cyls) can only be one of those values. In fact the A9L was only used for 8 cyl engines in production (as far as I know). This was just intended as an example of how pointers don't always point directly to their 'targets' if it's a list or multiple structure.

The pointer actually points to the middle of an opcode (and yes on first sight I too thought "WTF?" ) but then later when I saw the ldw code that refers to it I knew it had to be an offset of 4,6, or 8 and then it makes sense.
Ok. Maybe I'll do some poking around in CRAI8 and see what I can find near the pointers after it uses the pointer for number of cylinders. Maybe something will stick out and it will hit me in the head.. LOL.
wwhite
Posts: 401
Joined: 2021 Feb 16, 15:53
Location: Victoria, BC, Canada
Vehicle Information: 1994 Flarside, XLT, 351w E4OD
SD48b, Quarter Horse, Burn2

Re: EEC V file conversion

Unread post by wwhite »

BOOSTEDEVERYTHING wrote: 2024 Dec 11, 18:39 Just trying to determine how I could find the same info in crai8 or any other file for that matter.
The CRAI8 has the following base register addresses:

Code: Select all

8 2062: 60,20                2060  RBASEADR_01        Rbase Rf0
8 2064: 2e,24                242e  RBASEADR_02        Rbase Rf2
8 2066: 12,27                2712  RBASEADR_03        Rbase Rf4
8 2068: b8,39                39b8  RBASEADR_04        Rbase Rf6
8 206a: 8c,44                448c  RBASEADR_05        Rbase Rf8
8 206c: 48,57                5748  RBASEADR_06        Rbase Rfa
8 206e: 32,5d                5d32  RBASEADR_07        Rbase Rfc
8 2070: 3e,72                723e  RBASEADR_08        Rbase Rfe
Follow the code for each:

Code: Select all

// Rfx base address, 8 of them, start at the hex address.
1 2060: 2e,24             Rf0     word      242e
1 242e: 12,27             Rf2     word      2712
1 2712: b8,39             Rf4     word      39b8   
1 39b8: 8c,44             Rf6     word      448c 
1 448c: 48,57             Rf8     word      5748
1 5748: 32,5d             Rfa     word      5d32
1 5d32: 3e,72             Rfc     word      723e
1 723e: 10,87             Rfe     word      8710
You now have the location of the starting point for each base address, + or - offset.

What I do, is follow the code from startup, and during initialization, some lists are initialized to default values in RAM.
Finding this can help.

Pretty sure the following code initializes RAM with default values:

Code: Select all

8 21a9: a1,c8,89,26          ldw   R26,89c8           R26 = 89c8;      
8 21ad: b2,27,29             ldb   R29,[R26++]        R29 = [R26++];       
8 21b0: 99,ff,29             cmpb  R29,ff                                  
8 21b3: df,11                je    21c6               if (R29 == ff) goto 21c6;
8 21b5: b2,27,2a             ldb   R2a,[R26++]        R2a = [R26++];       
8 21b8: b2,27,28             ldb   R28,[R26++]        R28 = [R26++];       
8 21bb: b2,27,2b             ldb   R2b,[R26++]        R2b = [R26++];       
8 21be: c6,28,2b             stb   [R28],R2b          [R28] = R2b;         
8 21c1: e0,2a,f4             djnz  R2a,21b8           R2a--; if (R2a !=  0) goto 21b8;
Looking at how the bytes are loaded from the list:

Code: Select all

1 89c8: 00,0b,80,40 
1 89cc: 9b,12,9a,84
1 89d0: 93,02,d0,ff,79,ff,78,1e
1 89d8: 77,1e,68,7f,67,7f,63,04
1 89e0: 01,15,e8,62,da,01,d8,28
1 89e8: af,08,ae,be,ad,08,ac,be
1 89f0: a1,08,a0,31,9f,08,9e,31
The list structure should be:
R29 =00, R2a = 0b, R28 = 80, R2b = 40
R80 = 40;

R2a-- = 0a
Repeat....at 21b8

R28 = 9b, R2b = 12
R9b = 12
R2a-- = 09
....
The pattern:
R9a = 84 // R2a-- = 08
R93 = 02 // R2a-- = 07
Rd0 = ff // R2a-- = 06
R79 = ff // R2a-- = 05
R78 = 1e // R2a-- = 04
R77 = 1e // R2a-- = 03
R68 = 7f // R2a-- = 02
R67 = 7f // R2a-- = 01
R63 = 04 // R2a-- = 00
[/code]

R2a is zero, increment R26, R29 check for end of lists for FF.
Load byte into R2a, we are now at
R29 = 01, R2a = 15;

repeat,
Re8 = 62
Rda = 01
Rd8 = 28


Guess what I'm saying, is following known Register addresses, and following the code, you learn to see how the code, ram and lists are structured.

Then when there are calls/jumps or ram locations, well, you gotta think like the CPU, and go to that memory location.
jsa
Posts: 437
Joined: 2021 Feb 16, 15:46
Location: Australia
Vehicle Information: 95 Escort RS Cosworth
2.0 YBP
CARD / QUIK / COSY / ANTI
GHAJ0
SMD-190 / SMD-490 EEC-IV

Binary Editor
ForDiag

Re: EEC V file conversion

Unread post by jsa »

wwhite wrote: 2024 Dec 12, 14:25 Pretty sure the following code initializes RAM with default values:

Code: Select all

8 21a9: a1,c8,89,26          ldw   R26,89c8           R26 = 89c8;      
8 21ad: b2,27,29             ldb   R29,[R26++]        R29 = [R26++];       
8 21b0: 99,ff,29             cmpb  R29,ff                                  
8 21b3: df,11                je    21c6               if (R29 == ff) goto 21c6;
8 21b5: b2,27,2a             ldb   R2a,[R26++]        R2a = [R26++];       
8 21b8: b2,27,28             ldb   R28,[R26++]        R28 = [R26++];       
8 21bb: b2,27,2b             ldb   R2b,[R26++]        R2b = [R26++];       
8 21be: c6,28,2b             stb   [R28],R2b          [R28] = R2b;         
8 21c1: e0,2a,f4             djnz  R2a,21b8           R2a--; if (R2a !=  0) goto 21b8;
That target address interleave in the structure is nasty, makes it nigh on impossible to command a structure for it in SAD at the moment.
jsa
Posts: 437
Joined: 2021 Feb 16, 15:46
Location: Australia
Vehicle Information: 95 Escort RS Cosworth
2.0 YBP
CARD / QUIK / COSY / ANTI
GHAJ0
SMD-190 / SMD-490 EEC-IV

Binary Editor
ForDiag

Re: EEC V file conversion

Unread post by jsa »

wwhite wrote: 2024 Dec 12, 11:20 ..
Database Design:
We have known calibration constants, variables, functions and tables with known descriptions(strategy docs).
...
lets throw this information into ChatGPT
Not an AI user myself, but it seems to be the answer to everything. What are the chances of feeding in the strategy documents and getting the scalars, functions and tables information out in a summary for a data source?
tvrfan
Posts: 130
Joined: 2023 Oct 22, 22:13
Location: New Zealand
Vehicle Information: Several Kit cars, Ford (Europe), EEC-IV, TVR Vixen, Tasmin (a.k.a Wedge),
Engine - Cologne 2.8 V6 (Europe) catch code 'AA'.

EEC_Disassembler https://github.com/tvrfan/EEC-IV-disassembler

Re: EEC V file conversion

Unread post by tvrfan »

wwhite wrote: 2024 Dec 12, 11:20
tvrfan wrote: 2024 Dec 11, 15:58 PIVOT TABLES ?? My other half thinks they are a total waste of time, and reckons everything you can do in a pivot table can be done with more straightforward (and easier?) cell logic formulae like IF-THEN-ELSE and collection filters and sometimes adding a 'type' column to filter with. She has a strong background in finance, so I believe her (I have never done much in excel myself, so I'm just passing this on...).
So, in my mind(which only I can read), I'll try to explain.

<snip>
Ah, OK, Sorry, I mistakenly read earlier about using Excel (probably from a jsa post, I know he uses excel quite a bit for analysis) and assumed you meant the same. I see now you are talking about many_to_many key relationships in your DB. Totally different. Terminology varies, the way I learned was that what you are describing is a multiple JOIN (I think?) across tables.

Thoughts -

In SAD decodes, the only true universal key is address (including bank), so (almost) everything is linked to an address. So symbol names are linked to objects (data structs, code,subroutines) by address. This seems obvious for a disassembler approach .... So in a DB design, I would most likely have address as a primary key in every DB table that SAD uses. My current in-memory system is all ordered by address.

For a wider database I agree we would indeed need keys at least by strategy, and bin (hardware ID), a lot more comment type content (maybe even linked to stored strategy doc by section no) and probably a whole different way of linking objects together (as they would relate to the strategy, not address). Both approaches are valid in same DB, we just need multiple keys to do it. No big deal I reckon...
wwhite
Posts: 401
Joined: 2021 Feb 16, 15:53
Location: Victoria, BC, Canada
Vehicle Information: 1994 Flarside, XLT, 351w E4OD
SD48b, Quarter Horse, Burn2

Re: EEC V file conversion

Unread post by wwhite »

jsa wrote: 2024 Dec 12, 15:24 What are the chances of feeding in the strategy documents and getting the scalars, functions and tables information out in a summary for a data source?
Not good, AI needs to be trained in this specific area for it to be useful.

Code: Select all

Based on the provided context, I will try to extract relevant information about scalars, functions, and tables. 

Scalars: 

    kamcol: maximum value
    kamrow: maximum value
    SPK_STATE: current state (1 or 2)
    SAF: spark function result (SPK_FBS or SPK_ENTRY)
    NEWSA: new value (0)
     

Functions: 

    FN1325L: a function that takes two arguments and returns a value
    adapt1_uprat, adapt2_uprat, adapt3_uprat, adapt4_uprat: adapted values based on kamcol and kamrow
     

Tables: 

    Not explicitly mentioned, but the context implies tables are used for lookup or reference in calculations (e.g., "use kamcol_max values twice so not to wrap around table")
     

Please note that the information is mostly related to specific engineering or programming context, and I'm doing my best to extract relevant details. If you have any further questions or need clarification on anything, feel free to ask! 

Also, I want to mention that the provided context appears to be a code snippet or a technical document, and some parts might be hard to understand without additional context or explanation. If you'd like me to clarify anything or provide more information, please let me know! 
wwhite
Posts: 401
Joined: 2021 Feb 16, 15:53
Location: Victoria, BC, Canada
Vehicle Information: 1994 Flarside, XLT, 351w E4OD
SD48b, Quarter Horse, Burn2

Re: EEC V file conversion

Unread post by wwhite »

jsa wrote: 2024 Dec 12, 14:52 That target address interleave in the structure is nasty, makes it nigh on impossible to command a structure for it in SAD at the moment.
But I have done this with 8061:

Code: Select all

aa68: 00,00               word      0
aa6a: 98,aa               word   aa98                                              # initialise data lists

aa6c: cf,01               struct  SYNCTR     ,       0.06 
aa6e: 9f,04               struct  Flags_9f   ,       0.25 
aa70: a5,40               struct  Flags_a5   ,       4    
aa72: a5,80               struct  Flags_a5   ,       8    
aa74: 4f,01               struct  Flags_4f   ,       0.06
and some what:

Code: Select all

aa98: 9a,aa               word   aa9a                                              # next data list
aa9a: 00,01               word    100                                              # Addresses + 0x100 for this list
aa9c: de,aa               word   aade                                              # next data list

aa9e: da,80               struct  GEAR_CUR  ,  80
aaa0: db,5c               struct  PDL       ,  5c
aaa2: 00,80               struct           0,  80
aaa4: 01,3e               struct           1,  3e
aaa6: 02,80               struct  LSO_Port  ,  80
aaa8: 03,a2               struct  BIO_Port  ,  a2
aaaa: 35,d8               struct          35,  d8
aaac: 98,99               struct  EFTR      ,  99
Same as this:

Code: Select all

# 9.0 Parameter Identification (PID) Code Tables:                                  #Parameter        PID    Data    Output    Output
                                                                                   #Name             Code   Type    Scaling   Resolution
                                                                                   #----------------------------------------------------
2922: b4,00,84            struct  N_RPM     ,  84                                  #N                 01    word      bin -2      4 RPM
2925: ba,00,00            struct  MAP       ,   0                                  #MAP               02    byte      bin 3       0.125 "Hg
2928: bb,00,00            struct  BP        ,   0                                  #BP                03    byte      bin 3       0.125 "Hg   
292b: 8e,03,00            struct         38e,   0                                  #SAFTOT            04    byte      bin 2       0.25 degrees S.A.
292e: 12,01,86            struct         112,  86                                  #IACT              05    word      bin 0       1 A/D count             
2931: 10,01,86            struct         110,  86                                  #IECT              06    word      bin 0       1 A/D count             
2934: 14,01,86            struct         114,  86                                  #IEGR              07    word      bin 0       1 A/D count             
2937: 1a,01,86            struct         11a,  86                                  #IEGO1             08    word      bin 0       1 A/D count             
293a: 1c,01,86            struct         11c,  86                                  #ITP               09    word      bin 0       1 A/D count               
293d: 00,00,00            struct           0,   0                                  #***NOT USED***    0A    
2940: 0e,01,86            struct         10e,  86                                  #IVCAL             0B    word      bin 0       1 A/D count             
2943: 94,00,84            struct  FUELPW1   ,  84                                  #FUELPW1           0C    word      bin -5      32 clock ticks          
2946: 96,00,84            struct  LAMBSE1   ,  84                                  #LAMBSE1           0D    word      bin 11      1/2048 unitless         
unless I misunderstand what you mean?
jsa
Posts: 437
Joined: 2021 Feb 16, 15:46
Location: Australia
Vehicle Information: 95 Escort RS Cosworth
2.0 YBP
CARD / QUIK / COSY / ANTI
GHAJ0
SMD-190 / SMD-490 EEC-IV

Binary Editor
ForDiag

Re: EEC V file conversion

Unread post by jsa »

wwhite wrote: 2024 Dec 12, 14:25

Code: Select all

8 21a9: a1,c8,89,26          ldw   R26,89c8           R26 = 89c8;      
8 21ad: b2,27,29             ldb   R29,[R26++]        R29 = [R26++];       <-----Byte 1

8 21b8: b2,27,28             ldb   R28,[R26++]        R28 = [R26++];       <-----Byte 3
The 8061's I've looked at have been a simple offset for which STRuct has an option.

If you've found a way to use the struct command to combine byte 1 & 3 and give a usable result please post the command and options from your DIR?

Thanks for the AI attempt. Confirms my earlier statements.
Post Reply