SAD Version 5 (alpha)

All hardware related, disassembly / programming and code discussions belong here.
tvrfan
Posts: 86
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: SAD Version 5 (alpha)

Unread post by tvrfan »

jsa wrote: 2024 Jan 13, 08:07
wwhite wrote: 2024 Jan 11, 23:10 Well, I have 5.0.5 working the best I can with my dir.

Now I get the following in msg from SAD:

Code: Select all

## sym 2 "CPU_OK" [B 6]               
   ## Error - '[' expected
## sym 4 "AD_Cmd" W [B 0 71]               
   ## Error - '[' expected after '_Cmd" ' 
## sym 5 "WDG_Timer" W [B 0 71]               
   ## Error - '[' expected after 'imer" ' 
   
In light of the math hex/dec issue in my last post, 71, is that hex or dec??

TVRfan what should it be and is it a contributing bug??
There's nothing wrong with first command, can't see why that fails. That's a BUG...
The next two fail because the 'W' is outside the brackets - all options MUST be tied to a data item, and each set of '[ ]' is a new data item. So that's right, cmd needs a '['

You can have nested data items i.e. [W [B0]] but 'bit 0' is still a separate data item from a syntax point of view. One extra 'global' (for that command) is allowed, format is [$ ...], only for some commands (e.g. struct) which is used for layout and other things.

NOTE - there are several bugs reported in the command reader to be found - it seems to report the wrong error a lot, i.e. "Duplicate Command" when it's "invalid address" , and "overlaps" when it's not.

The '71' should be rejected as an invalid bit number, only 0-31 is allowed (a 'long') so again, wrong error reported..
tvrfan
Posts: 86
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: SAD Version 5 (alpha)

Unread post by tvrfan »

wwhite wrote: 2024 Jan 13, 15:43 I was working on an emulator for 8061, I had stopped because of exactly that, setting of the PSW.
I'm going to start working on it again.
PSW should be accessible globally in code.

I think what you are saying is SAD only checks previous instruction setting of PSW, but doesn't account for if an instruction doesn't set it, and hence doesn't know what the actual previous PSW was, wherever it was last set, if that makes any sense.
Yes, basically. Conditional jumps jump on the state of the PSW, which may or may not be set by the last instruction. If it isn't obvious where PSW was set from the jump then need something as a backup.....

Emulator -
I wrote an emulator ages ago, but it got horribly complicated, and I gave up. In effect you have to model all the internal 'registers' (PSW included) and all of the special function registers as a separate piece. What I didn't do was to include timing, which a was big mistake... every opcode takes a certain number of 'ticks' and it's different for different address modes, whether a conditional jump is taken or not...and stuff like A/D conversion takes even more ticks, even doing interrupts and so on.

I did most of the SFR stuff , but without any timing, and then I realised that to make an emulator viable, you actually also need some kind of 'engine model' so that the code 'fits' events that would be going on (PIP is most obvious one) with the right times/ticks... and I didn't and still don't have a clue how to do that in any sensible way. I set a fixed RPM (via PIPS coming in) but quickly the emulator set all the ignition timing to ridiculous values and fuel injection likewise....

Proper timing may have fixed this, but there's a LOT of it to do.

But honestly, good luck, I hope you find a way to crack it..
tvrfan
Posts: 86
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: SAD Version 5 (alpha)

Unread post by tvrfan »

Carry and overflow.

I think I got carry sorted with respect to previous instructions. It's the same basic idea as conditional jumps = 'which opcode last set the PSW' , but also some bins use the carry flag as a marker (just like setting a bit flag), so SAD should print these as 'if (CY = 0)' style. Signed/unsigned lookups in some bins use the carry flag. Most use a bit in a register.

Overflow - SAD v4 did the same as carry (look for last PSW setter) but I reckon it was often wrong - looking at those wonderful Ford manuals proved that OVF flag doesn't get set as I assumed. So for now, I've gone back to basic 'if (OVF = 1) style' whilst everything else gets fixed, and then I'll go back and check.
tvrfan
Posts: 86
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: SAD Version 5 (alpha)

Unread post by tvrfan »

Just in case !!

If anything in here says/implies "This is DEFINITELY RIGHT!" in my wording then I didn't mean it. All of the explanations here are to the best of my understanding, so if you reckon there's a mistake, please ask. It's always possible I've screwed something up. None of us are perfect.

My IT career showed me a lot about how some people get defensive to "hey, I think this is wrong..." because they think their code/creation/... is "their baby". It just gets in the way. Yeah, you do have to change your attitude when someone says it to you for the first time, but it's always worth double checking.
wwhite
Posts: 316
Joined: 2021 Feb 16, 15:53
Location: Victoria, BC, Canada
Vehicle Information: 1994 Flarside, XLT, 351w E4OD
SD48b, Quarter Horse, Burn2

Re: SAD Version 5 (alpha)

Unread post by wwhite »

SAD created the following:

Code: Select all

sym 4 "AD_Cmd" W [B 0 71]               #Auto Added by SAD
Still not happy:

Code: Select all


## sym 2 "CPU_OK" [B 6]               
   ## Error - '[' expected
## sym 4 "AD_Cmd"  [W B 0 71]               
   ## Error - Invalid End Bit after 'B 0 71' 
tvrfan
Posts: 86
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: SAD Version 5 (alpha)

Unread post by tvrfan »

wwhite wrote: 2024 Jan 13, 20:02 SAD created the following:

Code: Select all

sym 4 "AD_Cmd" W [B 0 71]               #Auto Added by SAD
Still not happy:

Code: Select all


## sym 2 "CPU_OK" [B 6]               
   ## Error - '[' expected
## sym 4 "AD_Cmd"  [W B 0 71]               
   ## Error - Invalid End Bit after 'B 0 71' 
Thanks - I just spotted that SAD prints these in the _msg file, and they are wrong (Duh on me) ....
and the 'W' is outside the brackets. ... sorry didn't get that before...

( the '71' is 7 + 64 or hex 0x47, and guess what flag I use for 'write' .... yep 0x40 ...)
jsa
Posts: 271
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: SAD Version 5 (alpha)

Unread post by jsa »

TVRfan, thank you for taking on board our feedback, whether it is right or wrong.
tvrfan
Posts: 86
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: SAD Version 5 (alpha)

Unread post by tvrfan »

No worries - If i want this to work for everybody.... I need the feedback - and the free testing !! (thanks again to all of you)
tvrfan
Posts: 86
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: SAD Version 5 (alpha)

Unread post by tvrfan »

Just released 5.0.6, not everything fixed yet, but enough things fixed to make it worth doing.
Also released source code, which I didn't do for previous V5 fixes.

I'm sure there's more stuff to fix yet, and to add....here are fixes over .5

FIXED - crash in handling of calc types with "= float" due to incorrect size/pointer (in funcs and tables mainly)
FIXED - "] expected" and "Invalid Address" and other errors if command has following spaces (and/or comments)
FIXED - "At least 2 values Required" error for special lookup types.
FIXED - parsing of 'calc' commands reports error when no space after a bracket.
FIXED - Incorrect wrap of comments (carry over from v4)
FIXED - repair style for AN3B, AN3W to V4 style of "R32 = name | name | name" back to correct v4 form.

CHANGE - add "with <command>" for duplicates and overlaps in dir file. (user request)

NB. Linux didn't crash for the first one, Windows did (a faulty pointer) but it did produce incorrect results on the function print (from jamie's example), which was my clue to finding it. Others are mostly incorrect handling of 'white space' in commands after new command syntax code added.

Noted that some subroutine calls still miss their arguments - that's my next problem to fix , unless you guys find another crash !
tvrfan
Posts: 86
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: SAD Version 5 (alpha)

Unread post by tvrfan »

Discovered a couple of things already -

Subroutine Arguments can be missed if code does a jump in the subroutine to the code which gets the arguments.
Rbase logic is wrong and can generate phantoms (reported by boosted).
Post Reply