1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-03-21 10:31:15 +00:00

Better FOR/NEXT ops

This commit is contained in:
Dave Schmenk 2018-03-02 21:43:09 -08:00
parent 8f408c8bbb
commit 40c3dcd197
8 changed files with 292 additions and 142 deletions

@ -769,12 +769,12 @@ void emit_brnch(int tag)
printf("\t%s\t$50\t\t\t; BRNCH\t_B%03d\n", DB, tag);
printf("\t%s\t_B%03d-*\n", DW, tag);
}
void emit_breq(int tag)
{
emit_pending_seq();
printf("\t%s\t$3C\t\t\t; BREQ\t_B%03d\n", DB, tag);
printf("\t%s\t_B%03d-*\n", DW, tag);
}
//void emit_breq(int tag)
//{
// emit_pending_seq();
// printf("\t%s\t$3C\t\t\t; BREQ\t_B%03d\n", DB, tag);
// printf("\t%s\t_B%03d-*\n", DW, tag);
//}
void emit_brne(int tag)
{
emit_pending_seq();
@ -793,6 +793,30 @@ void emit_brlt(int tag)
printf("\t%s\t$3A\t\t\t; BRLT\t_B%03d\n", DB, tag);
printf("\t%s\t_B%03d-*\n", DW, tag);
}
void emit_nxtup(int tag)
{
emit_pending_seq();
printf("\t%s\t$32\t\t\t; NXTUP\t_B%03d\n", DB, tag);
printf("\t%s\t_B%03d-*\n", DW, tag);
}
void emit_inxtup(int tag)
{
emit_pending_seq();
printf("\t%s\t$34\t\t\t; INXTUP\t_B%03d\n", DB, tag);
printf("\t%s\t_B%03d-*\n", DW, tag);
}
void emit_nxtdn(int tag)
{
emit_pending_seq();
printf("\t%s\t$3C\t\t\t; NXTDN\t_B%03d\n", DB, tag);
printf("\t%s\t_B%03d-*\n", DW, tag);
}
void emit_dnxtdn(int tag)
{
emit_pending_seq();
printf("\t%s\t$52\t\t\t; DNXTDN\t_B%03d\n", DB, tag);
printf("\t%s\t_B%03d-*\n", DW, tag);
}
void emit_call(int tag, int type)
{
if (type == CONST_TYPE)
@ -841,10 +865,6 @@ void emit_drop(void)
emit_pending_seq();
printf("\t%s\t$30\t\t\t; DROP\n", DB);
}
void emit_dup(void)
{
printf("\t%s\t$32\t\t\t; DUP\n", DB);
}
int emit_unaryop(t_token op)
{
emit_pending_seq();
@ -1656,9 +1676,6 @@ int emit_pending_seq()
case DROP_CODE:
emit_drop();
break;
case DUP_CODE:
emit_dup();
break;
case BRNCH_CODE:
emit_brnch(op->tag);
break;

@ -132,9 +132,12 @@ void emit_brgt(int tag);
void emit_brlt(int tag);
void emit_brne(int tag);
void emit_brnch(int tag);
void emit_nxtup(int tag);
void emit_inxtup(int tag);
void emit_nxtdn(int tag);
void emit_dnxtdn(int tag);
void emit_empty(void);
void emit_drop(void);
void emit_dup(void);
void emit_leave(void);
void emit_ret(void);
void emit_enter(int cparams);

@ -171,6 +171,16 @@ def emit_daw(tag, offset)#0
emit_byte($7E)
emit_addr(tag, offset)
end
def emit_brne(tag)#0
emit_pending_seq
emit_byte($3E)
emit_reladdr(tag)
end
def emit_branch(tag)#0
emit_pending_seq
emit_byte($50)
emit_reladdr(tag)
end
def emit_brgt(tag)#0
emit_pending_seq
emit_byte($38)
@ -181,14 +191,24 @@ def emit_brlt(tag)#0
emit_byte($3A)
emit_reladdr(tag)
end
def emit_brne(tag)#0
def emit_nxtup(tag)#0
emit_pending_seq
emit_byte($3E)
emit_byte($32)
emit_reladdr(tag)
end
def emit_branch(tag)#0
def emit_inxtup(tag)#0
emit_pending_seq
emit_byte($50)
emit_byte($34)
emit_reladdr(tag)
end
def emit_nxtdn(tag)#0
emit_pending_seq
emit_byte($3C)
emit_reladdr(tag)
end
def emit_dnxtdn(tag)#0
emit_pending_seq
emit_byte($52)
emit_reladdr(tag)
end
def emit_leave#0

@ -129,7 +129,7 @@ def crunch_seq(seq, pass)
if not op=>opval
op->opcode = LOGIC_NOT_CODE // Replace ZERO:ISEQ
op->opgroup = STACK_GROUP
freeops = 1
freeops = 1
fin
break
is CONST_CODE // Collapse constant operation

@ -5,7 +5,7 @@
#define RVALUE 1
#define MAX_LAMBDA 64
int infunc = 0, break_tag = 0, cont_tag = 0, stack_loop = 0;
int infunc = 0, break_tag = 0, cont_tag = 0, stack_loop = 0, for_loop = 0;
long infuncvals = 0;
t_token prevstmnt;
static int lambda_num = 0;
@ -798,9 +798,9 @@ t_opseq *parse_set(t_opseq *codeseq)
int parse_stmnt(void)
{
int tag_prevbrk, tag_prevcnt, tag_else, tag_endif, tag_while, tag_wend, tag_repeat, tag_for, tag_choice, tag_of;
int type, addr, step, cfnvals;
int type, addr, step, cfnvals, prev_forlp;
char *idptr;
t_opseq *seq;
t_opseq *seq, *fromseq, *toseq;
/*
* Optimization for last function LEAVE and OF clause.
@ -856,6 +856,8 @@ int parse_stmnt(void)
parse_error("Missing IF/FIN");
break;
case WHILE_TOKEN:
prev_forlp = for_loop;
for_loop = 0;
tag_while = tag_new(BRANCH_TYPE);
tag_wend = tag_new(BRANCH_TYPE);
tag_prevcnt = cont_tag;
@ -879,8 +881,11 @@ int parse_stmnt(void)
emit_codetag(tag_wend);
break_tag = tag_prevbrk;
cont_tag = tag_prevcnt;
for_loop = prev_forlp;
break;
case REPEAT_TOKEN:
prev_forlp = for_loop;
for_loop = 0;
tag_prevbrk = break_tag;
break_tag = tag_new(BRANCH_TYPE);
tag_repeat = tag_new(BRANCH_TYPE);
@ -904,48 +909,43 @@ int parse_stmnt(void)
emit_seq(seq);
emit_codetag(break_tag);
break_tag = tag_prevbrk;
for_loop = prev_forlp;
break;
case FOR_TOKEN:
stack_loop++;
prev_forlp = for_loop;
for_loop = 1;
stack_loop += 2;
tag_prevbrk = break_tag;
break_tag = tag_new(BRANCH_TYPE);
tag_for = tag_new(BRANCH_TYPE);
tag_prevcnt = cont_tag;
cont_tag = tag_for;
cont_tag = tag_new(BRANCH_TYPE);
if (scan() != ID_TOKEN)
parse_error("Missing FOR variable");
type = id_type(tokenstr, tokenlen);
addr = id_tag(tokenstr, tokenlen);
if (scan() != SET_TOKEN)
parse_error("Missing FOR =");
if (!(seq = parse_expr(NULL, &cfnvals)))
if (!(fromseq = parse_expr(NULL, &cfnvals)))
parse_error("Bad FOR expression");
if (cfnvals > 1)
{
parse_warn("Expression value overflow");
while (cfnvals-- > 1) seq = gen_drop(seq);
}
emit_seq(seq);
emit_codetag(tag_for);
if (type & LOCAL_TYPE)
type & BYTE_TYPE ? emit_dlb(addr) : emit_dlw(addr);
else
type & BYTE_TYPE ? emit_dab(addr, 0, type) : emit_daw(addr, 0, type);
if (scantoken == TO_TOKEN)
step = 1;
else if (scantoken == DOWNTO_TOKEN)
step = -1;
else
parse_error("Missing FOR TO");
if (!(seq = parse_expr(NULL, &cfnvals)))
if (!(toseq = parse_expr(NULL, &cfnvals)))
parse_error("Bad FOR TO expression");
if (cfnvals > 1)
{
parse_warn("Expression value overflow");
while (cfnvals-- > 1) seq = gen_drop(seq);
}
emit_seq(seq);
step > 0 ? emit_brgt(break_tag) : emit_brlt(break_tag);
if (scantoken == STEP_TOKEN)
{
if (!(seq = parse_expr(NULL, &cfnvals)))
@ -955,22 +955,54 @@ int parse_stmnt(void)
parse_warn("Expression value overflow");
while (cfnvals-- > 1) seq = gen_drop(seq);
}
emit_seq(seq);
emit_op(step > 0 ? ADD_TOKEN : SUB_TOKEN);
}
else
emit_unaryop(step > 0 ? INC_TOKEN : DEC_TOKEN);
{
seq = NULL;
}
emit_seq(toseq);
emit_seq(fromseq);
step > 0 ? emit_brgt(break_tag) : emit_brlt(break_tag);
emit_codetag(tag_for);
if (type & LOCAL_TYPE)
type & BYTE_TYPE ? emit_dlb(addr) : emit_dlw(addr);
else
type & BYTE_TYPE ? emit_dab(addr, 0, type) : emit_daw(addr, 0, type);
while (parse_stmnt()) next_line();
if (scantoken != NEXT_TOKEN)
parse_error("Missing FOR/NEXT");
emit_brnch(tag_for);
emit_codetag(cont_tag);
cont_tag = tag_prevcnt;
if (step > 0)
{
if (seq)
{
emit_seq(seq);
emit_op(ADD_TOKEN);
emit_nxtup(tag_for);
}
else
emit_inxtup(tag_for);
}
else
{
if (seq)
{
emit_seq(seq);
emit_op(SUB_TOKEN);
emit_nxtdn(tag_for);
}
else
emit_dnxtdn(tag_for);
}
emit_codetag(break_tag);
emit_drop();
break_tag = tag_prevbrk;
stack_loop--;
break_tag = tag_prevbrk;
stack_loop -= 2;
for_loop = prev_forlp;
break;
case CASE_TOKEN:
prev_forlp = for_loop;
for_loop = 0;
stack_loop++;
tag_prevbrk = break_tag;
break_tag = tag_new(BRANCH_TYPE);
@ -1026,10 +1058,18 @@ int parse_stmnt(void)
emit_drop();
break_tag = tag_prevbrk;
stack_loop--;
for_loop = prev_forlp;
break;
case BREAK_TOKEN:
if (break_tag)
{
if (for_loop)
{
emit_drop();
emit_drop();
}
emit_brnch(break_tag);
}
else
parse_error("BREAK without loop");
break;

@ -587,8 +587,8 @@ def parse_set(codeseq)
return codeseq
end
def parse_stmnt
byte type, elem_type, elem_size, i, cfnvals
word seq, tag_prevbrk, tag_prevcnt, tag_else, tag_endif, tag_while, tag_wend
byte type, elem_type, elem_size, i, cfnvals, prev_forlp
word seq, fromseq, toseq, tag_prevbrk, tag_prevcnt, tag_else, tag_endif, tag_while, tag_wend
word tag_repeat, tag_for, tag_choice, tag_of, idptr, addr, stepdir
if token <> END_TKN and token <> DONE_TKN and token <> OF_TKN and token <> DEFAULT_TKN
@ -640,6 +640,8 @@ def parse_stmnt
if token <> FIN_TKN; exit_err(ERR_MISS|ERR_CLOSE|ERR_STATE); fin
break
is WHILE_TKN
prev_forlp = for_loop
for_loop = FALSE
tag_while = new_tag(RELATIVE_FIXUP)
tag_wend = new_tag(RELATIVE_FIXUP)
tag_prevcnt = cont_tag
@ -663,8 +665,11 @@ def parse_stmnt
emit_tag(tag_wend)
break_tag = tag_prevbrk
cont_tag = tag_prevcnt
for_loop = prev_forlp
break
is REPEAT_TKN
prev_forlp = for_loop
for_loop = FALSE
tag_repeat = new_tag(RELATIVE_FIXUP)
tag_prevbrk = break_tag
break_tag = new_tag(RELATIVE_FIXUP)
@ -688,12 +693,15 @@ def parse_stmnt
emit_seq(seq)
emit_tag(break_tag)
break_tag = tag_prevbrk
for_loop = prev_forlp
break
is FOR_TKN
stack_loop++
prev_forlp = for_loop
for_loop = TRUE
stack_loop = stack_loop + 2
tag_for = new_tag(RELATIVE_FIXUP)
tag_prevcnt = cont_tag
cont_tag = tag_for
cont_tag = new_tag(RELATIVE_FIXUP)
tag_prevbrk = break_tag
break_tag = new_tag(RELATIVE_FIXUP)
if scan <> ID_TKN; exit_err(ERR_MISS|ERR_ID); fin
@ -705,19 +713,12 @@ def parse_stmnt
exit_err(ERR_INVAL|ERR_ID)
fin
if scan <> SET_TKN; exit_err(ERR_INVAL|ERR_STATE); fin
seq, cfnvals = parse_expr(NULL)
if !seq; exit_err(ERR_INVAL|ERR_STATE); fin
fromseq, cfnvals = parse_expr(NULL)
if !fromseq; exit_err(ERR_INVAL|ERR_STATE); fin
if cfnvals > 1
parse_warn("Expression value overflow")
while cfnvals > 1;cfnvals--; seq = gen_op(seq, DROP_CODE); loop
fin
emit_seq(seq)
emit_tag(tag_for)
if type & LOCAL_TYPE
if type & BYTE_TYPE; emit_dlb(addr); else; emit_dlw(addr); fin
else
if type & BYTE_TYPE; emit_dab(addr, 0); else; emit_daw(addr, 0); fin
fin
if token == TO_TKN
stepdir = 1
elsif token == DOWNTO_TKN
@ -725,14 +726,12 @@ def parse_stmnt
else
exit_err(ERR_INVAL|ERR_STATE)
fin
seq, cfnvals = parse_expr(NULL)
if !seq; exit_err(ERR_INVAL|ERR_STATE); fin
toseq, cfnvals = parse_expr(NULL)
if !toseq; exit_err(ERR_INVAL|ERR_STATE); fin
if cfnvals > 1
parse_warn("Expression value overflow")
while cfnvals > 1;cfnvals--; seq = gen_op(seq, DROP_CODE); loop
fin
emit_seq(seq)
if stepdir > 0; emit_brgt(break_tag); else; emit_brlt(break_tag); fin
if token == STEP_TKN
seq, cfnvals = parse_expr(NULL)
if !seq; exit_err(ERR_INVAL|ERR_STATE); fin
@ -740,23 +739,51 @@ def parse_stmnt
parse_warn("Expression value overflow")
while cfnvals > 1;cfnvals--; seq = gen_op(seq, DROP_CODE); loop
fin
emit_seq(seq)
emit_code(stepdir > 0 ?? ADD_CODE :: SUB_CODE)
else
emit_code(stepdir > 0 ?? INC_CODE :: DEC_CODE)
seq = NULL
fin
emit_seq(toseq)
emit_seq(fromseq)
if stepdir > 0; emit_brgt(break_tag); else; emit_brlt(break_tag); fin
emit_tag(tag_for)
if type & LOCAL_TYPE
if type & BYTE_TYPE; emit_dlb(addr); else; emit_dlw(addr); fin
else
if type & BYTE_TYPE; emit_dab(addr, 0); else; emit_daw(addr, 0); fin
fin
while parse_stmnt
nextln
loop
if token <> NEXT_TKN; exit_err(ERR_MISS|ERR_CLOSE|ERR_STATE); fin
emit_branch(tag_for)
emit_tag(cont_tag)
cont_tag = tag_prevcnt
if stepdir > 0
if seq
emit_seq(seq)
emit_code(ADD_CODE)
emit_nxtup(tag_for)
else
emit_inxtup(tag_for)
fin
else
if seq
emit_seq(seq)
emit_code(SUB_CODE)
emit_nxtdn(tag_for)
else
emit_dnxtdn(tag_for)
fin
fin
emit_tag(break_tag)
emit_code(DROP_CODE)
break_tag = tag_prevbrk
stack_loop--
break_tag = tag_prevbrk
stack_loop = stack_loop - 2
for_loop = prev_forlp
break
is CASE_TKN
prev_forlp = for_loop
for_loop = FALSE
stack_loop++
tag_prevbrk = break_tag
break_tag = new_tag(RELATIVE_FIXUP)
@ -815,9 +842,14 @@ def parse_stmnt
emit_code(DROP_CODE)
break_tag = tag_prevbrk
stack_loop--
for_loop = prev_forlp
break
is BREAK_TKN
if break_tag
if for_loop
emit_code(DROP_CODE)
emit_code(DROP_CODE)
fin
emit_branch(break_tag)
else
exit_err(ERR_INVAL|ERR_STATE)

@ -300,6 +300,7 @@ word strconstbuff
word strconstptr
byte infunc, inlambda
byte stack_loop
byte for_loop
byte prevstmnt
word infuncvals
word break_tag

@ -193,12 +193,14 @@ VMCORE = *
;* *
;****************
!ALIGN 255,0
;OPTBL !WORD CONST,CONST,CONST,CONST,CONST,CONST,CONST,CONST ; 00 02 04 06 08 0A 0C 0E
; !WORD CONST,CONST,CONST,CONST,CONST,CONST,CONST,CONST ; 10 12 14 16 18 1A 1C 1E
OPTBL !WORD ZERO,ADD,SUB,MUL,DIV,MOD,INCR,DECR ; 00 02 04 06 08 0A 0C 0E
!WORD NEG,COMP,BAND,IOR,XOR,SHL,SHR,IDXW ; 10 12 14 16 18 1A 1C 1E
!WORD LNOT,LOR,LAND,LA,LLA,CB,CW,CS ; 20 22 24 26 28 2A 2C 2E
!WORD DROP,DUP,NEXTOP,DIVMOD,BRGT,BRLT,BREQ,BRNE ; 30 32 34 36 38 3A 3C 3E
!WORD DROP,NXTUP,INXTUP,DIVMOD,BRGT,BRLT,NXTDN,BRNE ; 30 32 34 36 38 3A 3C 3E
!WORD ISEQ,ISNE,ISGT,ISLT,ISGE,ISLE,BRFLS,BRTRU ; 40 42 44 46 48 4A 4C 4E
!WORD BRNCH,IBRNCH,CALL,ICAL,ENTER,LEAVE,RET,CFFB ; 50 52 54 56 58 5A 5C 5E
!WORD BRNCH,DNXTDN,CALL,ICAL,ENTER,LEAVE,RET,CFFB ; 50 52 54 56 58 5A 5C 5E
!WORD LB,LW,LLB,LLW,LAB,LAW,DLB,DLW ; 60 62 64 66 68 6A 6C 6E
!WORD SB,SW,SLB,SLW,SAB,SAW,DAB,DAW ; 70 72 74 76 78 7A 7C 7E
;*
@ -400,12 +402,14 @@ LCDEFCMD = *-28 ; DEFCMD IN LC MEMORY
;* *
;*****************
!ALIGN 255,0
;OPXTBL !WORD CONST,CONST,CONST,CONST,CONST,CONST,CONST,CONST ; 00 02 04 06 08 0A 0C 0E
; !WORD CONST,CONST,CONST,CONST,CONST,CONST,CONST,CONST ; 10 12 14 16 18 1A 1C 1E
OPXTBL !WORD ZERO,ADD,SUB,MUL,DIV,MOD,INCR,DECR ; 00 02 04 06 08 0A 0C 0E
!WORD NEG,COMP,BAND,IOR,XOR,SHL,SHR,IDXW ; 10 12 14 16 18 1A 1C 1E
!WORD LNOT,LOR,LAND,LA,LLA,CB,CW,CSX ; 20 22 24 26 28 2A 2C 2E
!WORD DROP,DUP,NEXTOP,DIVMOD,BRGT,BRLT,BREQ,BRNE ; 30 32 34 36 38 3A 3C 3E
!WORD DROP,NXTUP,INXTUP,DIVMOD,BRGT,BRLT,NXTDN,BRNE ; 30 32 34 36 38 3A 3C 3E
!WORD ISEQ,ISNE,ISGT,ISLT,ISGE,ISLE,BRFLS,BRTRU ; 40 42 44 46 48 4A 4C 4E
!WORD BRNCH,IBRNCH,CALLX,ICALX,ENTER,LEAVEX,RETX,CFFB; 50 52 54 56 58 5A 5C 5E
!WORD BRNCH,DNXTDN,CALLX,ICALX,ENTER,LEAVEX,RETX,CFFB ; 50 52 54 56 58 5A 5C 5E
!WORD LBX,LWX,LLBX,LLWX,LABX,LAWX,DLB,DLW ; 60 62 64 66 68 6A 6C 6E
!WORD SB,SW,SLB,SLW,SAB,SAW,DAB,DAW ; 70 72 74 76 78 7A 7C 7E
;*
@ -706,28 +710,31 @@ LOR LDA ESTKL,X
;*
;* DUPLICATE TOS
;*
DUP DEX
LDA ESTKL+1,X
STA ESTKL,X
LDA ESTKH+1,X
STA ESTKH,X
JMP NEXTOP
;DUP DEX
; LDA ESTKL+1,X
; STA ESTKL,X
; LDA ESTKH+1,X
; STA ESTKH,X
; JMP NEXTOP
;*
;* LOGICAL NOT
;*
LNOT LDA ESTKL,X
ORA ESTKH,X
BNE +
LDA #$FF
BEQ +
LDA #$00
+ EOR #$FF
STA ESTKL,X
STA ESTKH,X
JMP NEXTOP
;*
;* CONSTANT
;*
ZERO DEX
+ LDA #$00
ZERO
CONST DEX
LSR ;LDA #$00
STA ESTKL,X
LDA #$00
STA ESTKH,X
JMP NEXTOP
CFFB DEX
@ -1256,14 +1263,6 @@ ISLT LDA ESTKL+1,X
;*
;* BRANCHES
;*
BRTRU INX
LDA ESTKH-1,X
ORA ESTKL-1,X
BNE BRNCH
NOBRNCH INY ;+INC_IP
INY
BMI FIXNEXT
JMP NEXTOP
FIXNEXT TYA
LDY #$00
CLC
@ -1272,6 +1271,30 @@ FIXNEXT TYA
BCC +
INC IPH
+ JMP NEXTOP
;BREQ INX
; LDA ESTKL-1,X
; CMP ESTKL,X
; BNE NOBRNCH
; LDA ESTKH-1,X
; CMP ESTKH,X
; BEQ BRNCH
; BNE NOBRNCH
BRNE INX
LDA ESTKL-1,X
CMP ESTKL,X
BNE BRNCH
LDA ESTKH-1,X
CMP ESTKH,X
BEQ NOBRNCH
BNE BRNCH
BRTRU INX
LDA ESTKH-1,X
ORA ESTKL-1,X
BNE BRNCH
NOBRNCH INY ;+INC_IP
INY
BMI FIXNEXT
JMP NEXTOP
BRFLS INX
LDA ESTKH-1,X
ORA ESTKL-1,X
@ -1294,58 +1317,72 @@ BRNCH TYA ; FLATTEN IP
STA IPH
DEY
JMP FETCHOP
BREQ INX
LDA ESTKL-1,X
;*
;* FOR LOOPS PUT TERMINAL VALUE AT ESTK+1 AND CURRENT COUNT ON ESTK
;*
BRGT LDA ESTKL+1,X ; $D95D
CMP ESTKL,X
BNE NOBRNCH
LDA ESTKH-1,X
CMP ESTKH,X
BEQ BRNCH
BNE NOBRNCH
BRNE INX
LDA ESTKL-1,X
CMP ESTKL,X
BNE BRNCH
LDA ESTKH-1,X
CMP ESTKH,X
BEQ NOBRNCH
BNE BRNCH
BRGT INX
LDA ESTKL-1,X
CMP ESTKL,X
LDA ESTKH-1,X
LDA ESTKH+1,X
SBC ESTKH,X
BVS +
BPL NOBRNCH
BMI BRNCH
+ BPL BRNCH
BMI NOBRNCH
BRLT INX
LDA ESTKL,X
CMP ESTKL-1,X
- INX ; DROP FOR VALUES
INX
BNE BRNCH ; BMI BRNCH
BRLT LDA ESTKL,X
CMP ESTKL+1,X
LDA ESTKH,X
SBC ESTKH-1,X
SBC ESTKH+1,X
BVS +
BPL NOBRNCH
BMI BRNCH
+ BPL BRNCH
BMI NOBRNCH
IBRNCH TYA ; FLATTEN IP
CLC
ADC IPL
STA TMPL
LDA #$00
TAY
ADC IPH
STA TMPH ; ADD BRANCH OFFSET
LDA TMPL
;CLC ; BETTER NOT CARRY OUT OF IP+Y
ADC ESTKL,X
STA IPL
LDA TMPH
ADC ESTKH,X
STA IPH
JMP DROP
INX ; DROP FOR VALUES
INX
BNE BRNCH ; BMI BRNCH
+ BMI NOBRNCH
BPL -
DNXTDN LDA ESTKL,X
BNE +
DEC ESTKH,X
+ DEC ESTKL,X
NXTDN LDA ESTKL,X ; BRGE
CMP ESTKL+1,X
LDA ESTKH,X
SBC ESTKH+1,X
BVS +
BPL BRNCH
- INX ; DROP FOR VALUES
INX
BNE NOBRNCH ; BMI NOBRNCH
INXTUP INC ESTKL,X
BNE NXTUP
INC ESTKH,X
NXTUP LDA ESTKL+1,X ; BRLE
CMP ESTKL,X
LDA ESTKH+1,X
SBC ESTKH,X
BVS +
BPL BRNCH
INX ; DROP FOR VALUES
INX
BNE NOBRNCH ; BMI NOBRNCH
+ BMI BRNCH
BPL -
;IBRNCH TYA ; FLATTEN IP
; CLC
; ADC IPL
; STA TMPL
; LDA #$00
; TAY
; ADC IPH
; STA TMPH ; ADD BRANCH OFFSET
; LDA TMPL
; ;CLC ; BETTER NOT CARRY OUT OF IP+Y
; ADC ESTKL,X
; STA IPL
; LDA TMPH
; ADC ESTKH,X
; STA IPH
; JMP DROP
;*
;* CALL INTO ABSOLUTE ADDRESS (NATIVE CODE)
;*
@ -1583,15 +1620,15 @@ CDINTRP PLY
JMP FETCHOP
CDINTRPEND
;
LDA #<ZERO
LDX #>ZERO
LDY #(CZEROEND-CZERO)
JSR OPCPY
CZERO DEX
STZ ESTKL,X
STZ ESTKH,X
JMP NEXTOP
CZEROEND
; LDA #<ZERO
; LDX #>ZERO
; LDY #(CZEROEND-CZERO)
; JSR OPCPY
;CZERO DEX
; STZ ESTKL,X
; STZ ESTKH,X
; JMP NEXTOP
;CZEROEND
;
LDA #<CB
LDX #>CB
@ -1884,7 +1921,7 @@ OPCPY STA DST
INC SRC
BNE +
INC SRC+1
+
+ DEY
- LDA (SRC),Y
STA (DST),Y
DEY