home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / GRLF-C-2.ZIP / GFUNC / DINPTOKB.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-05-30  |  1.6 KB  |  67 lines

  1. ;/*
  2. ;** dinptokb.asm
  3. ;** contains: dinptokb()
  4. ;*/
  5.  
  6. ROMSEG        equ    040h            ;ROM Bios data segment
  7. KEYBOARDBUFFER    equ    01eh            ;Offset of keyboard buffer in ROMSEG
  8. KEYBOARDEND    equ    KEYBOARDBUFFER+32    ;End of keyboard buffer
  9. KEYBOARDTAIL    equ    01ch            ;Offset of keyboard tail pointer
  10. KEYBOARDHEAD    equ    01ah            ;Offset of keyboard head pointer
  11.  
  12.  
  13.         include model.h
  14.         include prologue.h
  15.  
  16.         pseg cdinptokb
  17.  
  18. ;/*
  19. ;**  int
  20. ;** dinptokb(unsigned ScanChar)
  21. ;**
  22. ;** ARGUMENT(s)
  23. ;**  ScanChar        -    Scan code in high order 8 bits,
  24. ;**                ASCII code in low order 8 bits.
  25. ;**
  26. ;** DESCRIPTION
  27. ;**  Puts characters directly into the keyboard buffer.  Does not use the
  28. ;**  ROM BIOS.    Depends on the keyboard buffer being located at 40:1E as
  29. ;**  documented by IBM.
  30. ;**
  31. ;** RETURNS
  32. ;**  0 = operation successfully completed.
  33. ;**  1 = Buffer is full.
  34. ;**
  35. ;** AUTHOR
  36. ;**  "" Fri 11-Nov-1988 10:10:45
  37. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  38. ;**
  39. ;** MODIFICATIONS
  40. ;**
  41. ;*/
  42.         cproc    dinptokb
  43.         push    ds
  44.         mov    ax,ROMSEG
  45.         mov    ds,ax
  46.         mov    di,KEYBOARDHEAD
  47.         cli                ;shutdown interrupts
  48.         mov    bx,[di+2]        ;bx=buffer tail
  49.         mov    si,bx            ;save in SI
  50.         add    bx,2            ;move tail forward
  51.         cmp    bx,KEYBOARDEND        ;check for end
  52.         jnz    skipwrap
  53.         mov    bx,KEYBOARDBUFFER    ;wrap back to beginning
  54. skipwrap:    cmp    bx,[di]         ;if equal to head then full
  55.         mov    ax,1            ;assume full
  56.         jz    directinexit        ;check assumption
  57.         mov    ax,parm1_        ;ah=scan code, al=character code
  58.         mov    [si],ax         ;save in buffer
  59.         mov    [di+2],bx        ;update new tail position
  60.         xor    ax,ax
  61. directinexit:    sti
  62.         pop    ds
  63.         cproce
  64.  
  65.         endps
  66.         end
  67.