Jump to content

Timer Interrupt Issue

- - - - -

  • Please log in to reply
7 replies to this topic

#1
mebob

mebob

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 490 posts
I also have another problem with another program:

section .text


mov bx,0xb800

mov es,bx

mov byte[es:0],'a'

mov byte[es:1],0x07

mov bx,0

mov es,bx

mov ax,cs

mov word[es:32],handler

mov word[es:34],0x07c0


mov al,00111100b

out 0x43,al


mov ax,0

out 0x40,al

out 0x40,al


loop:

hlt

jmp loop


vdata:

dw 0


tdata:

db 0


handler:

mov bx,0xb800

mov es,bx

mov bx,0x7c0

mov fs,bx

mov bx,[fs:vdata]

mov byte[es:bx],'a'

inc bx

mov byte[es:bx],0x07

inc bx

mov word[fs:vdata],bx

mov al,0x20

out 0x20,al

iret

The timer doesn't seem to work for me. I know the interrupt works because I tested executing the interrupt itself in a loop, and it worked fine.

EDIT: Scratch that. When I have it in a loop of HLT's, it executes once. Am I sending the end of interrupt signal to the PIC incorrectly?

Edited by dargueta, 02 November 2010 - 01:42 PM.

Latinamne loqueris?

#2
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,705 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
A few suggestions for code efficiency:


section .text


mov bx,0xb800

mov es,bx

[COLOR="RED"]mov byte[es:0],'a'

mov byte[es:1],0x07[/COLOR]

[COLOR="BLUE"]mov WORD [es:0], 0x0761[/COLOR]

[COLOR="RED"]mov bx,0[/COLOR]

[COLOR="BLUE"]xor bx, bx[/COLOR]

mov es,bx

[COLOR="RED"]mov ax,cs[/COLOR]

mov word[es:32],handler

mov word[es:34],0x07c0


mov al,00111100b

out 0x43,al


[COLOR="RED"]mov ax,0[/COLOR]

[COLOR="BLUE"]xor ax, ax[/COLOR]

out 0x40,al

out 0x40,al


loop:

    hlt

    jmp loop


vdata:  dw 0

tdata:  db 0


handler:

    mov bx,0xb800

    mov es,bx

    mov bx,0x7c0

    mov fs,bx

    mov bx,[fs:vdata]

    [COLOR="RED"]

    mov byte[es:bx],'a'

    inc bx

    mov byte[es:bx],0x07

    inc bx[/COLOR]

    [COLOR="BLUE"]

    mov WORD [es:bx], 0x0761

    add bx, 2[/COLOR]

    mov [COLOR="RED"]word[/COLOR][fs:vdata],bx

    mov al,0x20

    out 0x20,al

    iret


As far as your actual problem, without seeing what your segment tables look like I can't really tell. Your FS segment selector looks suspiciously like the default loading address, 0x7c00. Besides, do you seriously have 248+ segments defined?

Edited by dargueta, 03 November 2010 - 04:10 PM.

sudo rm -rf /

#3
mebob

mebob

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 490 posts
This is in real mode. This is the entire code.
Latinamne loqueris?

#4
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,705 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
You're just replacing the vector pointer; I think there's something else you have to do. Try this instead of directly accessing vector memory:

mov     ax, 2515h

mov     dx, handler

mov     bx, 07c0h

mov     es, bx

int     21h


Put whatever interrupt you want to replace in AL. So if you want to override 21h then stick 2521h in AX.
sudo rm -rf /

#5
mebob

mebob

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 490 posts
It's not running from DOS, it's booting directly from a floppy (or in this case, a virtual floppy for VirtualBox).
Latinamne loqueris?

#6
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,705 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
Did you try it?
sudo rm -rf /

#7
mebob

mebob

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 490 posts
No, this time the interrupt didn't even fire once. With my code, it fired once (apparently from the timer), but didn't fire again.

BTW, for the INT 21 function you suggested, the pointer is supposed to be in DS : DX not ES : DX.
Latinamne loqueris?

#8
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,705 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
Oops. Ok, I've got stuff I need to get done before Friday, but I'll take a look at it again then.
sudo rm -rf /




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users