flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > What's wrong? |
Author |
|
§-Death_Reaver-§ 08 Dec 2006, 15:54
Hi,
Can somebody help me with this? (i am a noob )
_________________ §-Death_Reaver-§ [my site: deathreaver.altervista.org] [UIC site: quequero.org] |
|||||||||||
08 Dec 2006, 15:54 |
|
smiddy 09 Dec 2006, 05:05
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? |
|||
09 Dec 2006, 05:05 |
|
smiddy 09 Dec 2006, 16:39
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. |
|||
09 Dec 2006, 16:39 |
|
Tomasz Grysztar 09 Dec 2006, 16:49
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. |
|||
09 Dec 2006, 16:49 |
|
§-Death_Reaver-§ 09 Dec 2006, 21:23
smiddy wrote:
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] |
|||
09 Dec 2006, 21:23 |
|
smiddy 09 Dec 2006, 22:31
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? |
|||
09 Dec 2006, 22:31 |
|
Tomasz Grysztar 09 Dec 2006, 23:14
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. |
|||
09 Dec 2006, 23:14 |
|
Goplat 10 Dec 2006, 00:14
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. |
|||
10 Dec 2006, 00:14 |
|
§-Death_Reaver-§ 10 Dec 2006, 09:25
Thanks for your help
_________________ §-Death_Reaver-§ [my site: deathreaver.altervista.org] [UIC site: quequero.org] |
|||
10 Dec 2006, 09:25 |
|
§-Death_Reaver-§ 10 Dec 2006, 09:44
... i have still the same problem ...
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] |
|||
10 Dec 2006, 09:44 |
|
§-Death_Reaver-§ 10 Dec 2006, 12:35
Here the updated code, now it work quite good:
_________________ §-Death_Reaver-§ [my site: deathreaver.altervista.org] [UIC site: quequero.org] |
|||||||||||
10 Dec 2006, 12:35 |
|
smiddy 10 Dec 2006, 15:03
Yep, I goofed when I said change it to 18h, as you did to make it 10h for the data segments (descriptors).
|
|||
10 Dec 2006, 15:03 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.