Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -71,7 +72,6 @@ Unless otherwise specified, the assembler generally follows the source conventio
- `%` binary prefix
- `$` in symbol name
- `.` in middle of symbol name
- `\` line continuation character
- signed arithmetic, greater than 16 bits
- forward references in FCB directives.

Expand All @@ -84,6 +84,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

Expand Down
33 changes: 29 additions & 4 deletions asm68.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion defs.s
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions tests/cnttst.s
Original file line number Diff line number Diff line change
@@ -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)
Loading