I'm building a game in assembly and I want to print the score every time, how can I do that? I made a variable named score but I don't know how to print it on the screen as a number
Asked
Active
Viewed 35 times
-2
-
2Convert to string first. Plenty of examples for that if you can't figure it out yourself. – Jester Jun 03 '22 at 21:33
-
You will need some fonts to convert the numbers to graphics. – MikeCAT Jun 03 '22 at 22:39
-
1see [Graphics mode in assembly 8086](https://stackoverflow.com/a/48664419/2521214) so you should convert your number value to a string and print as such ... example of that can be found in the `GLSL example of using it for printing` link (but not in asm) btw using BCD can help with this. Another option is to render bars instead of numbers like I did win the `What is the best way to move an object on the screen?` link. You should add info like what format is your number (int, float, fixed, binary, BCD, other) and your code for printing it so we can see where the problem is – Spektre Jun 04 '22 at 05:58
1 Answers
0
The easy way would be to either get or create some bitmap images, one for each digit. Create an array of those bitmaps. And then use a mod then divide loop to extract the digits in reverse order, Use the digit value to index the bitmap array.
Given that you are even asking the question I have to assume that you have basic blitting operations already.

SoronelHaetir
- 14,104
- 1
- 12
- 23
-
1[How do I print an integer in Assembly Level Programming without printf from the c library?](https://stackoverflow.com/a/46301894) and [Displaying numbers with DOS](https://stackoverflow.com/q/45904075) have examples of int->digit-string in reverse order, storing backwards from the end of a tmp buffer. So there are good examples for that part of the problem. – Peter Cordes Jun 05 '22 at 03:21