flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
FlashBurn 30 Mar 2006, 04:30
At which address is the code loaded? This is the #1 failure of everyone trying to write code to enter pmode, the address modes! Your in rmode (16bit address) and have segment:offset and to get the 32bit address you have to do segment*16+offset.
In your code you would jump to the address of the label "protected", but the address is somewhere between 0 and 30h and your jump "jmp 0x10:protected" jumps into the nirvana (the rmode int table I guess)! So we need your code segment, the address at which this code is loaded! |
|||
![]() |
|
Dex4u 30 Mar 2006, 08:07
Try that
Code: org 100huse16start:;*****************************; Setting up, to enter pmode.;***************************** cli lgdt [gdtr] mov eax, cr0 or al,0x1 mov cr0,eax jmp 0x10: protected;*****************************; Pmode. Last edited by Dex4u on 30 Mar 2006, 14:10; edited 1 time in total |
|||
![]() |
|
FlashBurn 30 Mar 2006, 11:33
@Dex4u
This also wont work, because you assume that the code is loaded at 0x100! There are 2 options to get the linear address. Calc it at compile time or at run time. I like to know the address at compile time, this is a lot easier! But with this code you could do it also at run time: Code: use16 start: xor eax,eax mov ds,ax mov es,ax mov ss,ax mov sp,0x7c00 push cs pop ax shl eax,4 add [jump.offset],eax add [gdtr.base],eax cli lgdt [gdtr] mov eax,cr0 or ax,1 mov cr0,eax jump: .code: db 0x66,0xea .offset: dd protected .selector: dw 0x10 use32 protected: mov dx,0x3f2 xor eax,eax out dx,al jmp $ use16 gdt: dw 0,0,0,0 dw 0xffff,0,0x9200,0xcf dw 0xffff,0,0x9a00,0xcf gdt_end: gdtr: .limit: dw gdt_end - gdt .base: dd gdt I also think if you just use "org 0x7c00" it will also work, as I assume that your code is loaded at 0x7c00! |
|||
![]() |
|
Dex4u 30 Mar 2006, 14:17
@FlashBurn, i thought he was loading it as a com file, with something like this: http://alexfru.chat.ru/epm.html#bootprog
If that is so it will work, with "org 100h" added. But if he is booting it from a floppy boot sector, it need org 0x7C00 on is original, and assembly it as a bin file and use rawrite, then his original should work, (eg: the one he posted). Note: the com file will not work in window or dosbox. |
|||
![]() |
|
RedGhost 30 Mar 2006, 15:22
Dex4u wrote: @FlashBurn, i thought he was loading it as a com file, with something like this: http://alexfru.chat.ru/epm.html#bootprog you really love bootprog don't you, you seem to post it here alot ![]() just giving you a hard time, the source from that helped me make my first decent bootloader a while back ![]() _________________ redghost.ca |
|||
![]() |
|
Goat6 30 Mar 2006, 16:31
I thank everyone for the tips.
But I'vw tryed many of them and still cant get anywhare. I think I will use '[org 0x100]' and the visit my boot strap code to get the address at which i load the OSLoader file. I am going to continue to visit this thread for more tips so pease dont stop "tipping". Thanks again. ![]() ![]() ![]() ![]() _________________ Death is not the opposite of life but rather the absence of it. |
|||
![]() |
|
FlashBurn 30 Mar 2006, 16:50
@Dex4u
It wont work believe me! You need the right base address and the right address of the label for jumping into pmode and in rmode you either know the segment address or you do it like I have written. |
|||
![]() |
|
Dex4u 30 Mar 2006, 17:58
The code did have base, i did not notice, missing as i cut and paste.
I have Tested this code and it works on my pc's. Code: org 100huse16start:;*****************************; Setting up, to enter pmode.;***************************** xor ebx,ebx mov bx,ds shl ebx,4 mov eax,ebx mov [sys_code + 2],ax mov [sys_data + 2],ax shr eax,16 mov [sys_code + 4],al mov [sys_data + 4],al mov [sys_code + 7],ah mov [sys_data + 7],ah add ebx,gdt mov [gdtr + 2],ebx cli lgdt [gdtr] mov eax, cr0 or al,0x1 mov cr0,eax jmp 0x18: protected;*****************************; Pmode. You need the sys_lin or the base is add to screen pointer. It should print "P" in pmode, run from pure dos or that bootloader. |
|||
![]() |
|
Goat6 30 Mar 2006, 18:32
The source worked thanks dex4u!
![]() ![]() ![]() ![]() _________________ Death is not the opposite of life but rather the absence of it. |
|||
![]() |
|
Dex4u 30 Mar 2006, 18:44
Your welcome.
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.