flat assembler
Message board for the users of flat assembler.

Index > OS Construction > What's wrong?

Author
Thread Post new topic Reply to topic
§-Death_Reaver-§



Joined: 03 Aug 2006
Posts: 10
Location: Italy
§-Death_Reaver-§
Hi,
Can somebody help me with this? (i am a noob Sad )


Description:
Download
Filename: OS.rar
Filesize: 1.75 KB
Downloaded: 60 Time(s)


_________________
§-Death_Reaver-§

[my site: deathreaver.altervista.org]
[UIC site: quequero.org]
Post 08 Dec 2006, 15:54
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 559
smiddy
Hi,

What do you need help with?

I did a cursory look through the code but I didn't see anything blatent that jump out at me. Are you having a problem?
Post 09 Dec 2006, 05:05
View user's profile Send private message Reply with quote
§-Death_Reaver-§



Joined: 03 Aug 2006
Posts: 10
Location: Italy
§-Death_Reaver-§
well, when i execute it with bochs, after show my strings, it reboot continually

After some tries, i think that the problem can be:
1) GDT
2) ProtectMode switching

thanks
(and xcuse me for my english!) Very Happy

_________________
§-Death_Reaver-§

[my site: deathreaver.altervista.org]
[UIC site: quequero.org]
Post 09 Dec 2006, 08:33
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 559
smiddy
First thing I see, change the ESP from A0000h to A0000h - 4, A0000 is in the Video Memory area (not really a problem unless you try to use it later on).

Place the label liberta after the use32, this makes that label 32 bits and not 16 bits.

Everything after include "ia32main.asm" is presumed 32bit addressing, and you're calling the variables in the SI, while this may work initially, once the program gets bigger you will end up with problems. Place all the text variables and anything used in the 16bit environment before the include.

Does "Passaggio in Protected Mode...." displayed?

Your English is fine, my Italian is none existant, unless I can use some Latin based words...from Spanish. Wink
Post 09 Dec 2006, 16:39
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7718
Location: Kraków, Poland
Tomasz Grysztar
smiddy wrote:
Place the label liberta after the use32, this makes that label 32 bits and not 16 bits.

This doesn't matter for a label.
Post 09 Dec 2006, 16:49
View user's profile Send private message Visit poster's website Reply with quote
§-Death_Reaver-§



Joined: 03 Aug 2006
Posts: 10
Location: Italy
§-Death_Reaver-§
smiddy wrote:

Does "Passaggio in Protected Mode...." displayed?


yes, it is displayed, but if you look in the code, i create a little function to wait until user press a key (dbg_wait). I tried to use it before and after the switching (mov eax,cr0 etc.): before it work fine, after it isn't executed.

_________________
§-Death_Reaver-§

[my site: deathreaver.altervista.org]
[UIC site: quequero.org]
Post 09 Dec 2006, 21:23
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 559
smiddy
I see the issue, I think, change this:

Code:
liberta:
use32
    mov ax,8+8
    mov ds,ax
    mov es,ax
    mov ss,ax
    xor eax,eax
    mov esp,0x000A0000

    jmp $
    cli
    hlt
    


to this:

Code:
liberta:
use32
    mov ax,018h                 ; Point to Data Segment (not code)
    mov ds,ax
    mov es,ax
    mov ss,ax
    xor eax,eax
    mov esp,(0A0000h - 4)

    jmp $
    cli
    hlt
    


Then change your GDT from:

Code:
GDT:
    dw 16
    dd NULLO

dd 0  ;_______________________________________

NULLO db 8 dup(0)

CODICE:
    dw  0xFFFF      ;limit 0-15
    dw  0x0000      ;base 0-15
    db  0x00        ;base 16-23
    db  9Ah     ;1 00 1 1-010
    db  0CFh        ;1 1 0 0 1111
    db  0x00        ;base 24-31

DATI:
    dw  0xFFFF      ;limit 0-15
    dw  0x0000      ;base 0-15
    db  0x00        ;base 16-23
    db  92h
    db  0CFh
    db  0x00        ;base 24-31

_end:
    


To this:

Code:
GDT:

    dd 0
    dd 0  ;_______________________________________

CODICE:
    dw  0xFFFF      ;limit 0-15
    dw  0x0000      ;base 0-15
    db  0x00        ;base 16-23
    db  9Ah     ;1 00 1 1-010
    db  0CFh        ;1 1 0 0 1111
    db  0x00        ;base 24-31

DATI:
    dw  0xFFFF      ;limit 0-15
    dw  0x0000      ;base 0-15
    db  0x00        ;base 16-23
    db  92h
    db  0CFh
    db  0x00        ;base 24-31

_end:    



Here is mine for comparison:

Code:
GDT:

; Index = 0h
    dd 0                ; NULL Descriptor
    dd 0                ; NULL Descriptor

; Index = 8h
GDT_DATA_LINEAR_SELECTOR:

    dw 0FFFFh           ; (8h) linear Data segment, read/write, expand down
    dw 0
    db 0
    db 10010010b
    db 11001111b
    db 0
;Index = 10h
GDT_CODE_SELECTOR:

    dw 0FFFFh           ; limit00 to limit15=0xFFFFF=4GigaByte
    dw 00000h           ; base00 to base15=0x0000
    dw 09A00h           ; 0x9=1001=P/DPL/S  0xA=1010=Type=code/nonconforming/read
    dw 000CFh           ; granularity=4096, 386 (+5th nibble of limit)

; Index = 18h
GDT_PMODE_DATA_SELECTOR:

    dw 0FFFFh           ; 4Gb - (0x100000*0x1000 = 4Gb)
    dw 00000h           ; base address=0
    dw 09200h           ; data read/write
    dw 000CFh           ; granularity=4096, 386 (+5th nibble of limit)

    


Your code should just halt now. It looks like your GDT wasn't quite right forcing a reboot when ever you tried your code.

@Tomasz; Can I assume that when a label is used then the bits matter? In other words, if I did jmp liberta from 16bit code, the label would be put into the opcode as 16 bits, thus the same jump in 32bits would yeild an opcode associated with 32-bits (like wise 64-bits too?), is this correct?
Post 09 Dec 2006, 22:31
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7718
Location: Kraków, Poland
Tomasz Grysztar
smiddy wrote:
@Tomasz; Can I assume that when a label is used then the bits matter? In other words, if I did jmp liberta from 16bit code, the label would be put into the opcode as 16 bits, thus the same jump in 32bits would yeild an opcode associated with 32-bits (like wise 64-bits too?), is this correct?

Yes. The labels are affected by settings like ORG, while the USE16/USE32/USE64 affect the instructions.
Post 09 Dec 2006, 23:14
View user's profile Send private message Visit poster's website Reply with quote
Goplat



Joined: 15 Sep 2006
Posts: 181
Goplat
smiddy wrote:
First thing I see, change the ESP from A0000h to A0000h - 4, A0000 is in the Video Memory area (not really a problem unless you try to use it later on).


When you push something, (E)SP is decremented before the value is stored. Initializing the stack pointer to A0000 is fine.
Post 10 Dec 2006, 00:14
View user's profile Send private message Reply with quote
§-Death_Reaver-§



Joined: 03 Aug 2006
Posts: 10
Location: Italy
§-Death_Reaver-§
Thanks for your help Very Happy Very Happy

_________________
§-Death_Reaver-§

[my site: deathreaver.altervista.org]
[UIC site: quequero.org]
Post 10 Dec 2006, 09:25
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
§-Death_Reaver-§



Joined: 03 Aug 2006
Posts: 10
Location: Italy
§-Death_Reaver-§
... i have still the same problem Crying or Very sad ...
Anyway, i tried to set bochs to stop and let me see exception:
it show this:
Code:
 CPU 0
exception(): 3rd (13) exception with no resolution    

Why?

_________________
§-Death_Reaver-§

[my site: deathreaver.altervista.org]
[UIC site: quequero.org]
Post 10 Dec 2006, 09:44
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
§-Death_Reaver-§



Joined: 03 Aug 2006
Posts: 10
Location: Italy
§-Death_Reaver-§
Here the updated code, now it work quite good: Very Happy


Description:
Download
Filename: OS2.rar
Filesize: 1.84 KB
Downloaded: 47 Time(s)


_________________
§-Death_Reaver-§

[my site: deathreaver.altervista.org]
[UIC site: quequero.org]
Post 10 Dec 2006, 12:35
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 559
smiddy
Yep, I goofed when I said change it to 18h, as you did to make it 10h for the data segments (descriptors).
Post 10 Dec 2006, 15:03
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.