home *** CD-ROM | disk | FTP | other *** search
- page 63, 132
- title DECFKEY, example function key handler for RM/COBOL 2.1
- ; SCCS information:
- ;@(#) decfkey.asm ver. 1.3 last update 85/09/20 10:30:43
- ;@(#) This source obtained from the s file on 85/09/20 at 10:31:06
- ;
- ; SUBROUTINE TO HANDLE RAINBOW-100 KEYBOARD FUNCTION KEYS.
- ;
- ; The following keys on the keyboard will be recognized:
- ;
- ;
- ; Key Sequence Returned Key Sequence Returned
- ; Value Value
- ; (decimal) (decimal)
- ;
- ; Find ESC [ 1 ~ 1 Insert
- ; Remove ESC [ 3 ~ 3 Here ESC [ 2 ~ 2
- ; Select ESC [ 4 ~ 4 Prev
- ; Next Screen ESC [ 5 ~ 5
- ; Screen ESC [ 6 ~ 6 Up
- ; Down Arrow ESC [ A 65
- ; Arrow ESC [ B 66 Right
- ; Left Arrow ESC [ C 67
- ; Arrow ESC [ D 68
- ; Compose ESC [ 1 0 ~ 10 F4 ESC [ 1 4 ~ 14
- ; Interrupt Resume ESC [ 1 8 ~ 18
- ; ESC [ 1 7 ~ 17 Cancel ESC [ 1 9 ~ 19
- ; Main Exit ESC [ 2 1 ~ 21
- ; Screen ESC [ 2 0 ~ 20 Addtnl
- ; Help ESC [ 2 8 ~ 28 Options ESC [ 2 6 ~ 26
- ; Do ESC [ 2 9 ~ 29 F17 ESC [ 3 1 ~ 31
- ; F18 ESC [ 3 2 ~ 32 F19 ESC [ 3 3 ~ 33
- ; F20 ESC [ 3 4 ~ 34 PF1 ESC O P 80
- ; PF2 ESC O Q 81 PF3 ESC O R 82
- ; PF4 ESC O S 83
- ; others ESC O 'anychar' Value of 'anychar' is returned
- ;
- ; EQUATES
- ;
- ASCIIZERO EQU 030H
- ASCIIONE EQU 031H
- ASCIISIX EQU 036H
- ASCIININE EQU 039H
- LETTEROH EQU 04FH
- LEFTBRAKET EQU 05BH
- ESC EQU 01BH
- code segment byte public 'code'
- assume cs:code, ds:code
- main proc far
- ;
- ; This program must be a .COM type in order for it to link
- ; successfully with the RUNCOBOL.COM file using the RM/COBOL
- ; utility RMCLNK. .COM files must have the ORG 100 statement.
- ORG 100H ;USING 8080 MEMORY MODEL
- ;
- ; LINKED ASSEMBLY TABLE
- ;
- DW ENDCODE ;POINTS TO LAST LOCATION
- DB 6 ;LENGTH OF 'FUNKEY'
- DB 'FUNKEY' ;PROGRAM NAME
- DW FUNKEY ;ENTRY POINT
- DB 0 ;END OF TABLE
- ; Sccs information :
- db '@ #( ) (@)#@(#)' ;SCCS id.
- db 'decfkey.asm' ;Program name % M %.
- db ' ver. '
- db '1.3' ;version % I %.
- db ' 85/09/20 ' ;date % E %.
- db '10:30:43' ;time % U %.
- db '>' ;Ending indicator.
- ;
- ; To link this subroutine into the runtime,
- ; use the RM/COBOL utility RMCLNK to combine the RUNCOBOL.COM
- ; file and this .COM file.
- ; To enable this subroutine, the location FCHANDLE, at 014C of
- ; the configuration tables must be changed to be the offset of
- ; the location FUNKEY. The RM/COBOL configuration utility
- ; RMCNFG can be used to configure the linked runtime such that
- ; the runtime will call FUNKEY when exception characters are
- ; recognized. On the RMCNFG configuration menu, FCHANDLE is
- ; the label 'Fkey Addr', and must be set to 0142, which is the
- ; offset of FUNKEY when assembled with MASM and linked with LINK.
- ;
- ; Instead of linking this subroutine into the RUNCOBOL.COM file,
- ; the automatic loading of this subroutine can be configured by
- ; setting the location LINKTBL (Link Addr label on the RMCNFG
- ; menu) at 12A of the configuration tables to be FFFF (-1).
- ; Also the file name of this .COM file ('DECFKEY.COM') must be
- ; configured as the name of LNKFCB (Hex Filename on the RMCNFG
- ; menu) at location 12D of the configuration tables. The presence
- ; of the -1 at LINKTBL directs the runtime to automatically load
- ; the file whose name is found at LNKFCB before the RM/COBOL
- ; programs begin execution. And to enable this subroutine the
- ; location FCHANDLE must be set to be the offset of FUNKEY as
- ; described above for the linked example.
- ;
- ;
- FUNKEY:
- ;It is safe to assume that RUNCOBOL will
- ;save it's own registers
- MOV DL,AL ;Enters with first character
- ;in AL, save in DL, which is our
- ;answer register
- CMP AL,ESC ;Must be escape
- JNZ FIRSTOK ;No, return that first char
- CALL INCHAR ;GET NEXT CHARACTER
- CMP AL,LEFTBRAKET ;Next is '['
- JZ YESBRAKET
- CMP AL,LETTEROH ;Well, maybe the letter 'O'
- JNZ ERROR ;Must be something else
- CALL INCHAR ;The next char is the result
- MOV DL,AL ;In the answer register
- JMP FIRSTOK ;Exit
- YESBRAKET:
- CALL INCHAR ;GET NEXT CHARACTER
- MOV CL,AL ;Remember it in CL
- SUB AL,ASCIIONE
- JC ERROR ;Less than one
- MOV AL,ASCIISIX ; 6
- SUB AL,CL
- JNC FIRSTINRANGE ;LESS THAN 7, that is OK
- MOV AL,CL ;Check for A,B,C,D
- SUB AL,'A'
- JC ERROR ;Less than 'A'
- MOV AL,'D'
- SUB AL,CL
- JC ERROR ;Greater than 'D'
- MOV DL,CL ;DL has the answer
- JMP FIRSTOK
- FIRSTINRANGE:
- MOV AL,CL ;Back to the first digit
- SUB AL,ASCIIZERO ;MAKE IT BINARY
- MOV DL,AL ;NOW IN RANGE, SAVE IN DL
- CALL INCHAR ;NEXT CHARACTER
- MOV CL,AL ;Remember in CL
- CMP AL,'~' ;MAYBE THIS
- JZ FIRSTOK ;THEN DONE
- SUB AL,ASCIIZERO ;Range check
- JC ERROR ;LESS THAN 0
- MOV AL,ASCIININE ; 9
- SUB AL,CL
- JC ERROR ;GREATER THAN 9
- MOV AL,CL
- SUB AL,ASCIIZERO ;MAKE IT BINARY
- MOV CH,AL ;SAVE IN CH
- MOV AL,DL ;PREVIOUS DIGIT
- SAL AL,1
- MOV CL,AL ;DIGIT1 * 2 IN CL
- SAL AL,1 ; * 4
- SAL AL,1 ; * 8
- ADD AL,CL ;SUM IS * 10
- ADD AL,CH ;PLUS SECOND DIGIT
- MOV DL,AL ;RETURN VALUE, SAVE IN DL
- CALL INCHAR ;LAST CHARACTER MUST BE '~'
- CMP AL,'~'
- JNZ ERROR
- FIRSTOK:
- XOR AL,AL ;Set ZERO flag for all OK
- MOV AL,DL ;Returned value is in DL,
- RET ;RETURN ZERO -> SUCCESS
- ERROR:
- OR AL,1 ;NON-ZERO -> FAILURE
- RET
- main endp
- ;
- ;
- INCHAR proc near
- PUSH DX ;Save answer register
- MOV DL,0FFH ;0FFH -> INPUT FUNCTION
- INCHAR1:
- MOV AH,06H ;#6 = RAW CONSOLE I/O
- PUSH BX
- PUSH CX
- PUSH DX
- PUSH DS
- PUSH ES
- INT 021H ;Call MSDOS
- POP ES
- POP DS
- POP DX
- POP CX
- POP BX
- OR AL,AL
- JZ INCHAR1 ;Wait for a character to be typed
- POP DX ;Restore answer register
- RET
- inchar endp
- ENDCODE:
- code ends
- stack segment byte stack 'stack'
- assume ss:stack
- stack ends
- END FUNKEY ;Theoretical entry point
- ;if this was a normal program
-