Category : Assembly Language Source Code
Archive   : NORTASM.ZIP
Filename : DISPAT19.ASM

 
Output of file : DISPAT19.ASM contained in archive : NORTASM.ZIP
.MODEL SMALL

.CODE
EXTRN NEXT_SECTOR:PROC ;In DISK_IO.ASM
EXTRN PREVIOUS_SECTOR:PROC ;In DISK_IO.ASM
.DATA
;-----------------------------------------------------------------------;
; This table contains the legal extended ASCII keys and the addresses ;
; of the procedures that should be called when each key is pressed. ;
; ;
; The format of the table is ;
; DB 72 ;Extended code for cursor up ;
; DW OFFSET _TEXT:PHANTOM_UP ;
;-----------------------------------------------------------------------;
DISPATCH_TABLE LABEL BYTE
DB 61 ;F3
DW OFFSET _TEXT:PREVIOUS_SECTOR
DB 62 ;F4
DW OFFSET _TEXT:NEXT_SECTOR
DB 0 ;End of the table

.CODE

PUBLIC DISPATCHER
EXTRN READ_BYTE:PROC
;-----------------------------------------------------------------------;
; This is the central dispatcher. During normal editing and viewing, ;
; this procedure reads characters from the keyboard and, if the char ;
; is a command key (such as a cursor key), DISPATCHER calls the ;
; procedures that do the actual work. This dispatching is done for ;
; special keys listed in the table DISPATCH_TABLE, where the procedure ;
; addresses are stored just after the key names. ;
; ;
; If the character is not a special key, then it should be placed ;
; directly into the sector buffer--this is the editing mode. ;
; ;
; Uses: READ_BYTE ;
;-----------------------------------------------------------------------;
DISPATCHER PROC
PUSH AX
PUSH BX
DISPATCH_LOOP:
CALL READ_BYTE ;Read character into AX
OR AH,AH ;AX = -1 if no character read, 1
; for an extended code.
JS DISPATCH_LOOP ;No character read, try again
JNZ SPECIAL_KEY ;Read extended code
; do nothing with the character for now
JMP DISPATCH_LOOP ;Read another character

SPECIAL_KEY:
CMP AL,68 ;F10--exit?
JE END_DISPATCH ;Yes, leave
;Use BX to look through table
LEA BX,DISPATCH_TABLE
SPECIAL_LOOP:
CMP BYTE PTR [BX],0 ;End of table?
JE NOT_IN_TABLE ;Yes, key was not in the table
CMP AL,[BX] ;Is it this table entry?
JE DISPATCH ;Yes, then dispatch
ADD BX,3 ;No, try next entry
JMP SPECIAL_LOOP ;Check next table entry

DISPATCH:
INC BX ;Point to address of procedure
CALL WORD PTR [BX] ;Call procedure
JMP DISPATCH_LOOP ;Wait for another key

NOT_IN_TABLE: ;Do nothing, just read next character
JMP DISPATCH_LOOP

END_DISPATCH:
POP BX
POP AX
RET
DISPATCHER ENDP


END


  3 Responses to “Category : Assembly Language Source Code
Archive   : NORTASM.ZIP
Filename : DISPAT19.ASM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/