Here are some basic debugging macros to help solve those difficult assembly time problems.
"display_hex??" should be self explanatory.
"display_decimal" is for signed 64 bit numbers.
"display_unsigned" is for (you guessed it) unsigned 64 bit numbers.
macro display_hex1 value {
local nibble
nibble=(value) and 0fh + '0'
if nibble > '9'
nibble=nibble+7
end if
display nibble
}
macro display_hex2 value {
display_hex1 (value) shr 4
display_hex1 value
}
macro display_hex4 value {
display_hex2 (value) shr 8
display_hex2 value
}
macro display_hex8 value {
display_hex4 (value) shr 16
display_hex4 value
}
macro display_hex16 value {
display_hex8 (value) shr 32
display_hex8 value
}
macro display_decimal value*,put_zeros {
local leading_zero,digit,divisor,number
number=value
if number=1 shl 63
display '-9223372036854775808'
else
if number<0
number=-number
display '-'
end if
leading_zero=put_zeros+0
divisor=1000000000000000000
while divisor>0
digit=number/divisor
leading_zero=leading_zero+digit
if leading_zero | (divisor=1)
display digit+'0'
number=number-digit*divisor
end if
divisor=divisor/10
end while
end if
}
macro display_unsigned value* {
local number
number=value
if number<0
number=number-10000000000000000000
if number<0
number=number+1000000000000000000
display '9'
display_decimal number
else
display '1'
display_decimal number,1
end if
else
display_decimal number
end if
}