Advertisement
Guest User

Untitled

a guest
Feb 12th, 2024
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. ; Initialize timer interrupt handler
  2. ;push ax
  3. ;push dx
  4. mov ah, 35h
  5. mov al, TIMER_INT
  6. int 21h ; Now we have an address of this interrupt handler in bx
  7. ; since IVT starts at 0x00, bx, an offset, has a definitive address to 1CH handler
  8. cli
  9. mov word ptr [TIMER_INT_ADDR], bx ; move address of 1Ch to TIMER_INT_ADDR | Point the 1Ch IP to the TIMER_INT_ADDR.
  10. mov ax, es
  11. mov word ptr TIMER_INT_ADDR[2], ax ; move code segment of the 1Ch int to the addr+2bytes (each entry in IVT is 2 words wide)
  12. mov ax, seg handle_timer ; new code segment for the interrupt
  13. mov ds, ax
  14. mov dx, offset handle_timer
  15. mov ah, 25h
  16. mov al, TIMER_INT
  17. int 21h
  18. sti ; Ok now we set new address of the 1Ch interrupt handler. Effectively,
  19. ; it should be DS(handle_timer):DX(offset of handle_timer), so whenever
  20. ; 1CH is called, it goes to handle_timer
  21.  
  22. handle_timer:
  23. cli
  24. inc [timer_count]
  25. sti
  26. iret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement