[comp.sys.ibm.pc] help with serial->keyboard driver

lharris@gpu.utcs.toronto.edu (Leonard Harris) (12/08/88)

Hi.  I'm having problems with the following code on the PC.
What it is supposed to do is service interrupts from the serial port
and dump incoming data to the keyboard buffer  - so data sent via
a remote device hooked up to the serial port can act as a "second"
keyboard.  It installs as a TSR (code not included)  What happens
is that it works correctly for a few characters but then suddenly
a whole line (128) characters gets displayed on the screen - but
the cursor still points to the end of the input data.
Does the keyboard buffer have to have a special character at the end
to signal the end of data?  I think I'm writing over some essential
low memory address but I can't see where the problem occurs.
Can anyone help ?
;       Serial interrupt server                                         |
;       ENTRY : as from serial interrupt                                |
;       EXIT :  all registers preserved                                 |
;-----------------------------------------------------------------------|

Server  Proc    Far
	push 	ax
	push	bx
	push	dx
	push	ds
	mov	ax,cs
	mov	ds,ax
	mov	dx,RBRport
	in	al,dx
	cli
	mov	dx,40h
	mov	ds,dx
	mov	bx,ds:[1ch]	;get pointer to tail of kbbuf
	mov	ds:[bx],al
	inc	bx
	inc	bx
	mov 	cx,ds:[82h]	;get physical end of buffer
	inc	cx
	inc	cx
	cmp	cx,bx
	jne	serv2
	mov	bx,ds:[80h]	;point to top
serv2:
	mov	ds:[1ch],bx
	sti
	mov	al,eoi          ; signal end-of-interrupt
	out	inta00,al

	pop	ds
	pop     dx
	pop	bx
	pop	ax
	iret

Server  EndP

Thanks /leonard