Page 1 of 1

ISRs Not Working!

Posted: Mon Jan 29, 2007 2:16 am
by pcmattman
Hi all... I've written the following ISR for interrupt 1C (NASM):

Code: Select all

timerInt:

	pusha

	inc word [tc]					; increment the counter

	popa

	iret
There is no evidence at all of the incrementing of the value, and the only way I've been able to test that the ISR is firing is by adding in code to print the current value of tc, which works but because my ISR runs every time a timer interrupt happens, thousands of numbers just fill the screen...

Any ideas?

Posted: Mon Jan 29, 2007 2:59 am
by AJ
Hi,

1. One thought about the debugging - if you print a dot between each number and run in an emulator, when you pause the emulator you will be able to see if the number really does increment by one every time.

2. If you are not using any registers in your ISR, do you need to pusha and popa?

3. Is a word value enough to hold your system's tick counter?

4. If you are trying to read the value 'tc' in c (i assume you're not yet as there is no leading underscore), be careful that you are reading the value from memory every time. If you have just set up a loop to check the value, most compilers will just move the value to a register and keep reading the value from there. Use of the word 'volatile' will prevent this.

Hope some of this helps!
Cheers,
Adam

Posted: Mon Jan 29, 2007 9:36 am
by mathematician
How many segments do you have? The isr contains no code to load ds, or use a segment override.

Posted: Tue Jan 30, 2007 12:37 am
by pcmattman
I've since modified the code to load the correct data segment, thinking it might be that. I've tried this:

Code: Select all

timerInt:

	pusha
	push ds

	mov ds,word [tc_ds]

	mov al,'.'
	mov ah,0x0e
	mov bx,0x0007
	int 0x10

	inc word [ds:tc]

	pop ds
	popa

	iret
This works, but again, the counter is not incremented globally. I've tried putting it into the 'uninitialized data' section ie. bss but it still does not increment. It seems the only way I can access the data is from inside the ISR...

Posted: Tue Jan 30, 2007 1:00 am
by pcmattman
Problem solved, just had to change

Code: Select all

inc word [ds:tc]
to

Code: Select all

inc word [cs:tc]
Does anyone know the clock rate on a 2 year old pc? And what is the clock rate in QEMU?

Posted: Thu Feb 01, 2007 12:45 am
by XCHG
Okay one thing I can add to this post is that creating variables in your code segment specially when all scattered around is a bad practice. Your code would easily get unaligned and you will run into troubles every now and then specially in real mode. It would be better if you could put all your data in your Data Segment and thus use the default addressing mode rather than specifying the code segment explicitly.

Posted: Thu Feb 01, 2007 12:47 am
by pcmattman
Good idea! Didn't think of doing that because I was using a header from another assembly kernel. Now I can say it's officially my kernel :D .