flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Question about int 13h |
Author |
|
Tomasz Grysztar 11 Mar 2006, 10:52
At first sight: you put the code at address 0, where the real mode IDT usually resides. The interrupts won't work then, and any interrupt will cause the system to crash. You can put the CLI at the very beginning of loader to avoid it, but you cannot use the INT 10h then in your code (since you have sucessfully destroyed the interrupt table by writing this code there). So there are two options: either forget the interrupts at all, put the CLI at the beginning of loader and replace calls to INT 10h with writes to 0B800h segment; OR choose some memory area for your code that is not used by interrupt table or BIOS already.
|
|||
11 Mar 2006, 10:52 |
|
Giedrius 11 Mar 2006, 10:58
Thanks for your reply. Could you advice me at which location to put the code? What memory locations are used by the system?
|
|||
11 Mar 2006, 10:58 |
|
Tomasz Grysztar 11 Mar 2006, 11:09
You can look at the MEMORY.LST file from Ralph Brown's Interrupt List (it's in inter61c.zip) to find out what memory areas are usually used for what purposes. As you can find there out, DOS usually used the 0060h:0000h or 0070h:0000h addresses for loading its code at startup - so you may try those.
|
|||
11 Mar 2006, 11:09 |
|
Giedrius 11 Mar 2006, 13:37
Could you edit my code, so it reads the code to 0060h:0000h and jumps to it? I'm having a problem with understanding the memory managment...
|
|||
11 Mar 2006, 13:37 |
|
Borsuc 11 Mar 2006, 13:46
well, use a jmp 0060:0000 instead of jmp 0000:0000
and I suggest you put your kernel in another file, and put something like ORG 0000h, and load some the required segment registers with 0060. Though, you need to read the sectors off the floppy in that 0060 area before you jump. (try int 0x10 with ah=02h function. see Ralph Brown's list) About you being not experienced in memory management: i strongly suggest you learn a bit more. Designing an OS requires a solid knowledge of memory management, believe me. |
|||
11 Mar 2006, 13:46 |
|
doubletoker 15 Mar 2006, 16:00
the problem I see is that you overwrite some of the IVT, the way int 13 works is it transfers data from the chs to es:bx and right before you called it, you ran this code
Code: mov ah,2 mov al,1 mov bx,ax which would write the sector to 0x00000201h in memory, a good thing is you didn't over write int 13 or 10 so you could still use it, anyway after you load it at that address you jump to address 0 which you didn't load it at 0 like you thought, like said before the first memory address 600h segment 60h is the first place application ram starts at, which is a good loading point bx = 0 and es = 60h -pz |
|||
15 Mar 2006, 16:00 |
|
Giedrius 16 Mar 2006, 12:01
Can somebody alter my code, so it works? I can't get it to work :/ I probably need some working code examples. The FAT12 loader from the site is a bit too complex for me.
|
|||
16 Mar 2006, 12:01 |
|
log(21 09 Jun 2006, 23:05
Try this code. (I have written a loader, I'm not at the computer with it currently, but this code should work):
org 0x7C00 push cs pop ds mov ah, 02h ;Set for reading mov al, 1 ;Number of sectors to load mov cl,1 ;Starting sector mov ch,0 ;Cylinder number mov dh,0 ;Head number mov dl,0 ;Drive number ;Set data segment for reading mov bx, 0600h mov es, bx mov bx, 0 int 0x13 ;Read the sector(s) jmp 0600:0000 ;Kernal is loaded at 0600h:0000h |
|||
09 Jun 2006, 23:05 |
|
LocoDelAssembly 10 Jun 2006, 00:14
Code: org 0x7C00 use16 xor ax, ax cli mov ss, ax mov sp, $7C00 sti mov ds, ax mov ah,2 mov al,1 mov bx, 0600h mov cl,2 ; LOAD THE NEXT SECTOR!!! mov ch,0 mov dh,0 mov dl,80h int 0x13 jmp $0060:kernel_start times 510-($-$$) db 0x00 dw 0xAA55 org 0x0000 kernel_start: push cs push cs push ss pop es pop ds cli pop ss xor sp, sp sti xor ax,ax mov dx,ax mov si,string call write_str cli hlt write_str: mov ah,0x0E mov bh,0x00 mov bl,0x17 .nextchar: lodsb or al,al jz .return int 0x10 jmp .nextchar .return: ret string db 'Hello',13,10,0 times 512-($-kernel_start) db 0x00 Works in QEMU Regards |
|||
10 Jun 2006, 00:14 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.