2019-08-05 19:01:41 +00:00
|
|
|
%import c64lib
|
|
|
|
%import c64utils
|
|
|
|
%import c64flt
|
|
|
|
%zeropage basicsafe
|
|
|
|
|
|
|
|
main {
|
|
|
|
|
|
|
|
sub start() {
|
|
|
|
minus_ubyte(0, 0, 0)
|
|
|
|
minus_ubyte(200, 0, 200)
|
|
|
|
minus_ubyte(200, 100, 100)
|
|
|
|
minus_ubyte(100, 200, 156)
|
2020-03-12 23:27:33 +00:00
|
|
|
check_eval_stack()
|
2019-08-05 19:01:41 +00:00
|
|
|
|
|
|
|
minus_byte(0, 0, 0)
|
|
|
|
minus_byte(100, 100, 0)
|
|
|
|
minus_byte(50, -50, 100)
|
|
|
|
minus_byte(0, -30, 30)
|
|
|
|
minus_byte(-30, 0, -30)
|
2020-03-12 23:27:33 +00:00
|
|
|
check_eval_stack()
|
2019-08-05 19:01:41 +00:00
|
|
|
|
|
|
|
minus_uword(0,0,0)
|
|
|
|
minus_uword(50000,0, 50000)
|
|
|
|
minus_uword(50000,20000,30000)
|
|
|
|
minus_uword(20000,50000,35536)
|
2020-03-12 23:27:33 +00:00
|
|
|
check_eval_stack() ; TODO fix stack error
|
2019-08-05 19:01:41 +00:00
|
|
|
|
|
|
|
minus_word(0,0,0)
|
|
|
|
minus_word(1000,1000,0)
|
|
|
|
minus_word(-1000,1000,-2000)
|
|
|
|
minus_word(1000,500,500)
|
|
|
|
minus_word(0,-3333,3333)
|
|
|
|
minus_word(-3333,0,-3333)
|
2020-03-12 23:27:33 +00:00
|
|
|
check_eval_stack() ; TODO fix stack error
|
2019-08-05 19:01:41 +00:00
|
|
|
|
|
|
|
minus_float(0,0,0)
|
|
|
|
minus_float(2.5,1.5,1.0)
|
|
|
|
minus_float(-1.5,3.5,-5.0)
|
|
|
|
|
2020-03-12 23:27:33 +00:00
|
|
|
check_eval_stack() ; TODO fix stack error
|
2019-08-05 19:01:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub minus_ubyte(ubyte a1, ubyte a2, ubyte c) {
|
|
|
|
ubyte r = a1-a2
|
|
|
|
if r==c
|
|
|
|
c64scr.print(" ok ")
|
|
|
|
else
|
|
|
|
c64scr.print("err! ")
|
|
|
|
c64scr.print("ubyte ")
|
|
|
|
c64scr.print_ub(a1)
|
|
|
|
c64scr.print(" - ")
|
|
|
|
c64scr.print_ub(a2)
|
|
|
|
c64scr.print(" = ")
|
|
|
|
c64scr.print_ub(r)
|
|
|
|
c64.CHROUT('\n')
|
|
|
|
}
|
|
|
|
|
|
|
|
sub minus_byte(byte a1, byte a2, byte c) {
|
|
|
|
byte r = a1-a2
|
|
|
|
if r==c
|
|
|
|
c64scr.print(" ok ")
|
|
|
|
else
|
|
|
|
c64scr.print("err! ")
|
|
|
|
c64scr.print("byte ")
|
|
|
|
c64scr.print_b(a1)
|
|
|
|
c64scr.print(" - ")
|
|
|
|
c64scr.print_b(a2)
|
|
|
|
c64scr.print(" = ")
|
|
|
|
c64scr.print_b(r)
|
|
|
|
c64.CHROUT('\n')
|
|
|
|
}
|
|
|
|
|
|
|
|
sub minus_uword(uword a1, uword a2, uword c) {
|
|
|
|
uword r = a1-a2
|
|
|
|
if r==c
|
|
|
|
c64scr.print(" ok ")
|
|
|
|
else
|
|
|
|
c64scr.print("err! ")
|
|
|
|
c64scr.print("uword ")
|
|
|
|
c64scr.print_uw(a1)
|
|
|
|
c64scr.print(" - ")
|
|
|
|
c64scr.print_uw(a2)
|
|
|
|
c64scr.print(" = ")
|
|
|
|
c64scr.print_uw(r)
|
|
|
|
c64.CHROUT('\n')
|
|
|
|
}
|
|
|
|
|
|
|
|
sub minus_word(word a1, word a2, word c) {
|
|
|
|
word r = a1-a2
|
|
|
|
if r==c
|
|
|
|
c64scr.print(" ok ")
|
|
|
|
else
|
|
|
|
c64scr.print("err! ")
|
|
|
|
c64scr.print("word ")
|
|
|
|
c64scr.print_w(a1)
|
|
|
|
c64scr.print(" - ")
|
|
|
|
c64scr.print_w(a2)
|
|
|
|
c64scr.print(" = ")
|
|
|
|
c64scr.print_w(r)
|
|
|
|
c64.CHROUT('\n')
|
|
|
|
}
|
|
|
|
|
|
|
|
sub minus_float(float a1, float a2, float c) {
|
|
|
|
float r = a1-a2
|
|
|
|
if abs(r-c)<0.00001
|
|
|
|
c64scr.print(" ok ")
|
|
|
|
else
|
|
|
|
c64scr.print("err! ")
|
|
|
|
|
|
|
|
c64scr.print("float ")
|
|
|
|
c64flt.print_f(a1)
|
|
|
|
c64scr.print(" - ")
|
|
|
|
c64flt.print_f(a2)
|
|
|
|
c64scr.print(" = ")
|
|
|
|
c64flt.print_f(r)
|
|
|
|
c64.CHROUT('\n')
|
|
|
|
}
|
2020-03-12 23:27:33 +00:00
|
|
|
|
|
|
|
sub check_eval_stack() {
|
|
|
|
if X!=255 {
|
|
|
|
c64scr.print("x=")
|
|
|
|
c64scr.print_ub(X)
|
|
|
|
c64scr.print(" error!\n")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-05 19:01:41 +00:00
|
|
|
}
|