#macro BIN2BCD(result,value)
result = value / 1000 // 10 * 16
result = value / 100 // 10 + result * 16
result = value / 10 // 10 + result * 16
result = value // 10 + result
#endmacro
#macro BCD2BIN(result,value)
result = value / 4096 // 16 * 10
result = value / 256 // 16 + result * 10
result = value / 16 // 16 + result * 10
result = value // 16 + result
#endmacro
Bin2Bcd(w0,9876)
gosub PrintHex
Bcd2Bin(w1,w0)
sertxd(" = ",#w1)
end
PrintHex:
S_W0 = w0 / 4096 // 16
sertxd(13,10,#w0," = ",#S_W0)
S_W0 = w0 / 256 // 16
sertxd(#S_W0)
S_W0 = w0 / 16 // 16
sertxd(#S_W0)
S_W0 = w0 // 16
sertxd(#S_W0)
return