Skip to content

Commit

Permalink
fixes #27 COMPILE handles CALLR incorrectly
Browse files Browse the repository at this point in the history
  • Loading branch information
TG9541 committed Jun 15, 2017
1 parent c2ee779 commit 065744e
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions forth.asm
Expand Up @@ -4105,14 +4105,33 @@ BCOMP:
.ascii "COMPILE"
.endif
COMPI:
CALL RFROM
CALL ONEP
CALL DUPP
CALL AT
CALLR JSRC ; compile subroutine
CALL CELLP
CALL TOR ; this was a JP - a serious bug that took a while to find
RET
EXGW X,Y
POPW X
LD A,(X)
INCW X
CP A,#CALL_OPC
JRNE COMPIO1
LDW YTEMP,X ; COMPILE CALL address
INCW X
INCW X
PUSHW X
LDW X,[YTEMP]
JRA COMPIO2
COMPIO1:
LD A,(X) ; COMPILE CALLR offset
INCW X
PUSHW X ; return address
CLRW X ; offset i8_t to i16_t
TNZ A
JRPL 1$
DECW X
1$: LD XL,A
ADDW X,(1,SP) ; add offset in X to address of next instruction
COMPIO2:
EXGW X,Y
CALL YSTOR
JRA JSRC ; compile subroutine


; $," ( -- )
; Compile a literal string
Expand Down Expand Up @@ -4600,7 +4619,7 @@ RBRAC:
.ascii "DOES>"
DOESS:
CALL COMPI
CALL DODOES ; 3 CALL dodoes>
CALLR DODOES ; 3 CALL dodoes>
CALL HERECP
.ifne USE_CALLDOLIT
DoLitC 9
Expand Down

0 comments on commit 065744e

Please sign in to comment.