On Saturday, September 4, 2021 at 8:04:26 PM UTC-7, Andrew Roughan wrote:
> But then sometimes after I ‘hint’ at code the opcodes have triangles (see
> picture) and the lines on the left are bytes and the code is not clean.
> What is going on? How do I fix this?
Bear in mind that SourceGen is a code-tracing disassembler. It starts from "code start" points, and traces code as far as it can go. For simple programs this will cleanly separate code and data. For programs with indirect jumps and inline data elements, you will need to explicitly mark the places where execution starts or that hold inline data following a JSR. (There are features for formatting jump tables and common inline data formats that make those easy.)
Looking at the attributes column, you have put "code start point" tags on every byte. SourceGen did what you told it to and made EVERY BYTE a place where execution starts, including the bytes in the middle of earlier instructions.
Code often does this deliberately. For example, in Applesoft at
https://6502disassembly.com/a2-rom/Applesoft.html#SymPOP :
d979: a2 16 ldx #ERR_NOGOSUB
d97b: 2c bit ▼ $5aa2 ;fake: BIT xxxx skips ahead to JMP ERROR
d97c: a2 5a UNDERR ldx #ERR_UNDEFSTAT
Code executing straight through will LDX #$16 and then BIT $5AA2, but code branching into the middle of the instruction will do LDX #$5A. SourceGen shows both paths, alerting you to the presence of an embedded instruction by showing a triangle next to the opcode. The above code doesn't use any attributes, because the code tracer identified both execution paths automatically. (The triangle bit is explained in the tutorial:
https://6502bench.com/sgtutorial/odds-ends.html .)
What you need to do is select all of the code in that picture, Ctrl+H Ctrl+R to remove the tags, and then put a code start attribute ONLY on the place where the code starts.
Code start attributes are meant to be applied sparingly. Assuming you're using a recent version (currently v1.7.5), you should have received a warning when you applied the hint that what you were attempting (adding the tags to multiple bytes) was rarely a good idea.