The .while 1 is actually a bit fake, as there is no real condition tested - basically an endless loop, from which you can exit only using a .break
Here is a version that uses the .Repeat ... .Until construct:
include \Masm32\MasmBasic\Res\JBasic.inc ; ## builds in 32- or 64-bit mode with UAsm & AsmC but not ML64 ##
.code
CompareTwoStrings proc a:SIZE_P, b:SIZE_P ; receives two pointers
xor eax, eax ; result
mov rcx, a
mov rdx, b
.Repeat
mov al, [rcx]
.if !al ; end of string a ?
cmp al, [rdx]
je equal ; return 0 if equal
.break
.endif
inc rcx
inc rdx
.Until al != [rdx-1]
sbb eax, eax ; return -1 or 1
sbb eax,-1
equal:
ret
CompareTwoStrings endp
Init ; OPT_64 0 ; put 0 for 32 bit, 1 for 64 bit assembly
PrintLine Chr$("This program was assembled with ", @AsmUsed$(1), " in ", jbit$, "-bit format.")
jinvoke CompareTwoStrings, Chr$("Hello World, this is string A"), Chr$("Hello World, that is string B")
Print Str$("Result unequal:\t%i\n", rax)
jinvoke CompareTwoStrings, Chr$("Hello World, this is a string"), Chr$("Hello World, this is a string")
Print Str$("Result equal:\t%i\n", rax)
EndOfCode
Output for OPT_64 1 and OPT_64 0:
This program was assembled with AsmC in 64-bit format.
Result unequal: 1
Result equal: 0
This program was assembled with UAsm64 in 32-bit format.
Result unequal: 1
Result equal: 0