Hi, I'm very unexperienced with the use of strings in ASM. I try to convert this C code to ASM:

void AddLetter(char letter)
char myString[2];

if (strlen(text) < MAX_TEXT_LENGTH)
myString[0] = letter;
myString[1] = '\0';

strcat(text, myString);

the variables text and constant MAX_TEXT_LENGTH are global. text is just another array of char

Any help on the making of this function into ASM?
Posted on 2002-05-28 13:42:18 by Ronin Magus
It is easy, you should really try a bit, it would be a enrichissing experience : you can always help you by compiling the program and disassemble it, or generating an assembly listing using the compiler (VC++ is able to do that).
Posted on 2002-05-28 14:07:16 by JCP
Btw you don't need myString nor the strcat for such a function. Readiosys is right, give it a try and post your attempt here, you'll learn from it.

Posted on 2002-05-28 14:10:50 by Thomas
This is silly. :tongue:
Posted on 2002-05-28 14:19:32 by bitRAKE
after the reading of the working with strings in the help file, this is what I have created:

AddLetter proc letter :BYTE
mov ecx, text

mov al,
cmp al, 0
je addletter
inc ecx
jmp FindTerminator

mov , letter
inc ecx
mov , 0


AddLetter endp

but it does not compile. this is the best tha I could do
Posted on 2002-05-28 15:41:15 by Ronin Magus
Needless jmp.
Reorgonize it:

mov ecx,text ;pointer
mov al,[ecx]
inc ecx
test al,al
jne @B
mov [ecx-1],letter
mov [ecx],al
Posted on 2002-05-28 16:50:29 by The Svin
It helps to show the line with the error, and what error message you get:

mov , 0

MASM doesn't know what size to store, byte, word, or dword. You must tell it:

mov byte ptr , 0
Posted on 2002-05-28 20:51:33 by tenkey