

MODIFICATION OF LADS SUBPROGRAM 'DIS' (DISASSEMBLER)
To Support Hardcopy


Mike Davidson
74116,2507

Copyright 1985
Commercial Rights Reserved


What is LADS?

     Richard Mansfield's LADS (Label Assembler Development System) is very
probably the most thoroughly documented assembler for the 6502 chip family in
existence.  Not the least of its virtues is price; for less than $15, one is
presented with a 450-page spiral-bound volume that includes the object code,
a checksum-based editor to facilitate almost painless entry, the full,
commented source code, and a highly readable tour of logic, routines,
programming hints, and help.  Indeed, Mr. Mansfield conducts a one-to-one
seminar, and the instruction is first rate.  Optionally, a disk may be
ordered at modest cost, if entering 10K of source code, plus another 5K of
object code isn't your idea of fun.  In sum, LADS is a key for almost anyone
to successfully learn assembly language, and to begin producing some useful
stuff in ML.

'DIS'--The Disassembler Subprogram

     Quite obviously, disassembly and study of commercial or "professional"
routines are a large part of becoming proficient in machine language.  Study
of another's work is not unlike the casebook method in law, or the laboratory
environment in science.  LADS includes a very fast optional disassembler.

     The present file shows how to modify this subprogram to stream
disassembled code to a printer.  There are, of course, other approaches to
this.  My personal preference and work habits dictate that having an entire
routine in hardcopy is much easier to follow than starting and stopping screen
output.  Convenience also determined that 'dis' remain a RAM-based aid rather
than attempting to read files directly from disk.  As modified, a programmer
may disassemble between two addresses without having to watch the equipment.
The stop key is active at all times, to allow changing one's mind.  One is not
obligated to use header-dictated starting addresses, but may dip into memory at
any point and quit at any point.  'Dis' is also most useful for exploring ROM
routines.

The Modification

     These changes presuppose that you have a machine-readable copy of all the
LADS subprograms (source code), since you will be creating new object code for
'dis.'  The disassembler may NOT stand alone.  It draws upon routines and
definitions elsewhere in LADS during assembly and execution, as do the present
modifications.

     Line numbers have been arranged to merge with the published source code,
using most BASIC merge utilities.  'Disk Merge' (VIC/64), published in the
January '85 issue of Gazette, should work well.  There are others on CIS.  If
you do a merge, the modifications file should be designated as primary.  To be
of help to the greatest number of users, I have purposely not submitted this
as a machine-specific image file.  Users may elect to convert the listing from
ASCII to program with an appropriate file-conversion utility.  Dan Rothwell's
'Cruncher' (Midwest Micro) is an all-ML example for the C-64; others are
available through ACCESS.  If all else fails, one COULD type it in manually.
(Smile).

     Commenting is intended to resolve initial questions on logic, and may be
deleted at your convenience.  I suggest that you create a separate work disk
containing all the subprogram source code, leaving your master disk intact, as
published.

     Questions on these modifications are always welcome via EMAIL.



25 lda #147:jsr print:jsr prntcr; clr screen, cursor to line two
161 jsr prntcr:lda #<stopmess:sta temp:lda #>stopmess:sta temp+1:jsr prntmess
162 jsr prntcr:lda #63:jsr print:ldy #0:sty y; format, punc, zero counter
163 dtm1 jsr charin
164 beq dtm1
165 cmp #13;  ck for cr
166 beq dm1
167 ldy y:sta label,y:jsr print
168 iny:sty y:jmp dtm1
169 dm1 lda #0:sta label,y:jsr prntcr
170 lda #<label:sta temp:lda #>label:sta temp+1:jsr valdec
171 lda result:sta nubuf:lda result+1:sta nubuf+1
172 jsr open4;  printer channel--routine resides in subprogram 'open1'
173 inc printflag; advise lads we're sending data to printer
174 ldx #4; logical file nmbr
175 jsr chkout
176 ;
190 getbyte jsr stopkey:bne goahead:jmp fin; after keyscan, interpret result
195 goahead jsr gb:sta filen
600 alldone jsr prntcr:jsr stopck:bcc alld1:jmp fin
601 ;  stopck is a double-byte comparison between start & stop addrs
602 ;  branch occurs if result < stop, to getbyte thru alld1. otherwise, exit
603 ;  fin is lads most formal exit, at line 4390 in subprogram 'eval'
716 stopmess .byte "enter stop address":.byte 0
720 stopck sec
722 lda pmem
724 sbc nubuf
726 sta result
728 lda pmem+1
730 sbc nubuf+1
732 ora result
734 rts
750 .file dtables
755 ;
760 ;-------------------------------------------------------------------------
761 ;          references
762 ;-------------------------------------------------------------------------
763 ;
764 ;the label assembler development system (lads) is documented in
765 ;
766 ;richard mansfield, second book of machine language (greensboro, nc:
767 ;compute! publications, inc., 1984)
768 ;
769 ;the c-64 rom routines are generally described in
770 ;
771 ;commodore 64 programmer's reference guide (wayne, pa: commodore business
772 ;machines, inc., 1982), pp. 272-306


