andlabs/65816disasm — pull request #4 by cr1901 (2014-08-01 22:16:59+00:00)
Title: Add a command to manually mark data as code (dowordmanual).

Useful for jumps based on Direct Page.

Hi! First of all, I wanted to thank you for this disassembler, I find it highly useful. For a project I'm currently working on, the disassembler misses some jumps based on variables in the Direct Page. I have added a command which will manually mark such sections as code based on the environment from which the code is jumped.

As always, this will not be perfect (though uncommon, consider the case where a piece of code can be reached from multiple Direct Page variables used as direct indirect operands), and will not find dead code. Additionally, all my additions do is annotate the code and add a label. Some future work would be integration with doauto or other analysis to attempt to detect when A,X, or Y is loaded with a variable which corresponds to a subroutine address which has been marked manually.

As an example, running the following the commands:
```
doauto
dowordmanual 00B19B 000B7D
```
on the Anthrox 1992 Christmas Demo creates the following code:
```
NativeNMI: ; $008B68 / $808B68
php	; $B68
rep	#$30	; $B69
pha	; $B6B
phx	; $B6C
phy	; $B6D
phd	; $B6E
phb	; $B6F
sep	#$20	; $B70
lda	#$80	; $B72
sta	$2100	; $B74 | $2100 -> $002100
rep	#$20	; $B77
lda	$76	; $B79 | $76 + d=$0000 -> $000076
beq	loc_B80	; $B7B
jmp	($0076)	; $B7D | $0076 -> $000076 | pbr = $00
...
loc_17EA: ; $0097EA / $8097EA
jsr	sub_1B0B	; $17EA
jsr	sub_1B51	; $17ED
jsr	sub_1AA0	; $17F0
jsr	sub_1A32	; $17F3
lda	#$2200	; $17F6
sta	$7C	; $17F9 | $7C + d=$0000 -> $00007C
ldx	#$C073	; $17FB
jsr	sub_19CA	; $17FE
ldx	#$BB7D	; $1801
lda	#$B19B	; $1804
sta	$76	; $1807 | $76 + d=$0000 -> $000076
...
sub_319B: ; $00B19B / $80B19B
sep	#$20	; $319B
rep	#$10	; $319D
ldx	#$0000	; $319F
stx	$2116	; $31A2 | $2116 -> $002116
lda	#$00	; $31A5
sta	$2115	; $31A7 | $2115 -> $002115
ldx	#$0000	; $31AA
loc_31AD: ; $00B1AD / $80B1AD
lda	$048000,x	; $31AD | $048000 -> ROM $020000
sta	$2118	; $31B1 | $2118 -> $002118
inx	; $31B4
cpx	#$4000	; $31B5
bne	loc_31AD	; $31B8
jmp	loc_289C	; $31BA
```