[comp.sys.handhelds] SAD - Saturn Disassembler Beta 1.01

bson@rice-chex.ai.mit.edu (Jan Brittenson) (09/15/90)

   I have just (sort of) finished a Saturn Disassembler. I would like
a couple of people out there who have previously disassembled parts of
the HP-48SX ROMs to verify that the output is correct by disassembling
previously disassembled areas and comparing the results. If you are
interested in doing this, drop me a line. All others, please hang on
until most bugs are out, and a couple of tools have been added to
update the symbol and comment databases using edited listings as
input, as well as a GNU Emacs mode.

   The preparatory work required is to dump areas of the ROMs into
your UNIX system (DOS users will be on their own here), and convert it
into Core format. SAD consults three databases: Core, Symbols, and
Comments. Only Core is necessary for the verification.


   Included is a sample SAD 1.01 listing ([...] identify comments
inserted by SAD, the rest are picked from the Comments database):


05b79
05b79   ; Allocate string on heap. 
05b79   ; C is to contain the string length, in bytes.
05b79   ; Sets r0 to object header address, and d0 to data address.
05b79   ; Sets mode to hex.
05b79
05b79   stralloc:
05b79 04       sethex
05b7b c6       add.a	c, c		; Bytes to nibbles
05b7d 84a      clrb	#a, st		; No GC performed
05b80 24       move.1	4, p
05b82 809      add.a	p+1, c
05b85 108      move.w	c, r0
05b88 20       move.1	0, p
05b8a 8f60860  call.a	c=free_mem	; [<#6806>]
05b91 da       move.a	c, a
05b93 118      move.w	r0, c
05b96 2f       move.1	15, p
05b98 809      add.a	p+1, c
05b9b 20       move.1	0, p
05b9d 8bed0    brle.a	c, a, stralloc+#34 ; [<#5bad>]
05ba2 8fd3361  call.a	#1633d		; GC?
05ba9 6edf     jump.3	stralloc+#f	; [<#5b88>]
05bad 118      move.w	r0, c
05bb0 24       move.1	4, p
05bb2 809      add.a	p+1, c
05bb5 20       move.1	0, p
05bb7 8f8da60  call.a	#6ad8		; blkalloc?
05bbe 132      swap.a	a, d0
05bc1 130      move.a	a, d0
05bc4 120      swap.w	a, r0
05bc7 34c2a20  move.p5	type_String, c	; [<#2a2c>]
05bce 144      move.a	c, @d0
05bd1 164      add.a	5, d0
05bd4 140      move.a	a, @d0
05bd7 164      add.a	5, d0
05bda 1f97507  move.5	TOS, d1		; [<#70579>]
05be1 147      move.a	@d1, c
05be4 135      move.a	c, d1
05be7 03       retclrc

alonzo@microsoft.UUCP (Alonzo GARIEPY) (09/16/90)

In article <10712@life.ai.mit.edu> bson@rice-chex.ai.mit.edu (Jan Brittenson) writes:
>    I have just (sort of) finished a Saturn Disassembler. I would like
> a couple of people out there who have previously disassembled parts of
> the HP-48SX ROMs to verify that the output is correct by disassembling
> previously disassembled areas and comparing the results.
> 
> 05b79   stralloc:
> 05b79 04       sethex
> [...]

Congratulations, this is excellent work.  I verified the stralloc routine
and everything checks out okay.  More tests are definately in order to
catch some of the trickier problems. 

I do have some suggestions to make based on how my assembler/disassembler
and Andreas's assembler work.  These aren't necessarily the best ways to
do things so we should discuss them in order to come to some standard.

1.  All hex numbers should be preceded by the # symbol, including the
    machine code and addresses in listing files.

2.  Standard symbols begin with a letter or underscore and contain only 
    numbers, letters and underscores (we can talk about adding such things 
    as the $ and .).

3.  Nonstandard symbols are enclosed in quotes and can contain any
    characters.  Example:  "Garbage Collector!"  When used as labels,
    the colon goes outside the quotes.

4.  All symbols used as arguments should be defined in the disassembly
    (controllable by command line option). The simplest way to define
    an address symbol is    
    	#xxxxx: symbol: 
    Andreas also supports assignment for address and nonaddress symbols
  	symbol=#xxxxx  
    This has the disadvantage of a potential parsing problem if 'symbol'
    conflicts with a keyword.  One modification is that a standard symbol
    cannot be a keyword (i.e., if you want the symbol "move" it must
    always be enclosed in quotes).  I imagine we can come up with a scheme
    where numeric symbols don't conflict with keywords.
    
5.  I have seen many assemblers get into trouble with poor syntax for 
    macro capabilities, so I am inclined to think this through and make 
    it part of the standard.  My preference would be to use an existing, 
    portable, macro processor.  Cpp is one possibility, but not very 
    attractive.  The ideal would be something that is powerful enough to 
    implement the assembler and disassembler itself.  Any suggestions
    out there?

6.  Whether arguments are expressed in hex and commented with symbol names,
    or expressed symbolically and commented with hex equivalents, should be
    controllable by a command line switch.

7.  Comments should not be used for machine readable information.  Thus the
    syntax [<#xxxxx>] should be replaced with the simpler #xxxxx.

8.  The data pseudo op is used to put non instructions into the code.
    Your disassembler should use the data op for anything that is not
    a valid instruction.  Here are a few examples of its use from the 
    CHIP48 source by Andreas Gustafsson...
		data.b	'A'
		data.a	#2dcc		; machine code object
	begin:	data.a	end-begin	; length of object

		*		*		*

At one point I was planning a better disassembler (like yours!) and I 
have some interesting ideas about RPL and synchronization (always a problem
with disassembly) that you might like to hear.  Drop me a line.

Alonzo Gariepy
alonzo@microsoft