SAD Version 5 (alpha)

All hardware related, disassembly / programming and code discussions belong here.
wwhite
Posts: 319
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 »

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" ' 
   
and I get a whole bunch of this:

Code: Select all

## sym 2131 "Sub_2131"
   ## Error - Duplicate Command

## sym 2148 "Sub_2148"
   ## Error - Duplicate Command

## sym 2164 "Sub_2164"
   ## Error - Duplicate Command
   
wwhite
Posts: 319
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 »

Ok, fixed it. My dir actually works, still need to verify.

I removed all subroutines, like sub 2131 "Background_Loop" , caused duplicate command
because it is defined as sym 2131 "Sub_2131"

I also removed all symbols that were #Auto Added by SAD.
It appears without them defined in the dir, SAD will auto create on the fly.

Here's my resulting msg file:

Code: Select all

# ----------------------------
# SAD Version 5.0.5 Alpha (11 Jan 2024)
# ----------------------------

# ---------------------------------------------------------------------------------------------
# NB - All commands and errors are printed in new command format
# ---------------------------------------------------------------------------------------------


# Input file is 'C:\Users\wwhite\Programming\SAD\\KID2.bin'

# File is 56K (0xe000) bytes


# Read commands from directive file 'C:\Users\wwhite\Programming\SAD\\KID2_dir.txt'



# ----- Start Disassembly phase 1 -----

# ----- End   Disassembly phase 1 -----

# ----- Start Disassembly phase 2 -----

# ----- End   Disassembly phase 2  -----

# ----- Output Listing to file C:\Users\wwhite\Programming\SAD\\KID2_lst.txt



# ---------------------------------------------------------------------------------------------
# The disassembler has scanned the binary and produced the following equivalent command list.
# This list includes any user commands read in. It can be copied and pasted into a directives file.
# Commented command lines printed for information but may be uncommented (e.g. bank)
# ---------------------------------------------------------------------------------------------
Jamie from oz
Posts: 28
Joined: 2022 Jul 08, 04:54
Location: South Australia
Vehicle Information: 1995 ford falcon ute 5.0 windsor efi

Re: SAD Version 5 (alpha)

Unread post by Jamie from oz »

Tvrfan it's all good I can still keep working away with v4 and v5 as a reference for some that it seems to bo better than v4.

I will try the new syntax when I can as I am mainly trying to add correct short names to things that I have my random names on.
Have been referencing wwhite kid2 as a guide to the names then reference manual checking how it goes about the calls.
BOOSTEDEVERYTHING
Posts: 234
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: SAD Version 5 (alpha)

Unread post by BOOSTEDEVERYTHING »

tvrfan wrote: 2024 Jan 11, 17:57 Boosted...

Rbase zero - it's possible v4 allows it when it should not... and v5 catches it , but v5 should report an invalid address... not a duplicate.

System RBASES - SAD auto detects registers which are set to only one value ever (an address), and it then makes them rbases and valid everywhere. The 'master' setup is held at 2020 in 8061 bins, and 82060 (or 12060 in multibanks) 8065. Often there are more setup in other places, but their value is always the same (they point to same address). But in other places a 'temp base' may be used in the code for say a stack of data references only in one subroutine. Typically that will be to set a register to a value (address) and then do a lot of indexed opcodes [Rx + offset]. SAD does not get those, as the register is used for other things in other places. So those rbases are done with user commands, and have a range (i.e. valid only from here to there).

That list also shows the quirk of the way banks work. Anything below 0x400 has no bank (internal to CPU), anything else must have a bank, and SAD adds the default data bank (= 1). Haven't found any bin which has any data bank other than 1 (so far...)
V4 did not find many of the rbase values that v5 did. V5 found the 0 value and v4 gave me the error for duplicate address when I used it in my dir file for v4. V5 gave the entry to me without a dir file in the msg file.
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 11, 23:24 Ok, fixed it. My dir actually works, still need to verify.

I removed all subroutines, like sub 2131 "Background_Loop" , caused duplicate command
because it is defined as sym 2131 "Sub_2131"

I also removed all symbols that were #Auto Added by SAD.
It appears without them defined in the dir, SAD will auto create on the fly.

Here's my resulting msg file:

Code: Select all

# ----------------------------
# SAD Version 5.0.5 Alpha (11 Jan 2024)
# ----------------------------

# ---------------------------------------------------------------------------------------------
# NB - All commands and errors are printed in new command format
# ---------------------------------------------------------------------------------------------


# Input file is 'C:\Users\wwhite\Programming\SAD\\KID2.bin'

# File is 56K (0xe000) bytes


# Read commands from directive file 'C:\Users\wwhite\Programming\SAD\\KID2_dir.txt'



# ----- Start Disassembly phase 1 -----

# ----- End   Disassembly phase 1 -----

# ----- Start Disassembly phase 2 -----

# ----- End   Disassembly phase 2  -----

# ----- Output Listing to file C:\Users\wwhite\Programming\SAD\\KID2_lst.txt



# ---------------------------------------------------------------------------------------------
# The disassembler has scanned the binary and produced the following equivalent command list.
# This list includes any user commands read in. It can be copied and pasted into a directives file.
# Commented command lines printed for information but may be uncommented (e.g. bank)
# ---------------------------------------------------------------------------------------------
DAMN!!! That's a bug with sym (re)name rules. Anything the user specifies in a DIR file should be KING, but I noticed that it's not being honoured properly from a previous report (jsa?) of 'special' subr names (lookups) being overwritten. That was working in v4, so I've screwed that up somewhere in new code.
jsa
Posts: 274
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 »

I have some branches using JLEU where the printed output is rather obtuse.
Zero will never be greater than zero...yeah it's an artefact of the PSW setter not being captured.

From CARD.

Code: Select all

341b: af,76,e9,42         ldzbw R42,[R76+e9]     wR42 = [dc3c];
341f: 29,2b               scall 354c             Sub_354c ();
3421: d1,03               jleu  3426             if (0 > 0) {
.
.
    # SCall from L33F7                                                             Sub2ea1
    # SCall from L341F                                                             Sub2ea1
    # SCall from L3508                                                             Sub2ea1
    # SCall from L3530                                                             Sub2ea1
   Sub354c:
354c: 01,32               clrw  R32              R32 = 0;
354e: 8c,34,30            divw  R30,R34          wR30 /= R34;
3551: 07,42               incw  R42              R42++;
3553: 88,42,30            cmpw  R30,R42          
3556: f0                  ret                    return;
In other cases where SAD has not been able to identify the PSW setting code, something like CY = 0 is printed.
Referring to the software manual, JLEU will jump if the carry flag is zero or the zero flag is one.

For the continue case above, could SAD print something like;

Code: Select all

3421: d1,03               jleu  3426             if (C_PSW = 1 & Z_PSW = 0) {
It could be two lines, one each for C and Z.

Using the PSW command continues to work in this version, giving the expected output. So two thumbs up for that.
DIR

Code: Select all

PSW  33F9 3553
PSW  3421 3553
PSW  350A 3553
PSW  3532 3553
LST

Code: Select all

3417: a3,70,32,30         ldw   R30,[R70+32]     R30 = [4b2];
341b: af,76,e9,42         ldzbw R42,[R76+e9]     wR42 = [dc3c];
341f: 29,2b               scall 354c             Sub_354c ();
3421: d1,03               jleu  3426             if (R30 > R42) {
jsa
Posts: 274
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 »

Function crashes seem to be related to the diVide option with V4 function commands.

For CARD, this command and options in DIR by itself will crash SAD.

Code: Select all

func C020 C097 :W V +4096 :W V +1 P +5
For CARD, these commands and options in DIR each by their self will NOT crash SAD.

Code: Select all

func C020 C097 :W :W

OR

func C020 C097 :W :W P +5
For CARD, this command and options in DIR by itself will crash SAD.

Code: Select all

func C098 C0A5 :S Y V +1 :Y V +8 P +5
For CARD, these commands and options in DIR each by their self will NOT crash SAD.

Code: Select all

func C098 C0A5 :S Y :Y

OR

func C098 C0A5 :S Y :Y P +5

This will not crash or produce MSG errors.
Single entry in DIR

Code: Select all

func C020 C097 [ UW = float ( x / 12800) ] [W]
Zero is not the right answer...but 12800.0 you will say...
LST

Code: Select all

c020: ff,ff,87,0b         func      0,  2951
c024: 00,50,87,0b         func      0,  2951
c028: 00,48,38,08         func      0,  2104
c02c: 00,44,1d,07         func      0,  1821
c030: cd,3c,4d,05         func      0,  1357
c034: 9a,39,97,04         func      0,  1175
c038: 66,36,01,04         func      0,  1025
c03c: 33,33,7c,03         func      0,   892
c040: 00,30,fb,02         func      0,   763
c044: cd,2c,89,02         func      0,   649
c048: 9a,29,29,02         func      0,   553
c04c: 66,26,d4,01         func      0,   468
c050: 33,23,88,01         func      0,   392
c054: 9a,21,66,01         func      0,   358
c058: 00,20,41,01         func      0,   321
c05c: 66,1e,22,01         func      0,   290
c060: 33,1b,eb,00         func      0,   235
c064: 9a,19,d2,00         func      0,   210
c068: 00,18,bb,00         func      0,   187
c06c: 66,16,a3,00         func      0,   163
c070: cd,14,90,00         func      0,   144
c074: 33,13,80,00         func      0,   128
c078: 00,10,62,00         func      0,    98
c07c: cd,0c,46,00         func      0,    70
c080: 9a,09,31,00         func      0,    49
c084: cd,04,1a,00         func      0,    26
c088: 9a,01,15,00         func      0,    21
c08c: 00,00,00,00         func      0,     0
c090: 00,00,00,00         func      0,     0
c094: 00,00,00,00         func      0,     0
...12800.0 Single entry in DIR

Code: Select all

func C020 C097 [ UW = float ( x / 12800.0) ] [W]
An error is printed to MSG

Code: Select all

## func C020 C097 [ UW = float ( x / 12800.0) ] [W]
   ## Error - Invalid floating point number after '2800.0' 
No crash but no good.
LST

Code: Select all

c020: ff,ff               word   ffff
c022: 87,0b               word    b87

c024: 00,50,87,0b,00,48   ???   
c02a: 38,08,00,44,1d,07   ???   
c030: cd,3c,4d,05,9a,39   ???   
c036: 97,04,66,36,01,04   ???   
c03c: 33,33,7c,03,00,30   ???   
c042: fb,02,cd,2c,89,02   ???   
c048: 9a,29,29,02,66,26   ???   
c04e: d4,01,33,23,88,01   ???   
c054: 9a,21,66,01,00,20   ???   
c05a: 41,01,66,1e,22,01   ???   
c060: 33,1b,eb,00,9a,19   ???   
c066: d2,00,00,18,bb,00   ???   
c06c: 66,16,a3,00,cd,14   ???   
c072: 90,00,33,13,80,00   ???   
c078: 00,10,62,00,cd,0c   ???   
c07e: 46,00,9a,09,31,00   ???   
c084: cd,04,1a,00,9a,01   ???   
c08a: 15,00,00,00,00,00   ???   
c090: 00,00,00,00,00,00   ???   
c096: 00,00               ???   
Lets try Integer instead of float.
DIR

Code: Select all

func C020 C097 [ UW = integer ( x / 12800) ] [W]
Should be 5, 2951 for the first row.
LST

Code: Select all

c020: ff,ff,87,0b         func      0,  2951
c024: 00,50,87,0b         func      0,  2951
c028: 00,48,38,08         func      0,  2104
c02c: 00,44,1d,07         func      0,  1821
c030: cd,3c,4d,05         func      0,  1357
c034: 9a,39,97,04         func      0,  1175
c038: 66,36,01,04         func      0,  1025
c03c: 33,33,7c,03         func      0,   892
c040: 00,30,fb,02         func      0,   763
c044: cd,2c,89,02         func      0,   649
c048: 9a,29,29,02         func      0,   553
c04c: 66,26,d4,01         func      0,   468
c050: 33,23,88,01         func      0,   392
c054: 9a,21,66,01         func      0,   358
c058: 00,20,41,01         func      0,   321
c05c: 66,1e,22,01         func      0,   290
c060: 33,1b,eb,00         func      0,   235
c064: 9a,19,d2,00         func      0,   210
c068: 00,18,bb,00         func      0,   187
c06c: 66,16,a3,00         func      0,   163
c070: cd,14,90,00         func      0,   144
c074: 33,13,80,00         func      0,   128
c078: 00,10,62,00         func      0,    98
c07c: cd,0c,46,00         func      0,    70
c080: 9a,09,31,00         func      0,    49
c084: cd,04,1a,00         func      0,    26
c088: 9a,01,15,00         func      0,    21
c08c: 00,00,00,00         func      0,     0
c090: 00,00,00,00         func      0,     0
c094: 00,00,00,00         func      0,     0
Lets try integer with 4096.
DIR

Code: Select all

func C020 C097 [ UW = integer ( x / 4096) ] [W]
Should be 15 or 16, 2951 for the first row.
LST

Code: Select all

c020: ff,ff,87,0b         func      3,  2951
c024: 00,50,87,0b         func      1,  2951
c028: 00,48,38,08         func      1,  2104
c02c: 00,44,1d,07         func      1,  1821
c030: cd,3c,4d,05         func      0,  1357
c034: 9a,39,97,04         func      0,  1175
c038: 66,36,01,04         func      0,  1025
c03c: 33,33,7c,03         func      0,   892
c040: 00,30,fb,02         func      0,   763
c044: cd,2c,89,02         func      0,   649
c048: 9a,29,29,02         func      0,   553
c04c: 66,26,d4,01         func      0,   468
c050: 33,23,88,01         func      0,   392
c054: 9a,21,66,01         func      0,   358
c058: 00,20,41,01         func      0,   321
c05c: 66,1e,22,01         func      0,   290
c060: 33,1b,eb,00         func      0,   235
c064: 9a,19,d2,00         func      0,   210
c068: 00,18,bb,00         func      0,   187
c06c: 66,16,a3,00         func      0,   163
c070: cd,14,90,00         func      0,   144
c074: 33,13,80,00         func      0,   128
c078: 00,10,62,00         func      0,    98
c07c: cd,0c,46,00         func      0,    70
c080: 9a,09,31,00         func      0,    49
c084: cd,04,1a,00         func      0,    26
c088: 9a,01,15,00         func      0,    21
c08c: 00,00,00,00         func      0,     0
c090: 00,00,00,00         func      0,     0
c094: 00,00,00,00         func      0,     0
Soooo, what is this bug.
Lets do a hex calculation;
0xFFFF / 0x4096 = 0x3

Bingo, SAD has an issue with handling Hex VS Decimal from Binary VS User DIR entries.
Should SAD accept a math formula as an inferred conversion from Hex to Decimal??
Is native Hex math required for a use case, by the user??
Should the user have to specify the radix of math formulas entered in DIR??
jsa
Posts: 274
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 »

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??
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 »

PSWSET and ( 0 >= 0) - why.... [note for both 8061 and 8065...]

When the code does a conditional jump (JLE, JE, JLEU, etc) SAD scans backwards for the instruction which sets the PSW. why?, because some opcodes don't set PSW. Most common are LDW and LDB. So if you see code something like

Code: Select all

68,3a,98            sb2w  R32,R3a          R98 -= R32;    
b1,09,ba            ldb   Rba,9            Rba = 9;
d1,04               jleu  xxxx     
the conditional jump will jump if R98 < 0, NOT Rba... Yes, it's not obvious at first glance. If then you see

Code: Select all

ef,7a,f7            call  2395             sub_2395 ();
d1,04               jleu  xxxx  
Then SAD may print 'if (0<=0)' because it cannot find the instruction that set the PSW. I was in the process of providing for an 'answer' from a subroutine to be specified to help fix this, using the '=' in a different way in a global option, as per command

subr 3234 [$ = 34]

and then in the listing it would print

Code: Select all

ef,7a,f7            call  3234            R34 = sub_3234 ();
d1,04               jleu  xxxx            if (R34 < 0) {
and then the jleu would know what to use... but it isn't finished yet. It doesn't have a size for example (yet)

BUT - SAD still needs a PSWSET command even then because, how about this little trick in AA ?

Code: Select all

   HSOUT:
2b1c: de,04               jlt   2b22             if (0 >= 0) {                     # is really    if (R3a < 0)
2b1e: dd,04               jv    2b24             if (OVF = 1) goto Out_Now;
The very first thing this subroutine does is a conditional jump, but how the hell to decide where the PSW was last set, as subr can be called from different places.....so there's no way to decide in SAD....

Well, I hope that explains why (0 >= 0) may turn up. If I think of any way to solve this (better) automatically .....
wwhite
Posts: 319
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 »

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.
Post Reply