From: Frank K. <fbk...@zy...> - 2009-08-06 23:32:40
|
zak100 wrote: ... > An then I have a kernel code which includes a file also: > > %include "lib.inc" This is equivalent to cut-and-pasting the include file here. The macro shouldn't be a problem (won't emit anything here) but the isr code is going to be placed here, and will be the first thing executed. When it gets to "iret", the game is over! > mov ax, 7E0H > mov ds,ax > mov es,ax > mov si, msg > > mov ah, 0Eh > mov bx, 7 > top: > lodsb > cmp al, 0 > jz blackhole1 > int 10h > jmp short top > > blackhole1:install 6 6 ??? I should think you'd want 8. Or better yet, 1Ch... Int 6 is the invalid opcode handler, I think... > blackhole: > hlt > jmp blackhole > > msg db 'Welcome to the Kernel!', 0 > msgA db 'Total minutes elapsed since Kernel start is', 0AH, 0DH > clkcounter db 0 > secs db 0 > mins db 0 > > times 0x200-($-$$) db 0 > > > The include file is given below: > > %macro install 1 > push ax > mov al,%1 > mov ah, 0eh > int 10h > pop ax > ;push ds > ;mov ax, 0 mov ds, ax ; ? > ;mov word[%1*4],isr_add > ;mov word[%1*4+2],cs > ;pop ds > %endmacro > You don't want this code at the beginning of your kernel! Move it elsewhere, or jump over it, or something. > isr_add: > cli > inc byte [byte cs:clkcounter] > cmp byte [byte cs:clkcounter],18 > jz handle_secs > sti I think you need to acknowledge the interrupt to the PIC before you "iret", or you'll never get another interrupt. > iret > handle_secs: > mov byte [byte cs:clkcounter],0 > inc byte [byte cs:secs] > cmp byte [byte cs:secs],60 > jz handle_mins > sti > iret > handle_mins: > mov byte [byte cs:secs],0 > inc byte [byte cs:mins] > push ds > push es > > xor ax,ax > mov ds,ax > mov es,ax What are you doing here? "msgA" is at 7E0h:something, isn't it? > ; should probably set up a sane stack here, too. > mov si,msgA ; "our dear string" > > ;mov bx,7 > mov ah,0Eh > msgloop: > lodsb > or al,al > jz end44 > int 10h ; since we're still in RM, we can use bios. Yeah, but we're in the middle of an interrupt handler. Doing an interrupt in the middle of another interrupt can be tricky! What happens if the timer interrupt fires in the middle of the int 10h? This might work, or might hang - I'm not really sure (and haven't tested it). > jmp msgloop > end44: pop es > pop ds > sti > iret > sti > iret > > For compilation I am using following commands: > nasm -f bin bootmz.asm -o boot.bin > > nasm -f obj test_k.asm > > > > alink -oEXE test_k.obj > > > copy /b boot.bin+test_k.exe image.bin > partcopy image.bin 0 323 -f0 > > Can somebody plz help me with this? Looks like some good information here: <http://www.arl.wustl.edu/~lockwood/class/cs306/books/artofasm/Chapter_17/CH17-3.html> Mostly what I find searching around assumes you want to do 32-bit Pmode interrupt handling... The old Rmode stuff must be around somewhere... Best, Frank |