home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_progs / prog-asm / assemtls.lzh / ASSEMTOOLS / ASOURCE / ASC.ASM < prev    next >
Encoding:
Assembly Source File  |  1991-08-16  |  4.3 KB  |  221 lines

  1. ;
  2. ; ### ASCII v 1.70 ###
  3. ;
  4. ; - Created 880808 by TM -
  5. ;
  6. ;
  7. ; This program helps you to find the ASCII codes of different characters.
  8. ; It also 'knows' the control characters (NUL, BEL, LF, CR etc.).
  9. ;
  10. ; Original code by Tomi Marin, comments by Jukka Marin.
  11. ;
  12. ; Bugs: Not very well commented.  Sorry.  Not easy to write comments to a
  13. ;    proggie that's not written by me.
  14. ;
  15. ;
  16. ; Edited:
  17. ;
  18. ; - 881020 by TM -> v1.50    - Code compressed
  19. ; - 881020 by JM -> v1.60    - Code compressed and commented.
  20. ;                  Code size dropped from 1408 to 856 bytes!
  21. ; - 881021 by JM,TM -> v1.70    - Code still compressed.  Some features added.
  22. ;                  Code size is now 856 bytes.
  23. ;
  24. ;
  25.  
  26.  
  27. CSI    equ    $9b            ; control sequence introducer
  28.  
  29.  
  30.     xref    _LVOOpen        ; external references
  31.     xref    _LVOOpenLibrary
  32.     xref    _LVOClose
  33.     xref    _LVOCloseLibrary
  34.     xref    _LVORead
  35.     xref    _LVOWrite
  36.     xref    _LVOOutput
  37.     xref    _LVOExecute
  38.     xref    _LVOWaitForChar
  39.  
  40.  
  41.     include "jmplibs.i"        ; contains some useful macros
  42.  
  43.  
  44.  
  45.  
  46. start    openlib    Dos,clean2        ; open dos.library
  47.     openlib    Intuition,clean2    ; open intuition.library
  48.  
  49.     lea    ibuf(pc),a3        ; address of input buffer (1 byte)
  50.  
  51.     move.l    #name1,d1        ; raw window file
  52.     move.l    #1005,d2
  53.     lib    Dos,Open
  54.     move.l    d0,d5            ; put filehandle in d5
  55.     bne    fileok
  56.  
  57. cleanup    move.l    d5,d1
  58.     beq    clean1
  59.     flib    Dos,Close        ; close file (=window)
  60. clean1    closl    Dos
  61.     closl    Intuition
  62. clean2    moveq.l    #0,d0
  63.     rts
  64.  
  65. fileok    move.l    _IntuitionBase(pc),a0
  66.     move.l    52(a0),a0        ; pointer to active window
  67.     lea    16(a0),a0
  68.     move.l    #(250<<16)+77,d0    ; set window size -> no sizing allowed
  69.     move.l    d0,(a0)+
  70.     move.l    d0,(a0)
  71.  
  72.     lea    INIT(pc),a2        ; print initializing string
  73.     move.b    #' ',(a3)        ; number of first char displayed
  74.     bsr    output
  75.  
  76. jumppi    move.b    (a3),d4
  77.     subq.b    #4,d4
  78. syppi    lea    CLEAR(pc),a2        ; clear window
  79. wyppi    bsr    output
  80.     move.b    d4,d7
  81.     moveq.l    #6,d6
  82.     bra    sup2
  83. sup1    lea    LINEF(pc),a2        ; print line feed
  84.     bsr    output
  85. sup2    addq.b    #1,d7
  86.     move.b    d7,d0
  87.     bsr    fprint
  88.     move.l    d5,d1
  89.     moveq    #3,d2
  90.     flib    Dos,WaitForChar        ; check if a key pressed
  91.     tst.l    d0
  92.     dbne    d6,sup1            ; loop to print all lines
  93.  
  94. ph    move.l    d5,d1            ; read a char from keyboard
  95.     move.l    a3,d2
  96.     moveq.l    #1,d3
  97.     flib    Dos,Read
  98.     cmp.b    #27,(a3)        ; if ESC, then exit
  99.     beq    cleanup
  100.     cmp.b    #CSI,(a3)        ; check for cursor keys
  101.     bne    jumppi
  102. phii    move.l    d5,d1
  103.     move.l    a3,d2
  104.     moveq.l    #1,d3
  105.     flib    Dos,Read
  106.     cmp.b    #'?',(a3)
  107.     bls    phii
  108.     cmp.b    #'A',(a3)
  109.     bne    ph1
  110.     lea    HOME(pc),a2        ; scroll & cursor home
  111.     bsr    output
  112.     move.b    d4,d0
  113.     bsr    fprint
  114.     subq.b    #1,d4
  115.     bra    ph
  116. ph1    cmp.b    #'B',(a3)
  117.     bne    ph2
  118.     lea    BOTTOM(pc),a2        ; scroll & cursor to the bottommost line
  119.     bsr    output
  120.     move.b    d4,d0
  121.     addq.b    #8,d0
  122.     bsr    fprint
  123.     addq.b    #1,d4
  124. ph2    bra    ph
  125.  
  126.  
  127. fprint    lea    buffer+2(pc),a2        ; build one line into output buffer
  128.     moveq    #' ',d2
  129.     move.b    d0,d1
  130.     and.b    #127,d1
  131.     cmp.b    d2,d1
  132.     bhs    fprin2
  133.     move.b    d0,d1
  134.     bpl    fprin1
  135.     moveq    #'*',d2
  136. fprin1    and.w    #31,d1
  137.     mulu.w    #3,d1
  138.     lea    sohi(pc),a0
  139.     move.b    0(a0,d1.w),(a2)        ; copy 'NUL' etc.
  140.     move.b    1(a0,d1.w),1(a2)
  141.     move.b    2(a0,d1.w),2(a2)
  142.     bra    fprin3
  143. fprin2    move.b    #'"',(a2)
  144.     move.b    d0,1(a2)
  145.     move.b    #'"',2(a2)
  146. fprin3    lea    hextable(pc),a0        ; convert to hexadecimal
  147.     move.b    d0,d1
  148.     and.w    #15,d1
  149.     move.b    d2,3(a2)
  150.     move.b    0(a0,d1.w),d2        ; low nybble
  151.     move.b    d2,12(a2)
  152.     move.b    d0,d1
  153.     lsr.b    #4,d1
  154.     move.b    0(a0,d1.w),d2        ; high nybble
  155.     move.b    d2,11(a2)
  156.  
  157.     moveq.l    #0,d1            ; convert to decimal
  158.     move.b    d0,d1
  159.     divu    #10,d1
  160.     swap    d1
  161.     or.b    #'0',d1
  162.     move.b    d1,7(a2)        ; 1's
  163.     moveq.l    #0,d2
  164.     clr.w    d1
  165.     swap    d1
  166.     divu    #10,d1
  167.     swap    d1            ; get 10's in d1[0...3]
  168.     or.b    #'0',d1            ; convert to ASCII
  169.     move.b    d1,d2            ; save it
  170.     swap    d1            ; remainder = 100's
  171.     or.b    #'0',d1
  172.     cmp.b    #'0',d1
  173.     bne    fprin4
  174.     moveq.l    #' ',d1            ; blank leading zeros
  175.     cmp.b    #'0',d2
  176.     bne    fprin4
  177.     move.b    d1,d2
  178. fprin4    move.b    d2,6(a2)        ; 10's
  179.     move.b    d1,5(a2)        ; 100's
  180.  
  181.     move.b    d0,d2            ; convert to octal
  182.     and.b    #7,d2
  183.     or.b    #'0',d2
  184.     move.b    d2,18(a2)        ; lsd
  185.     lsr.b    #3,d0
  186.     move.b    d0,d2
  187.     and.b    #7,d2
  188.     or.b    #'0',d2
  189.     move.b    d2,17(a2)        ; isd
  190.     lsr.b    #3,d0
  191.     and.b    #7,d0
  192.     or.b    #'0',d0
  193.     move.b    d0,16(a2)        ; msd
  194.     subq.w    #2,a2
  195.  
  196. output    printa    a2,d5            ; print a string at a2 to file in d5
  197.     rts
  198.  
  199.  
  200. hextable dc.b    '0123456789ABCDEF'
  201.  
  202.         ;012345678901234567890
  203. buffer    dc.b    '  "C"  DEC  $HX  &OCT',0
  204. name1    dc.b    'Raw:0/0/250/77/Ascii Table'
  205. ibuf    dc.b    0
  206. LINEF    dc.b    10,0
  207. INIT    dc.b    CSI,'7t',CSI,'0 p',0
  208. CLEAR    dc.b    12,0
  209. HOME    dc.b    CSI,$54,CSI,'0;0H',0
  210. BOTTOM    dc.b    CSI,$53,CSI,'8;0H',0
  211.  
  212. sohi    dc.b    'NULSOHSTXETXEOTENQACKBEL BSTAB LF'
  213.     dc.b    ' VT FF CR SO SIDLEDC1DC2DC3DC4NAK'
  214.     dc.b    'SYNETBCAN EMSUBESC FS GS RS US'
  215.  
  216.     libnames
  217.  
  218.     end
  219.  
  220.  
  221.