Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Printing hex/decimal
2005-12-15 23:59
Wanderer
Account closed

Registered: Apr 2003
Posts: 478
Printing hex/decimal

I'm a bit rusty on this, it's been about 14 years since I've last done it:

I'm working on a utility and I need to...

a) print a decimal value (eg. 49152). I know there's a kernal routine you load with the low and high byte of your location and JSR$ the routine. It will print the decimal value.

or

b) print a hex address (eg. $c000) Now I used to have a nice routine to convert decimal to hex and print it but this has been lost to time.

I've tried searching for these routines online, but couldn't find anything. Any help would be appreciated :)

* Edit: I found the answer to (a), it's $BDCD *
2005-12-16 01:45
6R6

Registered: Feb 2002
Posts: 245
A)
address = $c000

ldx #<address
lda #>address
jmp $bdcd

B)
lda #>address
jsr hex2xa
stx $0400
sta $0401
lda #<address
jsr hex2xa
stx $0402
sta $0403
rts

hex2XA pha
and #$0f
jsr hex2sa
tax
pla
lsr
lsr
lsr
lsr
hex2sa clc
adc #$30
cmp #$3a
bmi hex2sb
adc #$06
hex2sb rts

2005-12-16 02:07
Wanderer
Account closed

Registered: Apr 2003
Posts: 478
Thank you kind sir... I appreciate the fast reply.

I'm just finishing the utility. :)
2009-07-29 06:07
TWW

Registered: Jul 2009
Posts: 545
Y = Byte to print in hex

tya
and #%00001111
tax
lda tab,x
sta $0401
tya
lsr
lsr
lsr
lsr
tax
lda tab,x
sta $0400
rts

tab .byte $30,$31,$32,$33,$34,$35,$36,$37
.byte $38,$39,$01,$02,$03,$04,$05,$06

neat lookuptable-trick for printing hex-values to the screen
TWW/Creators
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Mike
MWR/Visdom
ΛΛdZ
encore
WVL/Xenon
grennouille
Guests online: 109
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Swappers
1 Derbyshire Ram  (10)
2 Jerry  (9.8)
3 Violator  (9.7)
4 Acidchild  (9.7)
5 Cash  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.034 sec.