Assembler: a string that spells an instruction is no longer assembled as one
A token is classified after its quotes have been stripped, so a string literal reading "ADD" looked exactly like the ADD instruction and was assembled as one. It failed with "attempting to assemble outside the Program Segment", a message about a mistake nobody had made. The literal and label checks were already guarded against strings and the instruction check was not. Mnemonics match without regard to case, so "or" and "and" were caught by this too, and those are ordinary enough words to want in a message. Third of its family, after a string beginning with '0' being read as a malformed number and a string in the Program Segment being silently discarded. All three have the same root. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
ca34e077ad
commit
be402cc9be
@@ -0,0 +1,49 @@
|
||||
; A string whose text spells an instruction.
|
||||
;
|
||||
; The quotes are gone by the time the assembler looks at a token, so a string reading "ADD"
|
||||
; used to be assembled as the ADD instruction - which failed with "attempting to assemble
|
||||
; outside the Program Segment", a message about a mistake nobody had made. Mnemonics match
|
||||
; without regard to case, so "or" and "and" were caught by it too, and those are ordinary
|
||||
; enough words to want in a message.
|
||||
;
|
||||
; Correct output is:
|
||||
; ADD OR and NOP
|
||||
|
||||
#Include console.asm
|
||||
|
||||
#Program
|
||||
|
||||
start:
|
||||
SETD.0 First
|
||||
CALL printString
|
||||
CALL blank
|
||||
SETD.0 Second
|
||||
CALL printString
|
||||
CALL blank
|
||||
SETD.0 Third
|
||||
CALL printString
|
||||
CALL blank
|
||||
SETD.0 Fourth
|
||||
CALL printString
|
||||
CALL newLine
|
||||
HALT
|
||||
|
||||
blank:
|
||||
INIA 0x20
|
||||
OUTA 0x00
|
||||
RET
|
||||
|
||||
#Data
|
||||
|
||||
First:
|
||||
"ADD"
|
||||
Second:
|
||||
"OR"
|
||||
Third:
|
||||
"and"
|
||||
Fourth:
|
||||
"NOP"
|
||||
|
||||
#Vectors
|
||||
|
||||
Boot start
|
||||
Reference in New Issue
Block a user