home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / utility / 71 / utl / scan.s < prev    next >
Encoding:
Text File  |  1986-11-21  |  1.4 KB  |  85 lines

  1. * Get keypress and display ASCII and scan code
  2. *
  3. * By Charles F. Johnson
  4. *
  5. * Last revision: 11/02/86 - 13:58:16
  6.  
  7.     text
  8.  
  9.     move.l    #title,-(sp)    Print title
  10.     move.w    #9,-(sp)
  11.     trap    #1
  12.     addq.l    #6,sp
  13.  
  14. start:    move.w    #7,-(sp)    Get a keypress (no echo to screen)
  15.     trap    #1
  16.     addq.l    #2,sp
  17.     cmp.w    #27,d0        Is it Esc?
  18.     beq    exit        Yes, exit
  19.     
  20.     move.l    d0,char        Save key value
  21.  
  22.     move.l    #msg1,-(sp)
  23.     move.w    #9,-(sp)
  24.     trap    #1
  25.     addq.l    #6,sp
  26.  
  27.     move.l    char,d7        Go print ASCII value
  28.     bsr    hexout
  29.  
  30.     move.l    #msg2,-(sp)
  31.     move.w    #9,-(sp)
  32.     trap    #1
  33.     addq.l    #6,sp
  34.  
  35.     move.l    char,d7        Go print scan code value
  36.     swap    d7        Scan code is in upper word
  37.     bsr    hexout
  38.  
  39.     move.l    #msg3,-(sp)
  40.     move.w    #9,-(sp)
  41.     trap    #1
  42.     addq.l    #6,sp
  43.  
  44.     bra    start
  45.     
  46. exit:    clr.w    -(sp)
  47.     trap    #1
  48.  
  49. hexout:    and.l    #$FFFF,d7
  50.     move.l    #line,a5
  51. hex1:    move.l    d7,d6
  52.     and.w    #$F,d6
  53.     lsr.w    #4,d7
  54.     add.w    #$30,d6
  55.     cmp.w    #$39,d6
  56.     bls    hex2
  57.     add.w    #$7,d6
  58. hex2:    move.b    d6,(a5)+
  59.     tst.w    d7
  60.     bne    hex1
  61. hex3:    cmpa.l    #line,a5
  62.     bne    hex4
  63.     rts
  64. hex4:    move.b    -(a5),d7
  65.     and.w    #$FF,d7
  66.     move.w    d7,-(sp)
  67.     move.w    #2,-(sp)
  68.     trap    #1
  69.     addq.l    #4,sp
  70.     bra    hex3
  71.  
  72.     data
  73. title:    dc.b    27,'p ASCII/Scan  by Charles F. Johnson ',27,'q'
  74.     dc.b    10,13,' Type any key --- Esc to exit.'
  75.     dc.b    10,13,10,13,0
  76.  
  77. msg1:    dc.b    'ASCII code= ',0
  78. msg2:    dc.b    10,13,' Scan code= ',0
  79. msg3:    dc.b    10,13,10,13,0
  80.  
  81.     even
  82.     bss
  83. char:    ds.l    1
  84. line:    ds.b    40
  85. ə