NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: munair on April 09, 2020, 03:28:36 PM
-
While working on the SharpBASIC compiler I wonder how to define a null-terminated fixed length string.
Consider the following SharpBASIC code:
var buffer: string * 10 = $32;
This should be parsed into a NASM string with 10 spaces plus a null. The SharpBASIC compiler currently generates the following NASM code:
buffer times 10 db 32
times 11-$+buffer db 0
Is this the correct output or is there a better syntax?
-
I would use
buffer times 11 db 0
That will give you the 10 length string plus the zero terminator.
-
I would use
buffer times 11 db 0
That will give you the 10 length string plus the zero terminator.
That was my initial solution as well. But the string may be predefined with characters like in the example above the space character (32), or something else like
var buffer: string * 10 = "abcde";