2020-09-20 21:49:36 +00:00
|
|
|
%import floats
|
|
|
|
%import textio
|
2019-08-05 19:01:41 +00:00
|
|
|
%zeropage basicsafe
|
|
|
|
|
|
|
|
main {
|
|
|
|
|
|
|
|
sub start() {
|
|
|
|
div_ubyte(0, 1, 0)
|
|
|
|
div_ubyte(100, 6, 16)
|
|
|
|
div_ubyte(255, 2, 127)
|
|
|
|
|
2020-08-28 21:28:21 +00:00
|
|
|
div_byte(0, 1, 0)
|
|
|
|
div_byte(100, -6, -16)
|
|
|
|
div_byte(127, -2, -63)
|
2019-08-05 19:01:41 +00:00
|
|
|
|
|
|
|
div_uword(0,1,0)
|
|
|
|
div_uword(40000,500,80)
|
|
|
|
div_uword(43211,2,21605)
|
|
|
|
|
2020-08-28 21:28:21 +00:00
|
|
|
div_word(0,1,0)
|
|
|
|
div_word(-20000,500,-40)
|
|
|
|
div_word(-2222,2,-1111)
|
2019-08-05 19:01:41 +00:00
|
|
|
|
2020-12-01 21:19:03 +00:00
|
|
|
div_float(0,1,0)
|
|
|
|
div_float(999.9,111.0,9.008108108108107)
|
2019-08-05 19:01:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub div_ubyte(ubyte a1, ubyte a2, ubyte c) {
|
|
|
|
ubyte r = a1/a2
|
|
|
|
if r==c
|
2020-08-27 16:10:22 +00:00
|
|
|
txt.print(" ok ")
|
2019-08-05 19:01:41 +00:00
|
|
|
else
|
2020-08-27 16:10:22 +00:00
|
|
|
txt.print("err! ")
|
|
|
|
txt.print("ubyte ")
|
|
|
|
txt.print_ub(a1)
|
|
|
|
txt.print(" / ")
|
|
|
|
txt.print_ub(a2)
|
|
|
|
txt.print(" = ")
|
|
|
|
txt.print_ub(r)
|
2023-04-28 21:13:03 +00:00
|
|
|
cbm.CHROUT('\n')
|
2019-08-05 19:01:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub div_byte(byte a1, byte a2, byte c) {
|
|
|
|
byte r = a1/a2
|
|
|
|
if r==c
|
2020-08-27 16:10:22 +00:00
|
|
|
txt.print(" ok ")
|
2019-08-05 19:01:41 +00:00
|
|
|
else
|
2020-08-27 16:10:22 +00:00
|
|
|
txt.print("err! ")
|
|
|
|
txt.print("byte ")
|
|
|
|
txt.print_b(a1)
|
|
|
|
txt.print(" / ")
|
|
|
|
txt.print_b(a2)
|
|
|
|
txt.print(" = ")
|
|
|
|
txt.print_b(r)
|
2023-04-28 21:13:03 +00:00
|
|
|
cbm.CHROUT('\n')
|
2019-08-05 19:01:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub div_uword(uword a1, uword a2, uword c) {
|
|
|
|
uword r = a1/a2
|
|
|
|
if r==c
|
2020-08-27 16:10:22 +00:00
|
|
|
txt.print(" ok ")
|
2019-08-05 19:01:41 +00:00
|
|
|
else
|
2020-08-27 16:10:22 +00:00
|
|
|
txt.print("err! ")
|
|
|
|
txt.print("uword ")
|
|
|
|
txt.print_uw(a1)
|
|
|
|
txt.print(" / ")
|
|
|
|
txt.print_uw(a2)
|
|
|
|
txt.print(" = ")
|
|
|
|
txt.print_uw(r)
|
2023-04-28 21:13:03 +00:00
|
|
|
cbm.CHROUT('\n')
|
2019-08-05 19:01:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub div_word(word a1, word a2, word c) {
|
|
|
|
word r = a1/a2
|
|
|
|
if r==c
|
2020-08-27 16:10:22 +00:00
|
|
|
txt.print(" ok ")
|
2019-08-05 19:01:41 +00:00
|
|
|
else
|
2020-08-27 16:10:22 +00:00
|
|
|
txt.print("err! ")
|
|
|
|
txt.print("word ")
|
|
|
|
txt.print_w(a1)
|
|
|
|
txt.print(" / ")
|
|
|
|
txt.print_w(a2)
|
|
|
|
txt.print(" = ")
|
|
|
|
txt.print_w(r)
|
2023-04-28 21:13:03 +00:00
|
|
|
cbm.CHROUT('\n')
|
2019-08-05 19:01:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub div_float(float a1, float a2, float c) {
|
|
|
|
float r = a1/a2
|
2023-05-16 22:40:47 +00:00
|
|
|
if abs(r-c)<0.00001
|
2020-08-27 16:10:22 +00:00
|
|
|
txt.print(" ok ")
|
2019-08-05 19:01:41 +00:00
|
|
|
else
|
2020-08-27 16:10:22 +00:00
|
|
|
txt.print("err! ")
|
2019-08-05 19:01:41 +00:00
|
|
|
|
2020-08-27 16:10:22 +00:00
|
|
|
txt.print("float ")
|
2020-09-20 21:49:36 +00:00
|
|
|
floats.print_f(a1)
|
2020-08-27 16:10:22 +00:00
|
|
|
txt.print(" / ")
|
2020-09-20 21:49:36 +00:00
|
|
|
floats.print_f(a2)
|
2020-08-27 16:10:22 +00:00
|
|
|
txt.print(" = ")
|
2020-09-20 21:49:36 +00:00
|
|
|
floats.print_f(r)
|
2023-04-28 21:13:03 +00:00
|
|
|
cbm.CHROUT('\n')
|
2019-08-05 19:01:41 +00:00
|
|
|
}
|
|
|
|
}
|