sweh wrote:
Yeah, it's the "clean" part that I was having trouble with. Comments might be multi-line (eg describing a whole subroutine) or associated with a command (eg STA to a hardware register). The best I thought of was having "+ADDR" or "+LABEL" (or some other indicator) to indicate start of comment and then read the next line(s) until the next address/label and then sticking the comment in just before that point. Hmm...
Comments would normally start with a comment character, either ; or \, so that would be the normal thing to insert in the output and check for in the input.
I usually use (TABs or SPCs to column);(SPC) or (TABs or SPCs to column):\(SPC) as a comment marker, eg:
Code:
FFE0 JMP (&0210) ; OSRDCH get a byte from current input stream
FFE3 CMP #&0D ; OSASCI output a byte to VDU stream expanding
FFE5 BNE &FFEE ; carriage returns (&0D) to LF/CR (&0A,&0D)
FFE7 LDA #&0A ; OSNEWL output a CR/LF to VDU stream
FFE9 JSR OSWRCH ; Outputs A followed by CR to VDU stream
... or (more detailed example) ...
FFEC LDA #&0D :\ OSWRCR output a CR to VDU stream
FFEE JMP (&020E) :\ OSWRCH output a character to the VDU stream
FFF1 JMP (&020C) :\ OSWORD perform operation using parameter table
\ On entry, A =function
\ XY=>control block
\ On exit, OSWORD 0, CC=Ok, CS=Escape
\ Y=length of returned line
\ OSWORD <>0, A,X,Y,P irrelevant, likely to be corrupted
\ All data returned in control block
\
FFF4 JMP (&020A) :\ OSBYTE perform operation with single bytes
\ On entry, A=function
\ X=first byte parameter
\ Y=second byte parameter if A>&7F
\ On exit, A=preserved
\ X=first byte result
\ Y=second byte result if A>&7F
\ CC/CS returned for some if A>&7F
\
FFF7 JMP (&0208) :\ OSCLI pass string to command line interpreter
\ On entry, XY=>command string
\ On exit, all registers irrelevant
\ Some systems return A=return result
If I'm creating a disassembly to then use as source code, I put the addresses in the comments. Short version:
Code:
.OSWORD :JMP (&020C) :\ &FFF1 - Perform operation using parameter table
.OSBYTE :JMP (&020A) :\ &FFF4 - Perform operation with single bytes
.OS_CLI :JMP (&0208) :\ &FFF7 - Pass string to command line interpreter
Detailed version:
Code:
\ ========================================================
\ OSWORD - &FFF1 - Perform operation using parameter table
\ --------------------------------------------------------
\ On entry, A =function
\ XY=>control block
\ On exit, OSWORD 0, CC=Ok, CS=Escape
\ Y=length of returned line
\ OSWORD <>0, A,X,Y,P irrelevant, likely to be corrupted
\ All data returned in control block
\
.OSWORD :JMP (&020C)
\
\ ====================================================
\ OSBYTE - &FFF4 - Perform operation with single bytes
\ ----------------------------------------------------
\ On entry, A=function
\ X=first byte parameter
\ Y=second byte parameter if A>&7F
\ On exit, A=preserved (exceptions with &82/&83/&84)
\ X=first byte result
\ Y=second byte result if A>&7F
\ CC/CS returned for some if A>&7F
\
.OSBYTE :JMP (&020A)
\
\ =======================================================
\ OSCLI - &FFF7 - Pass string to command line interpreter
\ -------------------------------------------------------
\ On entry, XY=>command string
\ On exit, all registers irrelevant
\ Some systems return A=return result
\
.OS_CLI :JMP (&0208)
\
As an example see the
DNFS disassembly.