implement print_ulhex(long, prefix)

This commit is contained in:
Irmen de Jong
2025-09-20 03:45:31 +02:00
parent b058f1c7c2
commit 557b12668d
5 changed files with 66 additions and 1 deletions

View File

@@ -102,7 +102,7 @@ sub str_uwbin (uword value) -> str {
}
sub str_uwhex (uword value) -> str {
; ---- convert the uword in A/Y in hexadecimal string form (4 digits)
; ---- convert the uword in hexadecimal string form (4 digits)
ubyte bits = msb(value)
string_out[0] = hex_digits[bits>>4]
string_out[1] = hex_digits[bits&15]
@@ -113,6 +113,26 @@ sub str_uwhex (uword value) -> str {
return string_out
}
sub str_ulhex (long value) -> str {
; ---- convert the long in hexadecimal string form (8 digits)
uword upperw = msw(value)
uword lowerw = lsw(value)
ubyte bits = msb(upperw)
string_out[0] = hex_digits[bits>>4]
string_out[1] = hex_digits[bits&15]
bits = lsb(upperw)
string_out[2] = hex_digits[bits>>4]
string_out[3] = hex_digits[bits&15]
bits = msb(lowerw)
string_out[4] = hex_digits[bits>>4]
string_out[5] = hex_digits[bits&15]
bits = lsb(lowerw)
string_out[6] = hex_digits[bits>>4]
string_out[7] = hex_digits[bits&15]
string_out[8] = 0
return string_out
}
sub str_uw0 (uword value) -> str {
; ---- convert the uword in A/Y in decimal string form, with left padding 0s (5 positions total)
uword value2 = value/10

View File

@@ -136,6 +136,13 @@ sub print_uwhex (uword value, bool prefix) {
print(conv.str_uwhex(value))
}
sub print_ulhex (long value, bool prefix) {
; ---- print the ulong in hexadecimal form (4 digits)
if prefix
chrout('$')
print(conv.str_ulhex(value))
}
sub print_uw0 (uword value) {
; ---- print the uword value in decimal form, with left padding 0s (5 positions total)
print(conv.str_uw0(value))