ubyte comparisons

This commit is contained in:
Irmen de Jong 2018-12-08 18:08:46 +01:00
parent ef2ae60868
commit db3d3727c2
2 changed files with 210 additions and 231 deletions

View File

@ -19,28 +19,72 @@
rsave() rsave()
ub1=100 c64scr.print_byte_decimal(X)
ub2=199 c64.CHROUT('\n')
c64.STROUT("ub1=100,ub2=199\n")
rrestore() rrestore()
if ub1==ub2 { ub2=ub1<ub2
ub2=ub1<ub2
ub2=ub1<ub2
ub2=ub1<ub2
ub2=ub1>ub2
ub2=ub1>ub2
ub2=ub1>ub2
ub2=ub1>ub2
ub2=ub1>ub2
ub2=ub1<=ub2
ub2=ub1<=ub2
ub2=ub1<=ub2
ub2=ub1<=ub2
ub2=ub1>=ub2
ub2=ub1>=ub2
ub2=ub1>=ub2
ub2=ub1>=ub2
ub2=ub1>=ub2
rsave() rsave()
c64.STROUT(" true: ub1==ub2\n")
ub1=66
ub2=199
c64.STROUT("ub1=66,ub2=199\n")
rrestore()
if ub1<ub2 {
rsave()
c64.STROUT(" true: ub1<ub2\n")
rrestore() rrestore()
} else { } else {
rsave() rsave()
c64.STROUT(" false: ub1==ub2\n") c64.STROUT(" false: ub1<ub2\n")
rrestore() rrestore()
} }
if ub1!=ub2 { if ub1<=ub2 {
rsave() rsave()
c64.STROUT(" true: ub1!=ub2\n") c64.STROUT(" true: ub1<=ub2\n")
rrestore() rrestore()
} else { } else {
rsave() rsave()
c64.STROUT(" false: ub1!=ub2\n") c64.STROUT(" false: ub1<=ub2\n")
rrestore()
}
if ub1>ub2 {
rsave()
c64.STROUT(" true: ub1>ub2\n")
rrestore()
} else {
rsave()
c64.STROUT(" false: ub1>b2\n")
rrestore()
}
if ub1>=ub2 {
rsave()
c64.STROUT(" true: ub1>=ub2\n")
rrestore()
} else {
rsave()
c64.STROUT(" false: ub1>=b2\n")
rrestore() rrestore()
} }
@ -51,182 +95,96 @@
c64.STROUT("ub1=ub2=199\n") c64.STROUT("ub1=ub2=199\n")
rrestore() rrestore()
if ub1==ub2 { if ub1<ub2 {
rsave() rsave()
c64.STROUT(" true: ub1==ub2\n") c64.STROUT(" true: ub1<ub2\n")
rrestore() rrestore()
} else { } else {
rsave() rsave()
c64.STROUT(" false: ub1==ub2\n") c64.STROUT(" false: ub1<ub2\n")
rrestore() rrestore()
} }
if ub1!=ub2 { if ub1<=ub2 {
rsave() rsave()
c64.STROUT(" true: ub1!=ub2\n") c64.STROUT(" true: ub1<=ub2\n")
rrestore() rrestore()
} else { } else {
rsave() rsave()
c64.STROUT(" false: ub1!=ub2\n") c64.STROUT(" false: ub1<=ub2\n")
rrestore()
}
if ub1>ub2 {
rsave()
c64.STROUT(" true: ub1>ub2\n")
rrestore()
} else {
rsave()
c64.STROUT(" false: ub1>ub2\n")
rrestore()
}
if ub1>=ub2 {
rsave()
c64.STROUT(" true: ub1>=ub2\n")
rrestore()
} else {
rsave()
c64.STROUT(" false: ub1>=ub2\n")
rrestore() rrestore()
} }
rsave() rsave()
b1=50 ub1=222
b2=111 ub2=88
c64.STROUT("b1=50,b2=111\n") c64.STROUT("ub1=222,ub2=88\n")
rrestore() rrestore()
if b1==b2 { if ub1<ub2 {
rsave() rsave()
c64.STROUT(" true: b1==b2\n") c64.STROUT(" true: ub1<ub2\n")
rrestore() rrestore()
} else { } else {
rsave() rsave()
c64.STROUT(" false: b1==b2\n") c64.STROUT(" false: ub1<ub2\n")
rrestore() rrestore()
} }
if b1!=b2 { if ub1<=ub2 {
rsave() rsave()
c64.STROUT(" true: b1!=b2\n") c64.STROUT(" true: ub1<=ub2\n")
rrestore() rrestore()
} else { } else {
rsave() rsave()
c64.STROUT(" false: b1!=b2\n") c64.STROUT(" false: ub1<=ub2\n")
rrestore()
}
if ub1>ub2 {
rsave()
c64.STROUT(" true: ub1>ub2\n")
rrestore()
} else {
rsave()
c64.STROUT(" false: ub1>ub2\n")
rrestore()
}
if ub1>=ub2 {
rsave()
c64.STROUT(" true: ub1>=ub2\n")
rrestore()
} else {
rsave()
c64.STROUT(" false: ub1>=ub2\n")
rrestore() rrestore()
} }
rsave() rsave()
b1=111 c64scr.print_byte_decimal(X)
b2=111 c64.CHROUT('\n')
c64.STROUT("b1=b2=111\n")
rrestore() rrestore()
if b1==b2 {
rsave()
c64.STROUT(" true: b1==b2\n")
rrestore()
} else {
rsave()
c64.STROUT(" false: b1==b2\n")
rrestore()
}
if b1!=b2 {
rsave()
c64.STROUT(" true: b1!=b2\n")
rrestore()
} else {
rsave()
c64.STROUT(" false: b1!=b2\n")
rrestore()
}
rsave()
uw1=1234
uw2=59999
c64.STROUT("uw1=1234,uw2=59999\n")
rrestore()
if uw1==uw2 {
rsave()
c64.STROUT(" true: uw1==uw2\n")
rrestore()
} else {
rsave()
c64.STROUT(" false: uw1==uw2\n")
rrestore()
}
if uw1!=uw2 {
rsave()
c64.STROUT(" true: uw1!=uw2\n")
rrestore()
} else {
rsave()
c64.STROUT(" false: uw1!=uw2\n")
rrestore()
}
rsave()
uw1=52999
uw2=52999
c64.STROUT("uw1=uw2=52999\n")
rrestore()
if uw1==uw2 {
rsave()
c64.STROUT(" true: uw1==uw2\n")
rrestore()
} else {
rsave()
c64.STROUT(" false: uw1==uw2\n")
rrestore()
}
if uw1!=uw2 {
rsave()
c64.STROUT(" true: uw1!=uw2\n")
rrestore()
} else {
rsave()
c64.STROUT(" false: uw1!=uw2\n")
rrestore()
}
rsave()
w1=1234
w2=-9999
c64.STROUT("w1=1234, w2=-9999\n")
rrestore()
if w1==w2 {
rsave()
c64.STROUT(" true: w1==w2\n")
rrestore()
} else {
rsave()
c64.STROUT(" false: w1==w2\n")
rrestore()
}
if w1!=w2 {
rsave()
c64.STROUT(" true: w1!=w2\n")
rrestore()
} else {
rsave()
c64.STROUT(" false: w1!=w2\n")
rrestore()
}
rsave()
w1=44
w2=44
c64.STROUT("w1=w2=44\n")
rrestore()
if w1==w2 {
rsave()
c64.STROUT(" true: w1==w2\n")
rrestore()
} else {
rsave()
c64.STROUT(" false: w1==w2\n")
rrestore()
}
if w1!=w2 {
rsave()
c64.STROUT(" true: w1!=w2\n")
rrestore()
} else {
rsave()
c64.STROUT(" false: w1!=w2\n")
rrestore()
}
} }
} }

View File

@ -272,38 +272,27 @@ remainder_f .proc
equal_b .proc equal_b .proc
; -- are the two bytes on the stack identical? ; -- are the two bytes on the stack identical?
inx lda ESTACK_LO+1,x
lda ESTACK_LO,x cmp ESTACK_LO+2,x
cmp ESTACK_LO+1,x bne _equal_b_false
bne + _equal_b_true lda #1
lda #1 _equal_b_store inx
sta ESTACK_LO+1,x
rts
+ lda #0
sta ESTACK_LO+1,x sta ESTACK_LO+1,x
rts rts
_equal_b_false lda #0
beq _equal_b_store
.pend .pend
equal_w .proc equal_w .proc
; -- are the two words on the stack identical? ; -- are the two words on the stack identical?
inx lda ESTACK_LO+1,x
lda ESTACK_LO,x cmp ESTACK_LO+2,x
cmp ESTACK_LO+1,x bne equal_b._equal_b_false
bne + lda ESTACK_HI+1,x
lda ESTACK_HI,x cmp ESTACK_HI+2,x
cmp ESTACK_HI+1,x bne equal_b._equal_b_false
bne + beq equal_b._equal_b_true
txa ; words are equal
sta ESTACK_LO+1,x
rts
+ lda #0 ; words are not equal
sta ESTACK_LO+1,x
rts
.pend
equal_f .proc
rts
.warn "not implemented"
.pend .pend
notequal_b .proc notequal_b .proc
@ -329,15 +318,11 @@ notequal_w .proc
rts rts
.pend .pend
notequal_f .proc
rts
.warn "not implemented"
.pend
less_ub .proc less_ub .proc
rts lda ESTACK_LO+2,x
.warn "not implemented" cmp ESTACK_LO+1,x
bcc equal_b._equal_b_true
bcs equal_b._equal_b_false
.pend .pend
less_b .proc less_b .proc
@ -345,24 +330,22 @@ less_b .proc
.warn "not implemented" .warn "not implemented"
.pend .pend
less_w .proc
rts
.warn "not implemented"
.pend
less_uw .proc less_uw .proc
rts rts
.warn "not implemented" .warn "not implemented"
.pend .pend
less_f .proc less_w .proc
rts rts
.warn "not implemented" .warn "not implemented"
.pend .pend
lesseq_ub .proc lesseq_ub .proc
rts lda ESTACK_LO+2,x
.warn "not implemented" cmp ESTACK_LO+1,x
bcc equal_b._equal_b_true
beq equal_b._equal_b_true
bcs equal_b._equal_b_false
.pend .pend
lesseq_b .proc lesseq_b .proc
@ -370,30 +353,22 @@ lesseq_b .proc
.warn "not implemented" .warn "not implemented"
.pend .pend
lesseq_w .proc
rts
.warn "not implemented"
.pend
lesseq_uw .proc lesseq_uw .proc
rts rts
.warn "not implemented" .warn "not implemented"
.pend .pend
lesseq_f .proc lesseq_w .proc
rts rts
.warn "not implemented" .warn "not implemented"
.pend .pend
greater_ub .proc greater_ub .proc
inx lda ESTACK_LO+2,x
lda ESTACK_LO,x cmp ESTACK_LO+1,x
clc beq equal_b._equal_b_false
sbc ESTACK_LO+1,x bcs equal_b._equal_b_true
lda #0 bcc equal_b._equal_b_false
adc #0
sta ESTACK_LO+1,x
rts
.pend .pend
greater_b .proc greater_b .proc
@ -401,24 +376,21 @@ greater_b .proc
.warn "not implemented" .warn "not implemented"
.pend .pend
greater_w .proc
rts
.warn "not implemented"
.pend
greater_uw .proc greater_uw .proc
rts rts
.warn "not implemented" .warn "not implemented"
.pend .pend
greater_f .proc greater_w .proc
rts rts
.warn "not implemented" .warn "not implemented"
.pend .pend
greatereq_ub .proc greatereq_ub .proc
rts lda ESTACK_LO+2,x
.warn "not implemented" cmp ESTACK_LO+1,x
bcs equal_b._equal_b_true
bcc equal_b._equal_b_false
.pend .pend
greatereq_b .proc greatereq_b .proc
@ -426,21 +398,70 @@ greatereq_b .proc
.warn "not implemented" .warn "not implemented"
.pend .pend
greatereq_w .proc
rts
.warn "not implemented"
.pend
greatereq_uw .proc greatereq_uw .proc
rts rts
.warn "not implemented" .warn "not implemented"
.pend .pend
greatereq_w .proc
rts
.warn "not implemented"
.pend
equal_f .proc
; -- are the two mflpt5 numbers on the stack identical?
inx
inx
inx
inx
lda ESTACK_LO-3,x
cmp ESTACK_LO,x
bne equal_b._equal_b_false
lda ESTACK_LO-2,x
cmp ESTACK_LO+1,x
bne equal_b._equal_b_false
lda ESTACK_LO-1,x
cmp ESTACK_LO+2,x
bne equal_b._equal_b_false
lda ESTACK_HI-2,x
cmp ESTACK_HI+1,x
bne equal_b._equal_b_false
lda ESTACK_HI-1,x
cmp ESTACK_HI+2,x
bne equal_b._equal_b_false
beq equal_b._equal_b_true
.pend
notequal_f .proc
; -- are the two mflpt5 numbers on the stack different?
jsr equal_f
eor #1 ; invert the result
sta ESTACK_LO+1,x
rts
.pend
less_f .proc
rts
.warn "not implemented"
.pend
lesseq_f .proc
rts
.warn "not implemented"
.pend
greater_f .proc
rts
.warn "not implemented"
.pend
greatereq_f .proc greatereq_f .proc
rts rts
.warn "not implemented" .warn "not implemented"
.pend .pend
func_sin .proc func_sin .proc
rts rts
.warn "not implemented" .warn "not implemented"