home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / nor_asm / dispat19.asm < prev    next >
Assembly Source File  |  1989-05-17  |  3KB  |  80 lines

  1. .MODEL    SMALL
  2.  
  3. .CODE
  4.     EXTRN    NEXT_SECTOR:PROC            ;In DISK_IO.ASM
  5.     EXTRN    PREVIOUS_SECTOR:PROC            ;In DISK_IO.ASM
  6. .DATA
  7. ;-----------------------------------------------------------------------;
  8. ; This table contains the legal extended ASCII keys and the addresses    ;
  9. ; of the procedures that should be called when each key is pressed.    ;
  10. ;                                    ;
  11. ; The format of the table is                        ;
  12. ;        DB    72        ;Extended code for cursor up    ;
  13. ;        DW    OFFSET _TEXT:PHANTOM_UP                ;
  14. ;-----------------------------------------------------------------------;
  15. DISPATCH_TABLE    LABEL    BYTE
  16.     DB    61                ;F3
  17.     DW    OFFSET _TEXT:PREVIOUS_SECTOR
  18.     DB    62                ;F4
  19.     DW    OFFSET _TEXT:NEXT_SECTOR
  20.     DB    0                ;End of the table
  21.  
  22. .CODE
  23.  
  24.     PUBLIC    DISPATCHER
  25.     EXTRN    READ_BYTE:PROC
  26. ;-----------------------------------------------------------------------;
  27. ; This is the central dispatcher. During normal editing and viewing,    ;
  28. ; this procedure reads characters from the keyboard and, if the char    ;
  29. ; is a command key (such as a cursor key), DISPATCHER calls the        ;
  30. ; procedures that do the actual work.  This dispatching is done for    ;
  31. ; special keys listed in the table DISPATCH_TABLE, where the procedure    ;
  32. ; addresses are stored just after the key names.            ;
  33. ;                                    ;
  34. ; If the character is not a special key, then it should be placed    ;
  35. ; directly into the sector buffer--this is the editing mode.        ;
  36. ;                                    ;
  37. ; Uses:        READ_BYTE                        ;
  38. ;-----------------------------------------------------------------------;
  39. DISPATCHER    PROC
  40.     PUSH    AX
  41.     PUSH    BX
  42. DISPATCH_LOOP:
  43.     CALL    READ_BYTE        ;Read character into AX
  44.     OR    AH,AH            ;AX = -1 if no character read, 1
  45.                     ; for an extended code.
  46.     JS    DISPATCH_LOOP        ;No character read, try again
  47.     JNZ    SPECIAL_KEY        ;Read extended code
  48. ; do nothing with the character for now
  49.     JMP    DISPATCH_LOOP        ;Read another character
  50.  
  51. SPECIAL_KEY:
  52.     CMP    AL,68            ;F10--exit?
  53.     JE    END_DISPATCH        ;Yes, leave
  54.                     ;Use BX to look through table
  55.     LEA    BX,DISPATCH_TABLE
  56. SPECIAL_LOOP:
  57.     CMP    BYTE PTR [BX],0        ;End of table?
  58.     JE    NOT_IN_TABLE        ;Yes, key was not in the table
  59.     CMP    AL,[BX]            ;Is it this table entry?
  60.     JE    DISPATCH        ;Yes, then dispatch
  61.     ADD    BX,3            ;No, try next entry
  62.     JMP    SPECIAL_LOOP        ;Check next table entry
  63.  
  64. DISPATCH:
  65.     INC    BX            ;Point to address of procedure
  66.     CALL    WORD PTR [BX]        ;Call procedure
  67.     JMP    DISPATCH_LOOP        ;Wait for another key
  68.  
  69. NOT_IN_TABLE:                ;Do nothing, just read next character
  70.     JMP    DISPATCH_LOOP
  71.  
  72. END_DISPATCH:
  73.     POP    BX
  74.     POP    AX
  75.     RET
  76. DISPATCHER    ENDP
  77.  
  78.  
  79.     END
  80.