flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Interrupts screwin' up? (Lol, sounds like rap) Goto page 1, 2 Next |
Author |
|
Niels 22 Sep 2006, 19:20
Hello rhyno_dagreat,
After loading the bootsector at 0x7c00 RHYNLOAD.ASM, you are loading a sector from disk this I assume is RHYNOS.ASM. If this is true: It's more logic setting org 0x0600, but an other problem occurs first, you are including 'interrupts.inc' this means that after jumping from RHYNLOAD.ASM to RHYNOS.ASM, it start to execute 'interrupts.inc' meaning 'already' remapping the pic, and after that executing the isr it gets an iret, that not suppose to happen... |
|||
22 Sep 2006, 19:20 |
|
Artlav 22 Sep 2006, 19:23
Alright...
Main problem is that's this is assembler, not HLL. So, you should think in assembler terms. ================================ Let's start from the middle. Bootloader: Code: mov ax, 0060h mov es, ax mov bx, 0000h mov ah, 02h mov al, 1 mov ch, 0 mov cl, 2 mov dh, 0 ;mov dl, 0 ; Not sure if needed, been told that dl already contains the drive that was booted on int 13h Loads only one sector, while your OS uses 4. That leaves behind the idt and handlers (or most of the code in the original layout). So, put 4 in the al. ================================ Second, putting include 'interrupts.inc' org 0000h use16 in the beginning makes "Reroute_PICs" your entry point. Position of the code from the included file will be the position of the include directive, unlike HLL's , position matters in asm. So, put it(include 'interrupts.inc') in the very end. ------------------------------------- Then it all goes fine in this file. ------------------------------------- Now, let's move to the top. "Reroute_PICs" have no ret at the end, so after it the isr0 code is called, causing TF. ------------------------------------- At that point program becomes show-functional. ------------------------------------- About interrupts - your IDT doesn't seems to have any sense in it, so redo this part, if you want handling int's |
|||
22 Sep 2006, 19:23 |
|
Niels 22 Sep 2006, 19:36
Hello rhyno_dagreat,
Just a thought.... You have made a sort of template for the isr's... To me it looks like a very unlogic and slow template. If you want such a template with all push and pops, comment( them, until really needed, meaning let fs be fs if it isn't used in your isr-function. Niels. |
|||
22 Sep 2006, 19:36 |
|
Niels 22 Sep 2006, 20:07
Hello rhyno_dagreat,
Artlav is right about the amount of sectors. One solution is just fill in a large amount of sectors. An other is, putting this line at the end of RHYNOS.ASM: times (512*N)-($-$$) db 0 Were N is the amount of sectors to be loaded, when you get an error-message from FASM, you know you gotta raise N and al. |
|||
22 Sep 2006, 20:07 |
|
Niels 22 Sep 2006, 20:12
For the record: I use "repeat end repeat" instead of "times" but I guess FASM being a good assembler you get the same 'error' when 512*N is lower than 0.
|
|||
22 Sep 2006, 20:12 |
|
Niels 22 Sep 2006, 20:25
What I also 'miss' is CLI before mode-switching and remapping the PIC.
I do see you have commented one out. Niels. |
|||
22 Sep 2006, 20:25 |
|
rhyno_dagreat 22 Sep 2006, 21:16
Thank you Niels!, and to Artlav, Спасибо!
The only thing is that I'm still very new to how the IDT works, and I'm using the tutorials at [url] http://www.osdever.net/tutorials.php?cat=5&sort=1 [/url] namely, the three at the bottom. If someone could explain it a bit better, maybe I could write something better, and I'd be greatly appreciative. Again, thank you! |
|||
22 Sep 2006, 21:16 |
|
rhyno_dagreat 23 Sep 2006, 00:23
Hey again! It worked in a way. The stuff is coming up, but it's flashing between the text and a group of numbers (not my error message). So I don't know what's up with that. Could it be that I haven't created my code for the A20 line yet? Sorry, still new to OSdev.
|
|||
23 Sep 2006, 00:23 |
|
Niels 23 Sep 2006, 11:09
I don't think the idt is right but didn't check on that, I left most code the way you put it.
Code: ;BOOTSTART use16 org 7C00h RHYNOS.ASM equ 0x0600 BOOTDRIVE equ 0x05ff start: xor ax, ax mov ds, ax mov es,ax mov byte [BOOTDRIVE],dl mov si, message call bios_print load_os: mov bx, RHYNOS.ASM mov ah, 02h mov al, 4 mov ch, 0 mov cl, 2 mov dh, 0 mov dl, [BOOTDRIVE] int 13h ; There should be a check here, before continue cli call Reroute_PICs jmp 0:0x0600 bios_print: lodsb or al, al jz done mov ah, 0x0E int 0x10 jmp bios_print done: ret Reroute_PICs: mov al, 11h out 20h, al out 0A0h, al mov al, 20h out 21h, al mov al, 28h out 0A1h, al mov al, 04h out 21h, al mov al, 02h out 0A1h, al mov al, 01h out 21h, al out 0A1h, al mov al, 0FFh out 021h, al ret ;DATA message db 'Loading RhynOS...',13,10,0 ;BOOTEND times 510-($-$$) db 0 dw 0xAA55 include 'RHYNOS.ASM' Code: use16 org 0x0600 cli lgdt [gdt_descriptor] mov eax, cr0 inc eax mov cr0, eax mov ax, 10h mov ds, ax mov es, ax mov ss, ax mov esp, 090000h jmp 0x08:clear_pipe gdt: dd 0, 0 gdt_code: db 0FFh, 0FFh, 0, 0, 0, 10011010b, 11001111b, 0 gdt_data: db 0FFh, 0FFh, 0, 0, 0, 10010010b, 11001111b, 0 gdt_end: gdt_descriptor: dw gdt_end - gdt - 1 dd gdt use32 clear_pipe: mov byte [0B8000h], 'H' mov byte [0B8001h], 1Bh mov byte [0B8002h], 'e' mov byte [0B8003h], 1Bh mov byte [0B8004h], 'l' mov byte [0B8005h], 1Bh mov byte [0B8006h], 'l' mov byte [0B8007h], 1Bh mov byte [0B8008h], 'o' mov byte [0B8009h], 1Bh mov byte [0B800Ah], '!' mov byte [0B800Bh], 1Bh lidt [idtp] ;sti infinite_loop: jmp $ include 'interrupts.inc' Code: ;INTERRUPTS!!! YAY isr0: mov byte [ds:0B8000h], 'E' mov byte [ds:0B8001h], 1Bh mov byte [ds:0B8000h], 'r' mov byte [ds:0B8001h], 1Bh mov byte [ds:0B8000h], 'r' mov byte [ds:0B8001h], 1Bh mov byte [ds:0B8000h], '0' mov byte [ds:0B8001h], 1Bh mov byte [ds:0B8000h], '0' mov byte [ds:0B8001h], 1Bh iret idt_start: ;int0 dw 0x0000 dw 0x10 dw 0x8E00 dw 0x10 ;int1 dw 0x0000 dw 0x10 dw 0x8E00 dw 0x10 ;int2 dw 0x0000 dw 0x10 dw 0xE00 dw 0x10 ;int3 dw 0x0000 dw 0x10 dw 0x8E00 dw 0x10 ;int4 dw 0x0000 dw 0x10 dw 0x8E00 dw 0x10 ;int5 dw 0x0000 dw 0x10 dw 0x8E00 dw 0x10 ;int6 dw 0x0000 dw 0x10 dw 0x8E00 dw 0x10 ;int7 dw 0x0000 dw 0x10 dw 0x8E00 dw 0x10 ;int8 dw 0x0000 dw 0x10 dw 0x8E00 dw 0x10 ;int9 dw 0x0000 dw 0x10 dw 0x8E00 dw 0x10 ;int10 dw 0x0000 dw 0x10 dw 0x8E00 dw 0x10 ;int11 dw 0x0000 dw 0x10 dw 0x8E00 dw 0x10 ;int12 dw 0x0000 dw 0x10 dw 0x8E00 dw 0x10 ;int13 dw 0x0000 dw 0x10 dw 0x8E00 dw 0x10 ;int14 dw 0x0000 dw 0x10 dw 0x8E00 dw 0x10 ;int15 dw 0x0000 dw 0x10 dw 0xE00 dw 0x10 ;int16 dw 0x0000 dw 0x10 dw 0x8E00 dw 0x10 idt_end: idtp: dw idt_end - idt_start - 1 dd idt_start |
|||
23 Sep 2006, 11:09 |
|
Niels 23 Sep 2006, 11:16
fasm RHYNLOAD.ASM RHYNLOAD.BIN
Will get you to jmp $ The second CLI is not needed. I commented the STI, before enabling the idt must be correct. |
|||
23 Sep 2006, 11:16 |
|
Niels 23 Sep 2006, 11:58
In this particular case: A tutorial should explain to you, what you couldn't extract from the (Intel/AMD) manual.
|
|||
23 Sep 2006, 11:58 |
|
Niels 23 Sep 2006, 12:57
To give you the idea:
;int0 dw isr0 ; Start-address of interrupt, first 16 bits dw 0x10 ; Segment which hold the isr-code ; 5432109876543210 ; bit15 = Present, bit11 = 16/32-bit, bit10 = part of typecode, bit9 = part of typecode dw 1000111000000000b dw 0 ; Since the start-address of int0 is not more than 16-bit, we won't be needing the 2nd offset (16-31) other than to be 0. Intel page.192 |
|||
23 Sep 2006, 12:57 |
|
Niels 23 Sep 2006, 13:46
As we are just signals, let my carrier be wise.
Amen. |
|||
23 Sep 2006, 13:46 |
|
rhyno_dagreat 23 Sep 2006, 21:49
Neils, thank you for all the help, but Artlav put something in his previous post that I missed completely.
Quote:
That's what the problem was. The Reroute_PICs didn't do a return so it continued on into ISR0 making the emulator constantly Triple-Fault and reboot. Talk about embarrassment! Anyways, sorry man! On a slightly different note though, is it possible to use stosb or lodsb to put my strings of characters into Video Memory instead of typing everything out? |
|||
23 Sep 2006, 21:49 |
|
rhyno_dagreat 23 Sep 2006, 22:53
Okay, I tried to put an error in the code on purpose to test it (A divide by zero), and all that happens is my emulator triplefaults and reboots constantly.
Basically I don't think the IDT is being read from. Could anyone help with that? Also, in NASM you can do [section .text] and [section .data]. Is there an equivalent to that in FASM? Thanks! EDIT: I just realized that the IDT is being read from, but the IDT isn't recognizing the ISRs because I didn't put in them as the start address, like Neils told me to. Unfortunately, the first ISR isn't coming up, and cli'ing and hlt'ing like I want it to, and it's still triple-faulting and resetting constantly. |
|||
23 Sep 2006, 22:53 |
|
Dex4u 23 Sep 2006, 23:48
If you look at your
Code: ;int0 dw 0x0000 dw 0x10 <******* this should be code ***** dw 0x8E00 dw 0x10 ;int1 You are using data Maybe try something lik this: Code: ;int0 dw int0 dw 0x8 dw 0x8E00 dw 0x10 ;int1 |
|||
23 Sep 2006, 23:48 |
|
rhyno_dagreat 24 Sep 2006, 00:19
IT WORKS DEX! THANKS!!! But... Okay, I'm still very new to OSDevin' in ASM, and I pulled most of that code from tutorials and help along the way, all in mostly a learning expericence, and just to clarify: You figured out the code segment because that's where the jump to from 16bit mode occured, right? The jump I'm talking about is the:
Code: jmp 08h:clear_pipe Where 08h is the code SEGMENT and clear_pipe is the OFFSET, correct? If I'm way off, I'd be happy for some assistance with this. Also, I'm wondering why I need to do that far jump to access PMode instead of just going through things linearly (Y'see, the tutorial I used to learn this wasn't the best in the world, it had good code though which is why I chose it, also it was a rare tutorial in the fact that it didn't use GRUB to act as a bootloader). Anyways, thanks for the help! |
|||
24 Sep 2006, 00:19 |
|
Dex4u 24 Sep 2006, 01:24
If you go here: http://my.execpc.com/CE/AC/geezer/os/
get: Intel 386 Programmer's Reference Manual and also get these 12 tuts Protected-mode demo code There is enough info to get you started. Good luck . |
|||
24 Sep 2006, 01:24 |
|
rhyno_dagreat 24 Sep 2006, 02:04
Thanks again Dex. BTW, I tried your OS, and may I say it's pretty freakin' awesome man. Keep up the good work!
|
|||
24 Sep 2006, 02:04 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.