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()
ub1=100
ub2=199
c64.STROUT("ub1=100,ub2=199\n")
c64scr.print_byte_decimal(X)
c64.CHROUT('\n')
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()
ub1=66
ub2=199
c64.STROUT("ub1=66,ub2=199\n")
rrestore()
if ub1<ub2 {
rsave()
c64.STROUT(" true: ub1==ub2\n")
c64.STROUT(" true: ub1<ub2\n")
rrestore()
} else {
rsave()
c64.STROUT(" false: ub1==ub2\n")
c64.STROUT(" false: ub1<ub2\n")
rrestore()
}
if ub1!=ub2 {
if ub1<=ub2 {
rsave()
c64.STROUT(" true: ub1!=ub2\n")
c64.STROUT(" true: ub1<=ub2\n")
rrestore()
} else {
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()
}
@ -51,182 +95,96 @@
c64.STROUT("ub1=ub2=199\n")
rrestore()
if ub1==ub2 {
if ub1<ub2 {
rsave()
c64.STROUT(" true: ub1==ub2\n")
c64.STROUT(" true: ub1<ub2\n")
rrestore()
} else {
rsave()
c64.STROUT(" false: ub1==ub2\n")
c64.STROUT(" false: ub1<ub2\n")
rrestore()
}
if ub1!=ub2 {
if ub1<=ub2 {
rsave()
c64.STROUT(" true: ub1!=ub2\n")
c64.STROUT(" true: ub1<=ub2\n")
rrestore()
} else {
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()
}
rsave()
b1=50
b2=111
c64.STROUT("b1=50,b2=111\n")
ub1=222
ub2=88
c64.STROUT("ub1=222,ub2=88\n")
rrestore()
if b1==b2 {
if ub1<ub2 {
rsave()
c64.STROUT(" true: b1==b2\n")
c64.STROUT(" true: ub1<ub2\n")
rrestore()
} else {
rsave()
c64.STROUT(" false: b1==b2\n")
c64.STROUT(" false: ub1<ub2\n")
rrestore()
}
if b1!=b2 {
if ub1<=ub2 {
rsave()
c64.STROUT(" true: b1!=b2\n")
c64.STROUT(" true: ub1<=ub2\n")
rrestore()
} else {
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()
}
rsave()
b1=111
b2=111
c64.STROUT("b1=b2=111\n")
c64scr.print_byte_decimal(X)
c64.CHROUT('\n')
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,40 +272,29 @@ remainder_f .proc
equal_b .proc
; -- are the two bytes on the stack identical?
inx
lda ESTACK_LO,x
cmp ESTACK_LO+1,x
bne +
lda #1
sta ESTACK_LO+1,x
rts
+ lda #0
lda ESTACK_LO+1,x
cmp ESTACK_LO+2,x
bne _equal_b_false
_equal_b_true lda #1
_equal_b_store inx
sta ESTACK_LO+1,x
rts
_equal_b_false lda #0
beq _equal_b_store
.pend
equal_w .proc
; -- are the two words on the stack identical?
inx
lda ESTACK_LO,x
cmp ESTACK_LO+1,x
bne +
lda ESTACK_HI,x
cmp ESTACK_HI+1,x
bne +
txa ; words are equal
sta ESTACK_LO+1,x
rts
+ lda #0 ; words are not equal
sta ESTACK_LO+1,x
rts
lda ESTACK_LO+1,x
cmp ESTACK_LO+2,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
equal_f .proc
rts
.warn "not implemented"
.pend
notequal_b .proc
; -- are the two bytes on the stack different?
inx
@ -328,19 +317,20 @@ notequal_w .proc
sta ESTACK_LO+1,x
rts
.pend
notequal_f .proc
rts
.warn "not implemented"
.pend
less_ub .proc
rts
.warn "not implemented"
lda ESTACK_LO+2,x
cmp ESTACK_LO+1,x
bcc equal_b._equal_b_true
bcs equal_b._equal_b_false
.pend
less_b .proc
rts
.warn "not implemented"
.pend
less_uw .proc
rts
.warn "not implemented"
.pend
@ -350,19 +340,12 @@ less_w .proc
.warn "not implemented"
.pend
less_uw .proc
rts
.warn "not implemented"
.pend
less_f .proc
rts
.warn "not implemented"
.pend
lesseq_ub .proc
rts
.warn "not implemented"
lda ESTACK_LO+2,x
cmp ESTACK_LO+1,x
bcc equal_b._equal_b_true
beq equal_b._equal_b_true
bcs equal_b._equal_b_false
.pend
lesseq_b .proc
@ -370,33 +353,30 @@ lesseq_b .proc
.warn "not implemented"
.pend
lesseq_w .proc
rts
.warn "not implemented"
.pend
lesseq_uw .proc
rts
.warn "not implemented"
.pend
lesseq_f .proc
lesseq_w .proc
rts
.warn "not implemented"
.pend
greater_ub .proc
inx
lda ESTACK_LO,x
clc
sbc ESTACK_LO+1,x
lda #0
adc #0
sta ESTACK_LO+1,x
rts
lda ESTACK_LO+2,x
cmp ESTACK_LO+1,x
beq equal_b._equal_b_false
bcs equal_b._equal_b_true
bcc equal_b._equal_b_false
.pend
greater_b .proc
rts
.warn "not implemented"
.pend
greater_uw .proc
rts
.warn "not implemented"
.pend
@ -405,20 +385,12 @@ greater_w .proc
rts
.warn "not implemented"
.pend
greater_uw .proc
rts
.warn "not implemented"
.pend
greater_f .proc
rts
.warn "not implemented"
.pend
greatereq_ub .proc
rts
.warn "not implemented"
lda ESTACK_LO+2,x
cmp ESTACK_LO+1,x
bcs equal_b._equal_b_true
bcc equal_b._equal_b_false
.pend
greatereq_b .proc
@ -426,21 +398,70 @@ greatereq_b .proc
.warn "not implemented"
.pend
greatereq_w .proc
rts
.warn "not implemented"
.pend
greatereq_uw .proc
rts
.warn "not implemented"
.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
rts
.warn "not implemented"
.pend
func_sin .proc
rts
.warn "not implemented"