home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / RGASM.RAR / ASMCODE.EXE / CHAPT8 / SCRTBL.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-05-10  |  4.4 KB  |  82 lines

  1. ;
  2. ;       Program ScrTbl ( Chapter 8 )
  3. ;
  4.         page    55,132
  5. ;
  6. ;       this program outputs ASCII character table onto screen
  7. ;       character set currently loaded will be shown
  8. ;
  9. .model  small
  10. .stack
  11. .data
  12. CR      equ     00Dh                    ; carriage return code
  13. LF      equ     00Ah                    ; line feed code
  14. Con16   db      16                      ; integer constant 16
  15. EndMsg  equ     024h                    ; "dollar" sign - end of message
  16. StMsg   db      CR,LF,LF
  17.         db      'screen font show utility      14 Jun 92    version 1.2',CR,LF
  18.         db      'copyright (C) 1992 V.B.Maljugin,      Voronezh, Russia',CR,LF
  19. CrLf    db      CR, LF, EndMsg
  20. Pattern db      'xx-' , EndMsg
  21. HexSym  db      '0','1','2','3','4','5','6','7'
  22.         db      '8','9','A','B','C','D','E','F'
  23. CodSym  db      0
  24.  
  25. .code                                   ; CODE segment starts here
  26. .startup                                ; standard prologue (MASM 6)
  27.         mov     ax,40h                  ; segment address of BIOS data area
  28.         mov     es,ax                   ; ES will point to BIOS data
  29.         lea     dx,StMsg                ; address of message into DX
  30.         mov     ah,09                   ; function 09h - output text string
  31.         int     21h                     ; DOS service call
  32.         mov     cx,16                   ; number of lines in table
  33. ;===    enclosing cycle starts here
  34. PrtTable:
  35.         push    cx                      ; save enclosing cycle counter
  36. ;===    nested cycle - output 16 columns in current row
  37.         mov     cx,16                   ; set counter for nested cycle
  38. rows:
  39.         push    cx                      ; save outward counter
  40.         mov     al,CodSym
  41. ;===    convert code of current character code into two hex digits
  42. ToHex:                                  ;
  43.         mov     ah,0                    ; character code (0-0FFh) in AX
  44.         div     Con16                   ; low digit into AL, high - into AH
  45.         mov     bx,offset HexSym        ; offset of hex symbols table
  46.         xlat                            ; convert AL to character
  47.         mov     byte ptr Pattern,al     ;    and place it into output line
  48.         mov     al,ah                   ; place high digit into AL
  49.         xlat                            ;  convert AL to character
  50.         mov     byte ptr Pattern[1],al  ;    and place it into output line
  51. ;===    Output hexadecimal representation of character (DOS service)
  52.         mov     ah,09                   ; function 09 - output string
  53.         lea     dx,Pattern              ; address of text to be output
  54.         int     21h                     ; DOS service call
  55. ;===    output symbolic representation of character (BIOS service)
  56.         mov     bh,es:[62h]             ; number of active video page
  57.         mov     bl,0                    ; color in some graphics modes
  58.         mov     ah,0Ah                  ; function 0Ah - output symbol
  59.         mov     al,CodSym               ; AL - symbol to be output
  60.         mov     cx,1                    ; CX - repeat counter
  61.         int     10h                     ; BIOS video service
  62. ;===    prepare for output next column
  63.         mov     ah,03                   ; function 03h - get cursor location
  64.         int     10h                     ; BIOS video service
  65.         mov     ah,02                   ; function 02h - set cursor location
  66.         add     dl,2                    ; new location - 2 places to right
  67.         int     10h                     ; BIOS video service
  68.         pop     cx                      ; restore counter of nested cycle
  69.         add     CodSym,16               ; code for character in next column
  70.         loop    Rows                    ;=== end of nested cycle body
  71. ;===    enclosed cycle continues from here
  72.         lea     dx,CrLf                 ; address of message into DX
  73.         mov     ah,09h                  ; function 09h - output text string
  74.         int     21h                     ; DOS service call
  75.         pop     cx                      ; restore counter of enclosed cycle
  76.         inc     CodSym                  ; code for first character in next line
  77. EndMain:loop    PrtTable                ; print next line
  78. ;===    finish program. return code = 0
  79.         mov     ax,4C00h                ; function 4Ch - terminate process
  80.         int     21h                     ; DOS service call
  81.         end
  82.