NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: VishalPawale on December 12, 2011, 03:46:33 PM
-
Hi guys,
what does following instructions do????
dd gdt
gdt
;something goes here
so does here dd acts as jmp instruction???
-
No, "dd" just declares a dword (32 bits) of data. Unless the label "gdt" is a coincidence, you're probably looking at something like...
gdtr:
dw 23 ; ? size of gdt - 1
dd gdt ; physical(!) address of gdt
gdt:
dd 0, 0
dd 0x0000ffff,0x00cf9a00
dd 0x0000ffff,0x00cf9200
; maybe more descriptors?
Rather than a "jmp", this would be used as:
lgdt [gdtr]
The "trick", besides getting the descriptors right (these are arbitrary), is that the address of gdt in gdtr must be a physical address, not the usual offset:segment address that we encounter almost everyplace else. Happy rebootin'!
Best,
Frank
-
Hi Frank,
gdtr:
dw 23 ; ? size of gdt - 1
dd gdt ; physical(!) address of gdt
gdt:
dd 0, 0
dd 0x0000ffff,0x00cf9a00
dd 0x0000ffff,0x00cf9200
; maybe more descriptors?
so here instruction
dd gdt
will give physical address of label gdt right?
-
Well, no - just an offset... which may be the physical address, depending on where the code is loaded. In a bootsector, with "org 0x7C00", it's the physical address (if the code hasn't been moved). If it's in a .com file, it will have to be adjusted by "segment * 16" at runtime - Nasm doesn't know in which sector dos has chosen to load our file, only that it's loaded at an offset of 0x100 into that segment.
What are you trying to do? (edit) Same thing as last time, back in September?
Best,
Frank
-
Hi,
Ok, actually due to college I did not get time to work on it, so now this time I am trying to build it in two stages, now I am able load second file but have a doubt about "dd gdt " instruction and address or position of gdt in my code......
And also do you know how to make .iso (just trying) in linux of our nasm generated binary code?
-
Okay... back in September we were padding the "first stage" out to 512 bytes, followed by the "second stage", and loading the second stage to 7E00h. If that's still what you're doing, "dd gdt" ought to be the correct(?) physical address.
I've made an .iso in Linux, but to be honest I forget just how it went. Try "man mkisofs", and see if that helps...
Best,
Frank
-
No, I made it but by different way so now this time I am able to load my second file in memory.
But actually I have out about what should be the address of GDT, otherwise I can initialize them anywhere in the code, but does it gonna create problems ahead, I mean where should I put the code for GDT?
Okay I will try "man mkisofs"
Also I tried putting int 15h with function 8300 and 86h for adding timer instead of putting manual delay but int 15h doesnt work any suggestions..???
Thanks.
-
Maybe you want access BIOS time data, for example. Intercepting interruptions, accessing PIT, ...
http://www.abreojosensamblador.net/Productos/AOE/html/Pags_en/Chap17.html
Excuse me, my english is not excellent :-\
-
Maybe you want access BIOS time data, for example. Intercepting interruptions, accessing PIT, ...
http://www.abreojosensamblador.net/Productos/AOE/html/Pags_en/Chap17.html
Excuse me, my english is not excellent :-\
Thanks Buddy,
It's really useful and working fine for me......:)
-
Sorry for the delay - haven't been in the mood to reboot. Due to a brief power glitch, I rebooted into dos and tried out that int 15h/86h delay. A guy over on the AsmCommunity forum also told me that it doesn't work. Works for me...
org 100h
DELAY equ 5000000
DELAYHI equ DELAY >> 16
DELAYLO equ DELAY & 0FFFFh
section .text
mov cx, DELAYHI
mov dx, DELAYLO
mov ah, 86h
int 15h
ret
Haven't tried it from a bootsector, but it "should" work. I don't know what the problem is. If Alfonso's method works, that's probably better anyway (Thanks for that, and for the "hangman" example!). Once you switch to pmode, the BIOS methods won't work anyway, and you'll need that PIT information!
You should be able to put your gdt anywhere you want, as long as "dd gdt" points to it. I probably should have said "linear address" rather than "physical address" - same thing, until you enable paging. I have recently heard that the gdt should be aligned (16 bytes?), but I can't confirm that. Shouldn't hurt.
Lots of information about gdt (and other OSish topics) at http://wiki.osdev.org - check it out if you're not familiar with it!
Best,
Frank
-
A guy over on the AsmCommunity forum also told me that it doesn't work. Works for me...
There are some notes about this function in Ralph Brown's Interrupt List (http://www.ctyme.com/intr/rb-1525.htm).