Skip to content

Commit

Permalink
xas99: allow parentheses in @addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
endlos99 committed Feb 18, 2022
1 parent 3f0e9b7 commit 82ce1d2
Show file tree
Hide file tree
Showing 9 changed files with 218 additions and 160 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ For additional information, please refer to the [xdt99 homepage][1] or the
[xdt99 manual][4]. Windows users unfamiliar with working with the command line
will find some platform-specific information in the [Windows tutorial][5].

**Latest version: 3.3.2**
**Latest version: 3.4.0**

The latest binary distribution of xdt99 is available on the project
[releases page][2] on GitHub. xdt99 requires [Python 3.8][6] or higher and runs
Expand Down
8 changes: 4 additions & 4 deletions doc/MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -1518,10 +1518,10 @@ non-standard evaluation. These warnings can be disabled with option
`--quiet-arith`.

_Labels_ may be of arbitrary length and may contain arbitrary characters except
for whitespace and operators (`+-*/$#!@'"`). Labels not imported or exported by
`REF` or `DEF`, resp., may even be in Unicode. An optional colon `:` may be
appended to the label name. The colon is not part of the name, but logically
continues the current line to the next:
for whitespace and operators (`+-*/%$|&^~#!@'"`). Labels not imported or
exported by `REF` or `DEF`, resp., may even be in Unicode. An optional colon
`:` may be appended to the label name. The colon is not part of the name, but
logically continues the current line to the next:

my_label_1:
equ 1 ; assigns 1 to my_label_1 \
Expand Down
2 changes: 1 addition & 1 deletion test/as-checkerr.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def runtest():
source = os.path.join(Dirs.sources, 'asautoe.asm')
with open(Files.error, 'w') as ferr:
xas(source, '-R', '-o', Files.output, stderr=ferr, rc=1)
errs = re.findall('Auto-constant defined after AUTO directive', content(Files.error, 'r'))
errs = re.findall(r'Auto-constant defined after AUTO directive', content(Files.error, 'r'))
if len(errs) != 4:
error('misplaced auto-cons', 'Missing error about auto-cons after AUTO')

Expand Down
17 changes: 12 additions & 5 deletions test/as-checkext.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,21 +368,21 @@ def runtest():
with open(Files.error, 'w') as ferr:
xas(source, '-R', '--color', 'off', '-o', Files.output, stderr=ferr, rc=0)
expected = """> asxpragw.asm <2> 0005 - start clr 0 ; WARN
***** Warning: Treating as register, did you intend an @address?
***** Warning: Treating 0 as register, did you intend an @address?
> asxpragw.asm <2> 0010 - b @start ;: warn-opts = off, usage=on
***** Warning: Unknown pragma name
***** Warning: Unknown pragma name: USAGE
> asxpragw.asm <2> 0015 - seto 2 ; WARN ;: warn-usage=on, warn-opts=on
***** Warning: Treating as register, did you intend an @address?
***** Warning: Treating 2 as register, did you intend an @address?
""" # extra spaces for content_lines
if content_lines(Files.error) != expected:
error('pragmas', 'Incorrect warnings shown')

with open(Files.error, 'w') as ferr:
xas(source, '-R', '--color', 'off', '--quiet-usage', '-o', Files.output, stderr=ferr, rc=0) # no error
expected = """> asxpragw.asm <2> 0010 - b @start ;: warn-opts = off, usage=on
***** Warning: Unknown pragma name
***** Warning: Unknown pragma name: USAGE
> asxpragw.asm <2> 0015 - seto 2 ; WARN ;: warn-usage=on, warn-opts=on
***** Warning: Treating as register, did you intend an @address?
***** Warning: Treating 2 as register, did you intend an @address?
"""
if content_lines(Files.error) != expected:
error('pragmas', 'Incorrect warnings shown with --quiet-usage')
Expand All @@ -395,6 +395,13 @@ def runtest():
if len(content_line_array(Files.input)) != 13:
error('relaxed', 'Incorrect listing size')

# relaxed indexed addresses with parentheses
source = os.path.join(Dirs.sources, 'asrelidx.asm')
xas(source, '-R', '-q', '-o', Files.output)
ref = os.path.join(Dirs.sources, 'asrelidxr.asm')
xas(ref, '-R', '-o', Files.reference)
check_binary_files_eq('relindex', Files.output, Files.reference)

# cleanup
delfile(Dirs.tmp)

Expand Down
16 changes: 16 additions & 0 deletions test/asm/asrelidx.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
* relaxed indexed addresses

x equ >8300
work equ >83e0

; indexes
mov @x+2, @x
mov @work ^ x, @x(r2)
mov @(work), @x+2(r2)
c @work * 2 ( r1 ), @>1000 ( :101 )
ab @work + (2 * x ^ >3000) (r9), @7643 | (x + 2) (>a)

; expressions
c @x & (2 * work + >4), @work ^ x + ~ (r1 + 4 )

end
16 changes: 16 additions & 0 deletions test/asm/asrelidxr.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
* relaxed indexed addresses (reference)

x equ >8300
work equ >83e0

; indexes
mov @>8302, @>8300
mov @>e0, @>8300(r2)
mov @>83e0, @>8302(r2)
c @>07c0(r1), @>1000(r5)
ab @>b9e0(r9), @>9fdb(r10)

; expressions
c @>0300, @>00da

end
249 changes: 125 additions & 124 deletions test/asm/asxerrs.asm
Original file line number Diff line number Diff line change
@@ -1,124 +1,125 @@
* ERROR HANDLING: xdt99 extensions

idt 'ASXERRS'

; include_path and binary include_path

txtinc copy "nonexisting" ;ERROR
bininc bcopy "nonexisting" ;ERROR

; text bytes

text1 text >123456
text >12x34 ;ERROR

; arg count

* rtwp r1 ; cannt detect this: r1 is comment
* nop @1 ; ditto
inc r1, r2 ;ERROR
byte ;ERROR
text ;ERROR
mov r1 ;ERROR

; label continuations

label1:
label2: ;ERROR
clr 0

label3:
clr 0
label3 clr 1 ;ERROR

label4 clr 0
label4:
clr 1 ;ERROR

; .if/.endif nesting

.ifeq 1, 1
data 1
.else
data 2
.else ;ERROR
data 3
.endif

.else ;ERROR
.endif ;ERROR

.ifeq 1, 1
.else
.ifne 1, 2
.endif
.else ;ERROR
.endif
; macros

.defm mac1
.endm
.defm mac1 ;ERROR
.endm ; required, as assembly continues

.defm mac2
clr #2 ;ERROR:0001
.endm
.mac2 1 ; error reported on actual line

.macX ;ERROR

.defm mac3
.defm mac4 ;ERROR
.endm

; weak symbols
w1:
wequ 1
s2:
equ 2
w1:
equ 2 ;OK
w1:
equ 1 ;ERROR
w1:
equ 1 ;ERROR

; 9995 and F18A not available without -5 or -18

nnn lst r0 ;ERROR
lwp r1 ;ERROR
divs r2 ;ERROR
mpys *r3+ ;ERROR

call *r1 ;ERROR
push @nnn ;ERROR
pop r1 ;ERROR
slc r4, 9 ;ERROR

; hints for incorrect use
uuu b uuu ;ERROR
jmp @uuu ;ERROR
inc 9 ;OK, is warning only

; auto-constants

a w#text1, 0 ;ERROR
a w#w#1, 0 ;ERROR
a b#1 + text1, 0 ;ERROR
a 1 + w#1, 0 ;ERROR
a (w#1) + 1, 0 ;ERROR

; incorrect use of operands

coc @nnn, @uuu ;ERROR
coc @nnn, w1 ;OK

* NO ERRORS

good1:
; comment
clr 0

end
* ERROR HANDLING: xdt99 extensions

idt 'ASXERRS'

; include_path and binary include_path

txtinc copy "nonexisting" ;ERROR
bininc bcopy "nonexisting" ;ERROR

; text bytes

text1 text >123456
text >12x34 ;ERROR

; arg count

* rtwp r1 ; cannt detect this: r1 is comment
* nop @1 ; ditto
inc r1, r2 ;ERROR
byte ;ERROR
text ;ERROR
mov r1 ;ERROR

; label continuations

label1:
label2: ;ERROR
clr 0

label3:
clr 0
label3 clr 1 ;ERROR

label4 clr 0
label4:
clr 1 ;ERROR

; .if/.endif nesting

.ifeq 1, 1
data 1
.else
data 2
.else ;ERROR
data 3
.endif

.else ;ERROR
.endif ;ERROR

.ifeq 1, 1
.else
.ifne 1, 2
.endif
.else ;ERROR
.endif

; macros

.defm mac1
.endm
.defm mac1 ;ERROR
.endm ; required, as assembly continues

.defm mac2
clr #2 ;ERROR:0001
.endm
.mac2 1 ; error reported on actual line

.macX ;ERROR

.defm mac3
.defm mac4 ;ERROR
.endm

; weak symbols
w1:
wequ 1
s2:
equ 2
w1:
equ 2 ;OK
w1:
equ 1 ;ERROR
w1:
equ 1 ;ERROR

; 9995 and F18A not available without -5 or -18

nnn lst r0 ;ERROR
lwp r1 ;ERROR
divs r2 ;ERROR
mpys *r3+ ;ERROR

call *r1 ;ERROR
push @nnn ;ERROR
pop r1 ;ERROR
slc r4, 9 ;ERROR

; hints for incorrect use
uuu b uuu ;ERROR
jmp @uuu ;ERROR
inc 9 ;OK, is warning only

; auto-constants

a w#text1, 0 ;ERROR
a w#w#1, 0 ;ERROR
a b#1 + text1, 0 ;ERROR
a 1 + w#1, 0 ;ERROR
a (w#1) + 1, 0 ;ERROR

; incorrect use of operands

coc @nnn, @uuu ;ERROR
coc @nnn, w1 ;OK


* NO ERRORS

good1:
; comment
clr 0

end
14 changes: 7 additions & 7 deletions test/basic/nim_labels.bas
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ TURN:
PRINT "THERE ARE";N;"COINS LEFT"
HOWMANY:
INPUT "TAKE HOW MANY (1-3)? ":M
IF (M<1)+(M>3)THEN @HOWMANY
IF (M<1)+(M>3)THEN HOWMANY
N=N-M
PRINT "THERE ARE";N;"COINS LEFT"
IF N=0 THEN @YOUWIN
IF N=0 THEN YOUWIN
M=N-INT(N/4)*4
IF M<>0 THEN @OKCHOICE
IF M<>0 THEN OKCHOICE
M=1
OKCHOICE:
N=N-M
PRINT "I TAKE";M;"COINS"
IF N=0 THEN @IWIN
GOTO @TURN
IF N=0 THEN IWIN
GOTO TURN
YOUWIN:
PRINT "CONGRATULATIONS, YOU WIN!"
GOTO @AGAIN
GOTO AGAIN
IWIN:
PRINT "I WIN!"
AGAIN:
INPUT "TRY AGAIN (Y/N) ":A$
IF A$="Y" THEN @RESTART
IF A$="Y" THEN RESTART
PRINT "SEE YOU NEXT TIME"
END
Loading

0 comments on commit 82ce1d2

Please sign in to comment.