Hi,
nitinjavakid wrote:Actually, I want to execute the temp: part again and again continuously. So, I thought interrupt 08h which is a timer interrupt would do it continuously. But this thing is getting executed only twice:( Not continuously. Any suggestions?
To be honest, I'm surprised it worked at all - your IRQ handler trashes registers in use by anything it interrupts. It also looks like you're getting your segments mixed up, assuming DS is normally equal to CS (DS can't be 0x0000 and 0x7C00 at the same time), which it should be unless you're using a really messed up linker script.
When the IRQ handler calls "print" it pushes 4 bytes and then pops 2 bytes. There's also no need to disable and then re-enable IRQs (the CPU does this automatically anyway).
The IRQ handler can't assume that the direction flag is set or cleared, so instructions like "lodsb" might go backwards (decrement SI instead of incrementing it). The code for "print" doesn't need a stack frame either, and it's a waste of time pushing it's arguments on the stack. I also like to write functions (like print) so they don't trash registers either - it makes it much easier to maintain the code.
Lastly, I have no idea how the assembler allowed something like "
mov cs,[prevcsaddress]" to assemble.
Code: Select all
;storing previous interrupt address
mov ax,0
mov ds,ax
mov ax,[ds:08h*4]
mov [cs:prevaddress], ax
mov ax, [ds:08h*4 + 2]
mov [cs:prevaddress + 2], ax
;putting in new interrupt address
; mov ax,0 <- not needed
; mov ds,ax <- not needed
mov word [ds:08h*4], temp
mov word [ds:08h*4 + 2],0x07c0
Code: Select all
;IRQ handler
temp:
push si
mov si,msg
call _print
mov si,msg1
call _print
pop si
jmp far [cs:prevaddress]
;Print the string at CS:SI
_print:
pusha
cld ; <- needed for "lodsb"
mov ah,0x0e
mov bh,0
loopprint:
cs lodsb ;Use CS segment override to avoid messing with segment registers
cmp al,00
je exitprint
int 0x10
jmp loopprint
exitprint:
popa
ret
msg db 'Welcome to the world of amazing things.',13,10,0
msg1 db 'I feel great pleasure in providing you with nothing',0
prevaddress dw 0,0
BTW I'd recommend using CS = DS = 0, and then putting "org 0x7C00" at the start of your boot loader (it makes things easier to figure out).
Cheers,
Brendan