I'm familiar with _DispHL which displays a 16 bit number from HL but I would like to display an 8 byte number instead.




Code:
    .org 9D93h
    .db $BB,$6D
    bcall(_ClrLCD)    ; clear the screen
   
    ld hl, $0000
    ld (curRow), hl
   
    ld h,$00
    ld l,(Testing)
   
    bcall(_DispHL)
   
    ret             ; return from program

Testing:
    .db $A8


As you can see I'm trying to load the single byte number into hl to display that way. What is confusing me even more is that the number is displayed as 167 instead of 168. Any help or guidance would be greatly appreciated, thanks!
There is no such thing as a "ld l,(nnnn)" command. Normally the assembler should throw an error.
You must use "ld a,(nnnn) \ ld l,a".
Interesting, I'm using Brass to compile and it doesn't throw any errors.

The number is displaying correctly as 168 now, thanks.
I think it's generally more efficient to do it this way:
ld hl,(addr)
ld h,0
..if you have another register already set to 0, you can use it to load h with 0 and it'll be a byte smaller/3 cycles faster. HL is a special register here, ld hl,(addr) only takes up 3 bytes, using the other registers (ld bc,(addr), ld de,(addr)) are 4 byte instructions. ld a,(addr) is also 3 bytes (+ a byte for the ld l,a). Though in your case it seems h is already set to 0 (from loading into curRow), so using a is probably more efficient.

Also, maybe what Brass did was convert your ld l,(Testing) into ld l,Testing, (according to your code, i believe the Testing label is at $9DA6) which got truncated to $A6, or 166. Maybe in your other code you had an extra byte somewhere (or i miscalculated something)? I dunno. If you had the listing file, we could see what it changed it to. But as utz said, it should throw an error.
Is there a function similar to dispHL that is for 1 byte numbers? I don't like how it's putting 2 spaces in front of my 3 digit numbers.
You might look here for inspiration.
Yeah, usually to display numbers without the leading spaces (or to draw small print numbers) you have to convert the number into a string. I posted some code in an old post (which i funnily enough found also posted in an old thread of yours, heh). What i've done in games for displaying the score and other numbers that get drawn every frame is just make 0-9 number sprites and display the numbers with a simple sprite routine, since it's much faster to draw the sprites yourself to the gbuf than to rely on the OS's slow text routines.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement