Originally Posted by
anduril462
I don't know what you mean by "take longer", but yes, they refer to different addresses. The section they are in depends on what kind of .section directives you have above/between them. Ideally, data goes in .data or .bss, constant/unmodifiable data goes in .rodata and instructions go in .text.
Whether you declare it as a label with a .ascii, .asciz or .string directive, or whether you use a label and tabstop's .byte 0,0,0,0,0... or whether you use .comm someLabel, your resultant code will work the same (of course, assuming same amount of space reserved in all cases). Your assembly will still always refer to $someLabel, which will get translated to an address in all 3 cases when the final executable file is built. It technically doesn't matter which method you use for the program in question. In general however, it may be easier, more appropriate, or plain old impossible to use certain methods depending on whether you wish to initialize data or make it constant or read only, etc.
Take longer as in doing this
.string " "
where i have to count the number of spaces
.comm .... seems kind of quick.
Yeah, it does seem a bit clearer than before.
Quick question (haha)
I have a string declared that has 20bytes, but I want the last byte to have the null character when the user inputs a string.
so what i did was
Code:
movl $19, %edx
movl $inputString,%ecx
movl $0, %ebx
movl $3, %eax
int $0x80
addl $19, %ecx
movl $0, %ecx #add a null character
I just wonder if that is correct. I haven't tested it yet, because I am having problems with the text editor.