Bona Fide OS Developer
View unanswered posts | View active topics It is currently Sat Dec 21, 2024 11:53 am



Post new topic Reply to topic  [ 2 posts ] 
 Declaring initialized data with NASM 
Author Message

Joined: Thu Sep 09, 2010 9:34 pm
Posts: 3
Post Declaring initialized data with NASM
Hello, World!

i'm only using assembly in my toy OS project, (not trying to be a badass or anything, i just think it's a fun way to learn 32 bit assembly coming from the 16 bit world of the 8086) and i'm working on my IDT now, so i have something like this for each entry:
Code:
;interrupt 00
;division by zero exception
    dw    0x0000            ;offset low word
    dw    0x0008            ;selector
    dw    0x8E00            ;present and ring 0
    dw    0x0000            ;offset upper word

i'd like to have the offset initialized when i assemble it rather than write it in as it runs, like this:
Code:
    dd    div_by_zero_handler

but the upper and lower words are split all topsy-turvy like. Reading through the NASM manual, it seems like what i want are the >> and & operators, but when i try
Code:
;interrupt 00
;division by zero exception
    dw    isr_00 & 0xFFFF        ;offset low word
    dw    0x0008            ;selector
    dw    0x8E00            ;present and ring 0
    dw    isr_00 >> 16 & 0xFFFF    ;offset upper word

NASM spits it back out saying "shift operator may only be applied to scalar values."

Kinda long post, but my question is this:
How can i initialize data using only the upper or lower word of an address?


Thu Sep 09, 2010 9:57 pm
Profile

Joined: Thu Sep 09, 2010 9:34 pm
Posts: 3
Post Re: Declaring initialized data with NASM
Sorry to double post, but...

i figured out that i did not want to initialize my IDT when i assembled it, as then i would have to initialize the entire IDT or mess around with the linker script to get another uninitialized section to go right after it which i would then have to fill with zeros anyway.

But if anyone knows how to extract the upper and lower words of addresses to initialize parts of data like that, i would still like to know how since it might be useful sometime.


Wed Sep 22, 2010 6:07 pm
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin and tweaked by the BF Team.