I want to display a score in a game that I built in MASM32, and I have a problem, how do I convert a DWORD to a DB (string).
There is the function crt__itoa
to convert a dword to an integer , but for some reason it doesn't work (do i need to include an other lib ? ).
There is the function TextOutA to display a score, but again I cant print it out because I don't have a string so it can print it from.
do i need to include an other lib? - Probably. You need
msvcrt.inc
andmsvcrt.lib
forcrt__itoa
.masm32rt.inc
is the Swiss Army Knife for such cases. Here is a working example:The program does not stop. If you don't call it in an extra command prompt window it will open a window and close it immediately. In
Qeditor
I suggest to insert a line "Run & Pause" intomenus.ini
:Now you have a new item under "Project".
Next is a method made with Visual Studio 2010 C++ that manually converts EAX into a string (it doesn't need any library, just copy-paste and use). It takes a number as parameter, assign it to EAX, convert it to string and display the string :
Pay attention : previous method is a "void", so you call it as usual :
You can modify the method to return the string or to do anything you want.
Now (for those who are tough enough) the same previous procedure for pure assembler, made with GUI Turbo Assembler x64 (http://sourceforge.net/projects/guitasm8086/), this full program shows how it works :