thank you all of you for the help i really appreciate it.
i have a hopefully quick question, is this the correct syntax for adding an integer to a buffer: " add dword [userScore], 6 " or do i have to convert the userScore buffer to integer then add and then convert the resulting int back into string to insert back into the userScore?

3 Years
Discussion Span
Last Post by Roger_2

If my memory serves me well, add dword [userscore],6 will add 6 to the memory location pointed to by userscore. So I guess no conversion is needed.


That depends on what the label userscore is for. Is it a single dword holding the value as an integer, or is it a byte buffer holding a string? In other words, assuming NASM syntax, is it:

userscore:    resw 1  ; or 'userscore dw ?' in MASM 


userscore:    resb 8   ; or some other arbitrary size string

If it is a string, then yes, it would need to be converted first, then added to, then converted again. However, in that case, you may find it more useful to have userscore stored as a dword in integer form and only converted to a string when being displayed.

Edited by Schol-R-LEA


Currently, i have:

section .bss

userScore: resb 4

. . . . .

cmp edx, 5

add dword[userScore], edx
je printUserScore
call pcTurn

i would like to make this a simple process as i am not doing anything extravagant other than cycling through a few functions and just adding to the userScore quantity and ultimately printing it out. So, to use a word to store the userScore i should:

section .bss

userScore: resw 1

. . . . .

add dword[userScore], 5
je printUserScore
call pcTurn

then continue to add to userScore as needed until i need to print it out simply convert the userScore to string?

Edited by Roger_2


That's correct, except that either the size of the declaration should be resd (32-bit - my mistake in my earlier post) or the size of the operand should be word (16-bit). Which you want depends on the how high the score can go - 16-bit unsigned values go only to 65536, while 32-bit unsigned go over 4 billion. If you expect the scoring to exceed 65536, then use a dword or even a qword (64-bit).

Edited by Schol-R-LEA


makes perfect sense! and my algorithm works now thank you very much for your help!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.