OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Mar 29, 2024 3:02 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: "Printing to the screen without a db"
PostPosted: Sat Dec 04, 2010 5:49 pm 
Offline
Member
Member

Joined: Sun Sep 06, 2009 3:54 am
Posts: 169
Location: Brighton, United Kingdom
I was reading this article and noticed the following message:
Quote:
note, 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

I'm not sure if this is a good or bad idea, but it seems to work; rather than use the code
Code:
%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

as in the Wiki article, if you remove the section information:
Code:
%macro print 1+
   %%string:   db   %1,   0
   mov   si,   %%string
   call   putstr
%endmacro

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.


Top
 Profile  
 
 Post subject: Re: "Printing to the screen without a db"
PostPosted: Sat Dec 04, 2010 6:20 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
You're executing data that way. The reason it works is because you are lucky not to screw up the system and align back up before the mov si...

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: "Printing to the screen without a db"
PostPosted: Sat Dec 04, 2010 6:31 pm 
Offline
Member
Member

Joined: Sun Sep 06, 2009 3:54 am
Posts: 169
Location: Brighton, United Kingdom
Combuster wrote:
You're executing data that way. The reason it works is because you are lucky not to screw up the system and align back up before the mov si...

Oh, right, ok.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 23 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group