home *** CD-ROM | disk | FTP | other *** search
- * Get keypress and display ASCII and scan code
- *
- * By Charles F. Johnson
- *
- * Last revision: 11/02/86 - 13:58:16
-
- text
-
- move.l #title,-(sp) Print title
- move.w #9,-(sp)
- trap #1
- addq.l #6,sp
-
- start: move.w #7,-(sp) Get a keypress (no echo to screen)
- trap #1
- addq.l #2,sp
- cmp.w #27,d0 Is it Esc?
- beq exit Yes, exit
-
- move.l d0,char Save key value
-
- move.l #msg1,-(sp)
- move.w #9,-(sp)
- trap #1
- addq.l #6,sp
-
- move.l char,d7 Go print ASCII value
- bsr hexout
-
- move.l #msg2,-(sp)
- move.w #9,-(sp)
- trap #1
- addq.l #6,sp
-
- move.l char,d7 Go print scan code value
- swap d7 Scan code is in upper word
- bsr hexout
-
- move.l #msg3,-(sp)
- move.w #9,-(sp)
- trap #1
- addq.l #6,sp
-
- bra start
-
- exit: clr.w -(sp)
- trap #1
-
- hexout: and.l #$FFFF,d7
- move.l #line,a5
- hex1: move.l d7,d6
- and.w #$F,d6
- lsr.w #4,d7
- add.w #$30,d6
- cmp.w #$39,d6
- bls hex2
- add.w #$7,d6
- hex2: move.b d6,(a5)+
- tst.w d7
- bne hex1
- hex3: cmpa.l #line,a5
- bne hex4
- rts
- hex4: move.b -(a5),d7
- and.w #$FF,d7
- move.w d7,-(sp)
- move.w #2,-(sp)
- trap #1
- addq.l #4,sp
- bra hex3
-
- data
- title: dc.b 27,'p ASCII/Scan by Charles F. Johnson ',27,'q'
- dc.b 10,13,' Type any key --- Esc to exit.'
- dc.b 10,13,10,13,0
-
- msg1: dc.b 'ASCII code= ',0
- msg2: dc.b 10,13,' Scan code= ',0
- msg3: dc.b 10,13,10,13,0
-
- even
- bss
- char: ds.l 1
- line: ds.b 40
- ə