Re: Keyb.asm



In article <465827ca$0$27415$ba4acef3@xxxxxxxxxxxxxx>
spamtrap@xxxxxxxxxx "almas" writes:

Hi,
I search an asm file, the aim modify it and build a keyb French version.
The file must be the smaller as possible 1 Kb or less
I found an example...but i'm just beginner...

Below is a version of KEYB that I use here with DOS 6.22 -- it
assembles to approx 350 bytes. Small enough for you? ;-)

This is for the UK keyboard that I use; you will have to change
the scancode checking at the 'is_ours' label to suit a French
keyboard (or find a non-beginner to help you:)

Pete

------------------------------------------------------
; keybuk.asm

code segment para public 'CODE'
assume cs:code
org 100h

assume es:nothing, ss:nothing, ds:code

start proc near
jmp initialise

EVEN
old_int9 dw 0 ;slot for original Int09 handler
old_int9_seg dw 0 ;

new_int9: pushf
push ax
push dx
push ds
mov ax, 40h ;bios data segnent
mov ds, ax
assume ds:nothing
mov ah, ds:[17h] ;read keyboard status bits
in al, 60h ;read keyboard controller
sti ;reenable ints
test al, 80h ;break code?
jnz pass_to_bios ;yes - give it to the old handler
;
mov dh, al ;else put keycode to DH
test ah, 1000b ;alt key active?
jz is_ours ;no
pass_to_bios: pop ds ;else pass stright to BIOS
pop dx ;
pop ax ;
popf
jmp dword ptr cs:[old_int9]

; Our replacement keyboard code handling here

is_ours: cmp al, 03h ; '2' key
jnz @4
test ah, 0011b ;shift active?
jz pass_to_bios ;no - let bios do it
mov dl, '"' ;replace with double-quote
jmp short process ;
@4: cmp al, 04h ; '3' key
jnz @28
test ah, 0011b ;shift active?
jz pass_to_bios ;no - let bios do it
mov dl, 09Ch ;replace with pound sign
jmp short process ;
@28: cmp al, 28h ;s-quote and '@'
jb pass_to_bios ;
ja @29
test ah, 0011b ;shift active?
jz pass_to_bios ;no - let bios do it
mov dl, '@' ;replace with @ symbol
jmp short process ;
@29: cmp al, 29h ;sbquote/bar/not
ja @2B
test ah, 0011b ;shift active?
jnz @AA ;yes
mov dl, '`' ;
jmp short process ;
@AA: mov dl, 0AAh ;replace with "NOT"
jmp short process ;
@2B: cmp al, 2Bh ;hash/tilde
jb pass_to_bios ;must have been 2A
ja @56
test ah, 0011b ;shift active?
jnz @tilde ;yes
mov dl, '#' ;replace with hash
jmp short process ;
@tilde: mov dl, '~' ;replace with tilde
jmp short process ;
@56: cmp al, 56h ;backslash/pipe
jnz pass_to_bios ;
test ah, 0011b ;shift active?
jnz @pipe ;yes
mov dl, '\' ;replace with backslash
jmp short process ;
@pipe: mov dl, '|' ;pipe
;drop through
process: ;
in al, 61h ;PC/XT PPI port B bits:
mov ah, al ;
or al, 80h ;pulse bit 7 to clear keyboard int
out 61h, al ;
mov al, ah ;
out 61h, al ;
push bx
push di
mov bx, ds:[1Ch] ;keyboard buffer tail pointer
mov di, bx ;insert scancode here
inc bx
inc bx
cmp bx, ds:[82h] ;reached end of buffer?
jnz insert_code ;no
mov bx, ds:[80h] ;else reset to start of buffer
cmp bx, ds:[1Ah] ;head ptr == tail ptr?
jz skip_code ;yes - skip insert
insert_code: mov [di], dx ;insert scancode
mov ds:[1Ch], bx
skip_code: pop di
pop bx
cli
mov al, 20h ;send non-specific EOI
out 20h, al ;to clear interrupt
pop ds
pop dx
pop ax
popf
iret

; TSR startup code here

initialise: mov ax, cs ;
mov ds, ax ;DS = CS
mov dx, offset sign_on
mov ah, 9 ;print sign-on message
int 21h ;
mov ax, 3509h ;get existing Int09 vector
int 21h ;
mov ds:[old_int9], bx ;store it
mov ds:[old_int9_seg], es ;
mov dx, offset new_int9
mov ax, 2509h ;install our replacement vector
int 21h ;
mov es, cs:[2Ch] ;free environment block
mov ah, 49h ;
int 21h ;
mov dx, offset initialise + 0Fh
mov cl, 4 ;set final para of resident code
shr dx, cl ;
mov ax, 3100h ;terminate stay resident service
int 21h ;
start endp ;

sign_on db 'Installing MYKEYB - PJD, Mar-2001', 0Dh, 0Ah
db 'Based on UKKEYB version 1.51',0Dh,0Ah
db '(c) 1990 - 1993 Julian V Moss.',0Dh,0Ah,'$'

code ends
end

------------------------------------------------------

.