Created
November 17, 2017 05:17
-
-
Save Pinacolada64/e82882d4a0ea26011c3e4d5a13ea166f to your computer and use it in GitHub Desktop.
Hexadecimal display routines for 6510
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hex_16(value): | |
# format 16-bit 4-digit hex value | |
# return ('{:04x}'.format(value)) # returns 'xxxx', 16-bit hex value | |
return("%04X" % (value)) | |
def hex_8(value): | |
# format 8-bit 2 digit hex value | |
# return ('{:02x}'.format(value)) | |
return("%02X" % (value)) | |
# print(hi_lo(49152)) # should return 192 0 | |
# print 16-bit address and 8 8-bit bytes: | |
# (simulates a hex dump of a program) | |
for addr in range(0x2000,0x2064,8): | |
print("${}: {} {} {} {} {} {} {} {}".format(hex_16(addr), | |
hex_8(0xde), | |
hex_8(0xad), | |
hex_8(0xbe), | |
hex_8(0xef), | |
hex_8(0xc0), | |
hex_8(0xff), | |
hex_8(0xee), | |
hex_8(0x00) | |
)) | |
# core says this also works: | |
print("$%04X" % 53248) # $D000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment