[PicForth] Re: A smarter disassembly utility
David McNab
david at rebirthing.co.nz
Thu Oct 28 11:51:43 CEST 2004
Samuel Tardieu wrote:
> David, how do this compare to PicForth integrated disassembler?
I never knew PicForth had an integrated disassembler.
But sure enough, on grepping the picforth dir for 'disass', I found
mention of the word 'dis' in changes.html.
Wish I'd known of it before.
Samuel, you've got one real gem in PicForth!
(I'm in the process of porting my PIC C projects to PicForth, which one
could argue is the strongest possible compliment in action)
However, PicForth suffers somewhat from incomplete doco. The existing
doco is good, but desperately needs fleshing out, especially in regard
to some of the internals which benefit users. I've sprained my brain
many times trying to figure out some of the internals.
I guess the difference with picforth's 'dis' and my 'fdasm' is that
fdasm works from outside the picforth environment, by parsing hex files
and map files.
fdasm's output can easily be redirected to a file or pager (easy in
unix, not sure how to redirect stdout from within gforth).
another intended use of my util is for autopsies - where one rips the
image from a PIC back to a .hex file, and analyses what's actually
inside the PIC's program/data memory.
Cheers
David
>
> Here is an example of PicForth disassembly (excerpt from
> i2cloader.fs):
>
> ; name: add-to-buffer
> ; max return-stack depth: 1
> 0x0661 0823 movf 0x23,w
> 0x0662 0384 decf 0x04,f
> 0x0663 0080 movwf 0x00
> 0x0664 2604 call 0x604 ; any-!
> 0x0665 0AA3 incf 0x23,f
> 0x0666 0008 return
> ; name: reset-i2c-buffer
> ; max return-stack depth: 0
> 0x0667 3025 movlw 0x25
> 0x0668 00A3 movwf 0x23
> 0x0669 0008 return
> ; name: read-eeprom-data
> ; max return-stack depth: 2
> 0x066A 2667 call 0x667 ; reset-i2c-buffer
> 0x066B 0826 movf 0x26,w
> 0x066C 00C5 movwf 0x45
> 0x066D 3010 movlw 0x10
> 0x066E 00C6 movwf 0x46
> 0x066F 0845 movf 0x45,w
> 0x0670 261E call 0x61E ; ee@
> 0x0671 2661 call 0x661 ; add-to-buffer (rs depth: 1)
> 0x0672 0AC5 incf 0x45,f
> 0x0673 0BC6 decfsz 0x46,f
> 0x0674 2E6F goto 0x66F ; read-eeprom-data + 0x005
> 0x0675 3020 movlw 0x20
> 0x0676 0685 xorwf 0x05,f
> 0x0677 0008 return
>
> Sam
--
Cheers
David
More information about the PicForth
mailing list