From 22e76eaa7f829aed4aaab8a30cc30a5b2bb1df33 Mon Sep 17 00:00:00 2001 From: Jason Borgmann Date: Sat, 10 Jan 2026 19:51:58 -0600 Subject: [PATCH 1/3] Implement backslash line continuation feature --- tests/cnttst.s | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/cnttst.s diff --git a/tests/cnttst.s b/tests/cnttst.s new file mode 100644 index 0000000..82dfbd0 --- /dev/null +++ b/tests/cnttst.s @@ -0,0 +1,29 @@ +********************************************************************** +* Line Continuation Test +* Tests for backslash line continuation feature +********************************************************************** + +* Test 1: Simple continuation in operand field +T1_LBL LDAA #$10 \ + ADDB #$20 + +* Test 2: Continuation in mnemonic field + LDX #$200 \ + STAA 0,X + +* Test 3: Multiple continuations + LDAA #$01 \ + ADDB #$02 \ + STAA $300 + +* Test 4: Backslash in quoted string (should be literal) + FCC "test\"literal" + +* Test 5: Continuation in comment field + LDAA #$10 * comment continues \ + ADDB #$20 + +* Expected behavior: +* - Tests 1-3: Lines should continue without terminating +* - Test 4: Backslash in quotes should be literal, not continuation +* - Test 5: Comment should continue (not tested by assembler, but stored) From 13e9e2b136fcc80c1a1257b22acb4006e1bb42df Mon Sep 17 00:00:00 2001 From: Jason Borgmann Date: Sat, 10 Jan 2026 23:19:36 -0600 Subject: [PATCH 2/3] Forgot all of the files. --- README.md | 7 ++++--- asm68.s | 33 +++++++++++++++++++++++++++++---- defs.s | 3 ++- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 6f1d6de..e5d281c 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,9 @@ Unless otherwise specified, the assembler generally follows the source conventio ### Extensions -- `.` may be used as PC in expressions +- ‘.’ may be used as PC - `;` may be used instead of `*` to introduce comments +- `\` may be used to continue a line ### Unimplemented directives @@ -66,12 +67,10 @@ Unless otherwise specified, the assembler generally follows the source conventio ### Unimplemented features -- `*` as PC in expressions - `@` octal prefix - `%` binary prefix - `$` in symbol name - `.` in middle of symbol name -- `\` line continuation character - signed arithmetic, greater than 16 bits - forward references in FCB directives. @@ -84,6 +83,8 @@ Unless otherwise specified, the assembler generally follows the source conventio - Use of forward reference in EQU or ORG directives. - Source or program buffer overflow. - Support for signed division removed; tests have NOT been updated. +- `\` is treated as a continuation character only outside of quotes +- `\` at end of a quoted string is treated as a literal character ## Memory Layout diff --git a/asm68.s b/asm68.s index 97a0ae4..a7960a3 100644 --- a/asm68.s +++ b/asm68.s @@ -264,6 +264,7 @@ isend *-------------------------------------------------------------------- nsrc clr qotflg * clear quote flag + clr cntflg * clear continuation flag * initialize current line = 0 ldx #-1 * init line number to -1 stx line @@ -291,15 +292,34 @@ nsrc bsr isend * check for ESC or EOT (end of input) beq .nsrc * return bsr iscom * check for comment character - bne .ntcom * if not comment, continue below + bne .cntchk * if not comment, check continuation bsr lincom * set up for line comment + bra .ntcom +*-------------------------------------------------------------------- +.cntchk cmpa #CONT * check for continuation char '\' + bne .ntcom * if not continuation, continue below + tst qotflg * in quote mode? + bne .ntcom * if in quotes, treat as regular character + ldaa #CR * continuation char at end of line + jsr ECHO * echo CR only, not backslash + bra .nxtch * continue reading (skip storing '\') +*-------------------------------------------------------------------- .ntcom cmpa #CR * end of line? bne .notcr * skip if not end of line + tst cntflg * check continuation flag + bne .cntcr * if continuing, handle below tst column * blank line? bne .ntblk * skip if not blank line ldaa #EMPTY * store blank line marker staa ,x inx +*-------------------------------------------------------------------- +* cntcr - Handle carriage return with continuation active +********************************************************************** +.cntcr clr cntflg * clear continuation flag + bsr newline * output newline + bra .nxtch * continue reading same line +*-------------------------------------------------------------------- .ntblk ldaa #NUL * ACC A = end-of-line marker (NUL) staa ,x * store here & pass to tokmne below inx @@ -309,13 +329,18 @@ nsrc *-------------------------------------------------------------------- .notcr cmpa #BSIN bne .notbs * if BS, delete typed characters... - ldx linptr * restore X (start of current line) + tst cntflg * check continuation flag + beq .bkspc * if not continuing, normal backspace + clr cntflg * else, clear continuation flag + bra .rdlin * and restart line input +*-------------------------------------------------------------------- +.bkspc ldx linptr * restore X (start of current line) inc column * column++ -.bkspc dec column * column-- +.bspcl dec column * column-- beq .rdlin * already at start of line? ldaa #BS * no, emit backspace character jsr ECHO - bra .bkspc * and loop + bra .bspcl * and loop *-------------------------------------------------------------------- .notbs bsr fldsp * check for field separator diff --git a/defs.s b/defs.s index e248146..1414feb 100644 --- a/defs.s +++ b/defs.s @@ -18,6 +18,7 @@ BSIN equ $5F * Apple-1 uses _ key as rubout HT equ $09 * ASCII horizontal tab CR equ $0D * ASCII carriage return ESC equ $1B * ASCII escape +CONT equ $5C * ASCII backslash (line continuation) _ equ $7F * we use $7F (DEL) as underscore @@ -83,7 +84,7 @@ opcptr equ $001E * (2 bytes) current opcode entry during search jmpbuf equ $0020 * (4 bytes) stack pointer (S) to restore * $24-$38 reserved by wozmon symoff equ $0039 * (1 byte) symbol definition offset -* $3A-$3B available +cntflg equ $003A * (1 byte) line continuation flag fwdrok equ $003C * (1 byte) forward ref allowed? column equ $003D * (1 byte) column index (n/l commands) mneitr equ $003E * (1 byte) mnemonic search pass count From 623d962d7fab5dfd2864f04d007503f5af3a9280 Mon Sep 17 00:00:00 2001 From: Jason Borgmann Date: Sat, 10 Jan 2026 23:26:29 -0600 Subject: [PATCH 3/3] Fixed a coulple issues AI created in the README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e5d281c..c092f15 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Unless otherwise specified, the assembler generally follows the source conventio ### Extensions -- ‘.’ may be used as PC +- `.` may be used as PC - `;` may be used instead of `*` to introduce comments - `\` may be used to continue a line @@ -67,6 +67,7 @@ Unless otherwise specified, the assembler generally follows the source conventio ### Unimplemented features +- `*` as PC in expressions - `@` octal prefix - `%` binary prefix - `$` in symbol name