"Printing to the screen without a db"
Posted: Sat Dec 04, 2010 5:49 pm
I was reading this article and noticed the following message:
as in the Wiki article, if you remove the section information:
you can use it normally. I've tested this and it seems to work if you don't put any section information in your program, and instead let the assembler do this. It works with nasm, I'm not sure about other assemblers (though I think this article only applies to nasm anyway).
I'm not sure if there are any side-effects to doing this, though.
I'm not sure if this is a good or bad idea, but it seems to work; rather than use the codenote, you don't want to use this in a bootloader, it messes with the data section and I don't know how to place the boot signature at the end of the data section and still pad out to 512 bytes
Code: Select all
%macro print 1+
section .data ; At the end of the binary.
%%string:
db %1,0
section .text ; Back to where we were.
mov si,%%string
call print_string ; Print it out using the print_string function.
%endmacro
Code: Select all
%macro print 1+
%%string: db %1, 0
mov si, %%string
call putstr
%endmacro
I'm not sure if there are any side-effects to doing this, though.