millfork/examples/crossplatform/calculator.mfk

39 lines
713 B
Plaintext

import stdio
#if CBM_64
import c64_basic
#elseif CBM_264
import c264_basic
#elseif ZX_SPECTRUM || NEC_PC_88 || TRS80 || CBM_VIC
// no imports needed
#else
#error Unsupported platform
#endif
void main() {
word a
word b
putstrz("enter first number:"z)
new_line()
a = readword()
while errno != err_ok {
putstrz("that wasn't a number, try again:"z)
new_line()
a = readword()
}
putstrz("enter second number:{n}"z)
b = readword()
while errno != err_ok {
putstrz("that wasn't a number, try again:"z)
new_line()
b = readword()
}
putstrz("the sum is:"z)
new_line()
putword(a + b)
new_line()
}