flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Teehee 08 Mar 2011, 17:38
i will highlight some mistakes, but I'm noob, so do not believe me too much:
Code: ORG 7C00h USE16 CLI PM: lgdt [cs:GDT_DESC] mov eax, cr0 bts eax, 0h mov cr0, eax jmp 08h:anarchy USE32 ; ########## use here instead anarchy: mov ax, 10h mov ss, ax mov ds, ax mov esp, 90000h ; ###### you need to enable a20 in order to access this address Video_out: mov byte [0B8002h], 'H' ; ###### i'm not sure if you can do this in PM mov byte [0B8003h], 01Fh ; ### idem times 1890 db 0 ; ############ Wrong: boot sector should be 512 bytes wide GP dw 0h PModemsg db ' Welcome to the Protected mode!!' ScanPCImsg db ' Scanning PCI-PCIX-PCIE devices...' GDT_DESC: dw GDT_ENDS - GDT_STARTS -1 ; ############ need to be size - 1 dq GDT_STARTS GDT_STARTS: GDT_REC0 dq 0h GDT_REC1 dw 0FFFFh dw 0h db 0h db 10011010b db 11001111b db 0h GDT_REC2 dw 0FFFFh dw 0h db 0h db 100[0]1001b ; ###### highlighted zero must be 1, no?, also: maybe you want 0010b in the end, if this is a data descriptor db 11001111b db 0h GDT_ENDS: ; ######## times 510 - size should come here dw 0xAA55 _________________ Sorry if bad english. |
|||
![]() |
|
BOTOKILLER 08 Mar 2011, 17:50
Teehee wrote: i will highlight some mistakes, but I'm noob, so do not believe me too much: im making cd bootsector, its 2048 bytes and what about debugger??? |
|||
![]() |
|
Teehee 08 Mar 2011, 17:58
so me fail again? dam
![]() debug i know is http://www.ollydbg.de/ (idk if it debug bin) and Bochs debugger (it does). _________________ Sorry if bad english. |
|||
![]() |
|
Dex4u 08 Mar 2011, 19:19
use a floppy boot code eg:
Code: org 0x7C00 use16 ;**************************** ; Realmode startup code. ;**************************** start: xor ax,ax mov ds,ax mov es,ax mov ss,ax mov sp,0x7C00 ;***************************** ; Setting up, to enter pmode. ;***************************** cli lgdt [gdtr] mov eax, cr0 or al,0x1 mov cr0,eax jmp 0x10: protected ;***************************** ; Pmode. And write CD using floppy emulation. |
|||
![]() |
|
egos 09 Mar 2011, 07:25
BOTOKILLER wrote: Hi everyone, ![]() Code: ORG 7C00h USE16 CLI lgdt [cs:GDT_DESC] ; can be written before "CLI". Do you know what value cs holds? I don't. Maybe 7C0h or something else mov eax, cr0 bts eax, 0h ; "or al, 1" is more compact and effective mov cr0, eax USE32 jmp 08h:anarchy ; should be written before "USE32" but it should be kept 32-bit (with prefix). Add word "pword" or "fword" anarchy: mov ax, 10h mov ss, ax mov ds, ax mov esp, 90000h ; it is better to put it directly after "mov ss, ax" mov byte [0B8002h], 'H' ; are you sure that videobuffer starts at 0B8000h? Add "mov ax, 3" and "int 10h" before "CLI" for more reliability mov byte [0B8003h], 01Fh times 1890 db 0 ; wow! Replace it with "jmp $" and add "rb 83FEh-$" under boot signature GDT_DESC: dw GDT_ENDS - GDT_STARTS ; and minus 1 dq GDT_STARTS ; "dd" still enough |
|||
![]() |
|
BOTOKILLER 09 Mar 2011, 09:04
egos wrote:
thanks, it seems to work(no error message), at least for now=), i think problem was there: Code: jmp 08h:anarchy i corrected it like this Code: jmp fword 08h:anarchy and what about debugger????????? olydbg couldnt debug bin file, any other debuggers for windows?? |
|||
![]() |
|
edfed 09 Mar 2011, 14:11
Teehee wrote: i will highlight some mistakes, but I'm noob, so do not believe me too much: helping others, and try to find mistakes in the code from others it is a very good way to learn. ![]() |
|||
![]() |
|
Coty 09 Mar 2011, 14:39
BOTOKILLER wrote: and what about debugger????????? I believe Bochs emulator has built in debug? I would not know to much as I never use debugers ![]() |
|||
![]() |
|
b1528932 09 Mar 2011, 15:17
Quote: lgdt [cs:GDT_DESC] ; can be written before "CLI". Do you know what value cs holds? I don't. Maybe 7C0h or something else You do not care. Your code must be position independent. you address GDT_DESC using a register + displacement. Use near call to get offset, and cs to get cs. it should be like this: Code: ;here bios start executing ur bootsector call near _code IDT: dw ? dd ? GDT: dw ? dd ? _code: pop bx lgdt [cs:bx + 6] lidt [cs:bx] ... Code: bts eax, 0h ; "or al, 1" is more compact and effective bt* suck, not avaiable on 8086. use or/and instead. Code: mov ax, 10h mov ss, ax mov ds, ax mov esp, 90000h ; it is better to put it directly after "mov ss, ax" no, its retarded to put it anywhere else. Even with clear IF you can still get NMI or exception. |
|||
![]() |
|
poupougne 09 Mar 2011, 16:13
I already debug with Bochs built-in debugger, and that was helpfull !
|
|||
![]() |
|
egos 09 Mar 2011, 16:21
b1528932 wrote:
Code: xor ax,ax mov ds,ax lgdt [GDTR] _________________ If you have seen bad English in my words, tell me what's wrong, please. |
|||
![]() |
|
BOTOKILLER 13 Mar 2011, 09:07
YEAH!!!!
I MADE IT!! the problem was there: Code: lea eax, [GDT_DESC] lgdt [eax] it just couldnt load GDTR without effective address i found debugger in VirtualBox, here what it writes: VirtualBox wrote: VBoxDbg> dg |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.