Skip to content

Commit

Permalink
moved the code which needs to remain resident at the start, to allow me
Browse files Browse the repository at this point in the history
to discard the init code and string data with the TSR call.
  • Loading branch information
jtsiomb committed Sep 8, 2018
1 parent dac56e6 commit a2b2bb4
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions capsmap.asm
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,8 @@ SCANCODE equ 011bh
org 100h
bits 16

mov ax, 0900h
mov dx, msg
int 21h

; get current keyboard interrupt handler
mov ax, 3509h
int 21h
mov [orig_seg], es
mov [orig_off], bx

; set our own interrupt handler in its place
mov ax, 2509h
mov dx, kbintr
int 21h

mov ax, 0900h
mov dx, msg_done
int 21h

; terminate and stay awesome
mov dx, end_of_code
int 27h
; jump over resident part to the init code at the end
jmp init

KB_INTR equ 09h
KB_PORT equ 60h
Expand All @@ -69,7 +49,6 @@ KBFLAGS1 equ 18h
SCAN_CAPS_PRESS equ 03ah
SCAN_CAPS_RELEASE equ 0bah


kbintr:
push ax
in al, KB_PORT
Expand Down Expand Up @@ -118,7 +97,6 @@ kbintr:
iret



%ifndef MAP_MODKEY

BHEAD_OFF equ 1ah
Expand Down Expand Up @@ -150,14 +128,38 @@ append_key:

.end: popa
ret

%endif


msg db 'Installing capslock remapper... $'
msg_done db 'done.',13,10,'$'
orig_seg dw 0
orig_off dw 0
resident_end:

; init code, anything from this point on will not stay resident
init:
mov ax, 0900h
mov dx, msg
int 21h

; get current keyboard interrupt handler
mov ax, 3509h
int 21h
mov [orig_seg], es
mov [orig_off], bx

; set our own interrupt handler in its place
mov ax, 2509h
mov dx, kbintr
int 21h

mov ax, 0900h
mov dx, msg_done
int 21h

end_of_code:
; terminate and stay awesome
mov dx, resident_end
int 27h


msg db 'Installing capslock remapper... $'
msg_done db 'done.',13,10,'$'
; vi:set filetype=nasm ts=8:

0 comments on commit a2b2bb4

Please sign in to comment.