1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2024-07-05 04:28:57 +00:00

Fix reverse copy off-by-one bug in memcpy

This commit is contained in:
David Schmenk 2014-11-21 20:22:18 -08:00
parent 80646542ee
commit 06c087751b
4 changed files with 24 additions and 19 deletions

View File

@ -167,7 +167,7 @@ const CLOSE_BRACKET_TKN = $DD // ]
// Misc. tokens // Misc. tokens
// //
const COMMA_TKN = $AC // , const COMMA_TKN = $AC // ,
const COMMENT_TKN = $BB // // //const COMMENT_TKN = $BB // //
// //
// Keyword tokens // Keyword tokens
// //
@ -601,10 +601,12 @@ REVCPY ;CLC
LDA ESTKH-2,X LDA ESTKH-2,X
ADC ESTKH-1,X ADC ESTKH-1,X
STA SRCH STA SRCH
INC ESTKH-2,X
DEC DSTH DEC DSTH
DEC SRCH DEC SRCH
LDY #$FF LDY #$FF
LDA ESTKL-2,X
BEQ REVCPYLP
INC ESTKH-2,X
REVCPYLP LDA (SRC),Y REVCPYLP LDA (SRC),Y
STA (DST),Y STA (DST),Y
DEY DEY
@ -2568,7 +2570,7 @@ def scan
// //
// Skip whitespace // Skip whitespace
// //
while ^scanptr and ^scanptr <= ' ' while ^scanptr == ' '
scanptr = scanptr + 1 scanptr = scanptr + 1
loop loop
tknptr = scanptr tknptr = scanptr
@ -2602,7 +2604,7 @@ def scan
// //
// Hexadecimal constant // Hexadecimal constant
// //
token = INT_TKN// token = INT_TKN
constval = 0 constval = 0
repeat repeat
scanptr = scanptr + 1 scanptr = scanptr + 1
@ -2712,8 +2714,8 @@ def scan
break break
is '/' is '/'
if ^(scanptr + 1) == '/' if ^(scanptr + 1) == '/'
token = EOL_TKN token = EOL_TKN
scanptr = scanptr + 2 ^scanptr = $00
else else
token = DIV_TKN token = DIV_TKN
scanptr = scanptr + 1 scanptr = scanptr + 1
@ -2775,7 +2777,6 @@ def nextln
else else
^instr = 0 ^instr = 0
^inbuff = 0 ^inbuff = 0
scanptr = inbuff
token = DONE_TKN token = DONE_TKN
fin fin
fin fin
@ -3504,7 +3505,6 @@ def parse_stmnt
emit_leave emit_leave
break break
is EOL_TKN is EOL_TKN
is COMMENT_TKN
return TRUE return TRUE
is ELSE_TKN is ELSE_TKN
is ELSEIF_TKN is ELSEIF_TKN
@ -3703,7 +3703,6 @@ def parse_vars
until scan <> COMMA_TKN until scan <> COMMA_TKN
break break
is EOL_TKN is EOL_TKN
is COMMENT_TKN
return TRUE return TRUE
otherwise otherwise
return FALSE return FALSE
@ -3729,13 +3728,13 @@ def parse_defs
retfunc_tag = ctag_new retfunc_tag = ctag_new
idlocal_init idlocal_init
if scan == OPEN_PAREN_TKN if scan == OPEN_PAREN_TKN
repeat repeat
if scan == ID_TKN if scan == ID_TKN
cfnparms = cfnparms + 1 cfnparms = cfnparms + 1
idlocal_add(tknptr, tknlen, WORD_TYPE, 2) idlocal_add(tknptr, tknlen, WORD_TYPE, 2)
scan scan
fin fin
until token <> COMMA_TKN until token <> COMMA_TKN
if token <> CLOSE_PAREN_TKN if token <> CLOSE_PAREN_TKN
return parse_err(@bad_decl) return parse_err(@bad_decl)
fin fin
@ -3751,13 +3750,13 @@ def parse_defs
loop loop
infunc = FALSE infunc = FALSE
if token <> END_TKN; return parse_err(@bad_syntax); fin if token <> END_TKN; return parse_err(@bad_syntax); fin
if scan <> EOL_TKN and token <> COMMENT_TKN; return parse_err(@bad_syntax); fin if scan <> EOL_TKN; return parse_err(@bad_syntax); fin
if prevstmnt <> RETURN_TKN if prevstmnt <> RETURN_TKN
emit_const(0) emit_const(0)
emit_leave emit_leave
fin fin
return TRUE return TRUE
elsif token == EOL_TKN or token == COMMENT_TKN elsif token == EOL_TKN
return TRUE return TRUE
fin fin
return FALSE return FALSE

View File

@ -243,10 +243,12 @@ REVCPY ;CLC
LDA ESTKH-2,X LDA ESTKH-2,X
ADC ESTKH-1,X ADC ESTKH-1,X
STA SRCH STA SRCH
INC ESTKH-2,X
DEC DSTH DEC DSTH
DEC SRCH DEC SRCH
LDY #$FF LDY #$FF
LDA ESTKL-2,X
BEQ REVCPYLP
INC ESTKH-2,X
REVCPYLP LDA (SRC),Y REVCPYLP LDA (SRC),Y
STA (DST),Y STA (DST),Y
DEY DEY

View File

@ -267,10 +267,12 @@ REVCPY ;CLC
LDA ESTKH-2,X LDA ESTKH-2,X
ADC ESTKH-1,X ADC ESTKH-1,X
STA SRCH STA SRCH
INC ESTKH-2,X
DEC DSTH DEC DSTH
DEC SRCH DEC SRCH
LDY #$FF LDY #$FF
LDA ESTKL-2,X
BEQ REVCPYLP
INC ESTKH-2,X
REVCPYLP LDA (SRC),Y REVCPYLP LDA (SRC),Y
STA (DST),Y STA (DST),Y
DEY DEY

View File

@ -244,10 +244,12 @@ REVCPY ;CLC
LDA ESTKH-2,X LDA ESTKH-2,X
ADC ESTKH-1,X ADC ESTKH-1,X
STA SRCH STA SRCH
INC ESTKH-2,X
DEC DSTH DEC DSTH
DEC SRCH DEC SRCH
LDY #$FF LDY #$FF
LDA ESTKL-2,X
BEQ REVCPYLP
INC ESTKH-2,X
REVCPYLP LDA (SRC),Y REVCPYLP LDA (SRC),Y
STA (DST),Y STA (DST),Y
DEY DEY