home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / Assembly / DISP_S16.ASM < prev    next >
Assembly Source File  |  1986-09-24  |  5KB  |  218 lines

  1. CGROUP    GROUP    CODE_SEG, DATA_SEG    ;Group two segments together
  2.     ASSUME    CS:CGROUP, DS:CGROUP
  3.  
  4. ;-----------------------------------------------------------------------;
  5. ; Graphics characters for border of sector.                ;
  6. ;-----------------------------------------------------------------------;
  7. VERTICAL_BAR    EQU    0BAh
  8. HORIZONTAL_BAR    EQU    0CDh
  9. UPPER_LEFT    EQU    0C9h
  10. UPPER_RIGHT    EQU    0BBh
  11. LOWER_LEFT    EQU    0C8h
  12. LOWER_RIGHT    EQU    0BCh
  13. TOP_T_BAR    EQU    0CBh
  14. BOTTOM_T_BAR    EQU    0CAh
  15. TOP_TICK    EQU    0D1h
  16. BOTTOM_TICK    EQU    0CFh
  17.  
  18. CODE_SEG    SEGMENT PUBLIC
  19.  
  20.     PUBLIC    INIT_SEC_DISP
  21.     EXTRN    WRITE_PATTERN:NEAR, SEND_CRLF:NEAR
  22. ;-----------------------------------------------------------------------;
  23. ; This procedure initializes the half_sector display.            ;
  24. ;                                    ;
  25. ; Uses:        WRITE_PATTERN, SEND_CRLF, DISP_HALF_SECTOR        ;
  26. ;        WRITE_TOP_HEX_NUMBERS                    ;
  27. ; Reads:    TOP_LINE_PATTERN, BOTTOM_LINE_PATTERN            ;
  28. ;-----------------------------------------------------------------------;
  29. INIT_SEC_DISP    PROC    NEAR
  30.     PUSH    DX
  31.     CALL    WRITE_TOP_HEX_NUMBERS
  32.     LEA    DX,TOP_LINE_PATTERN
  33.     CALL    WRITE_PATTERN
  34.     CALL    SEND_CRLF
  35.     XOR    DX,DX            ;Start at the beginning of the sector
  36.     CALL    DISP_HALF_SECTOR
  37.     LEA    DX,BOTTOM_LINE_PATTERN
  38.     CALL    WRITE_PATTERN
  39.     POP    DX
  40.     RET
  41. INIT_SEC_DISP    ENDP
  42.  
  43.     EXTRN    WRITE_CHAR_N_TIMES:NEAR, WRITE_HEX:NEAR, WRITE_CHAR:NEAR
  44.     EXTRN    WRITE_HEX_DIGIT:NEAR, SEND_CRLF:NEAR
  45. ;-----------------------------------------------------------------------;
  46. ; This procedure writes the index numbers (0 through F) at the top of    ;
  47. ; the half-sector display.                        ;
  48. ;                                    ;
  49. ; Uses:        WRITE_CHAR_N_TIMES, WRITE_HEX, WRITE_CHAR        ;
  50. ;        WRITE_HEX_DIGIT, SEND_CRLF                ;
  51. ;-----------------------------------------------------------------------;
  52. WRITE_TOP_HEX_NUMBERS    PROC    NEAR
  53.     PUSH    CX
  54.     PUSH    DX
  55.     MOV    DL,' '            ;Write 9 spaces for left side
  56.     MOV    CX,9
  57.     CALL    WRITE_CHAR_N_TIMES
  58.     XOR    DH,DH            ;Start with 0
  59. HEX_NUMBER_LOOP:
  60.     MOV    DL,DH
  61.     CALL    WRITE_HEX
  62.     MOV    DL,' '
  63.     CALL    WRITE_CHAR
  64.     INC    DH
  65.     CMP    DH,10h            ;Done yet?
  66.     JB    HEX_NUMBER_LOOP
  67.  
  68.     MOV    DL,' '            ;Write hex numbers over ASCII window
  69.     MOV    CX,2
  70.     CALL    WRITE_CHAR_N_TIMES
  71.     XOR    DL,DL
  72. HEX_DIGIT_LOOP:
  73.     CALL    WRITE_HEX_DIGIT
  74.     INC    DL
  75.     CMP    DL,10h
  76.     JB    HEX_DIGIT_LOOP
  77.     CALL    SEND_CRLF
  78.     POP    DX
  79.     POP    CX
  80.     RET
  81. WRITE_TOP_HEX_NUMBERS    ENDP
  82.  
  83.  
  84.     PUBLIC    DISP_HALF_SECTOR
  85.     EXTRN    SEND_CRLF:NEAR
  86. ;-----------------------------------------------------------------------;
  87. ; This procedure displays half a sector (256 bytes)            ;
  88. ;                                    ;
  89. ;    DS:DX    Offset into sector, in bytes -- should be multiple of 16;
  90. ;                                    ;
  91. ; Uses:        DISP_LINE, SEND_CRLF                    ;
  92. ;-----------------------------------------------------------------------;
  93. DISP_HALF_SECTOR    PROC    NEAR
  94.     PUSH    CX
  95.     PUSH    DX
  96.     MOV    CX,16            ;Display 16 lines
  97. HALF_SECTOR:
  98.     CALL    DISP_LINE
  99.     CALL    SEND_CRLF
  100.     ADD    DX,16
  101.     LOOP    HALF_SECTOR
  102.     POP    DX
  103.     POP    CX
  104.     RET
  105. DISP_HALF_SECTOR    ENDP
  106.  
  107.     PUBLIC    DISP_LINE
  108.     EXTRN    WRITE_HEX:NEAR
  109.     EXTRN    WRITE_CHAR:NEAR
  110.     EXTRN    WRITE_CHAR_N_TIMES:NEAR
  111. ;-----------------------------------------------------------------------;
  112. ; This procedure displays one line of data, or 16 bytes, first in hex,    ;
  113. ; then in ASCII.                            ;
  114. ;                                    ;
  115. ;    DS:DX    Offset into sector, in bytes.                ;
  116. ;                                    ;
  117. ; Uses:        WRITE_CHAR, WRITE_HEX, WRITE_CHAR_N_TIMES        ;
  118. ; Reads:    SECTOR                            ;
  119. ;-----------------------------------------------------------------------;
  120. DISP_LINE    PROC    NEAR
  121.     PUSH    BX
  122.     PUSH    CX
  123.     PUSH    DX
  124.     MOV    BX,DX            ;Offset is more useful in BX
  125.  
  126.     MOV    DL,' '
  127.     MOV    CX,3            ;Write 3 spaces before line
  128.     CALL    WRITE_CHAR_N_TIMES
  129.                     ;Write offset in hex
  130.     CMP    BX,100h            ;Is the first digit a 1?
  131.     JB    WRITE_ONE        ;No, write space already in DL
  132.     MOV    DL,'1'            ;Yes, then place '1' into DL for output
  133. WRITE_ONE:
  134.     CALL    WRITE_CHAR
  135.     MOV    DL,BL            ;Copy lower byte into DL for hex output
  136.     CALL    WRITE_HEX
  137.                     ;Write separator
  138.     MOV    DL,' '
  139.     CALL    WRITE_CHAR
  140.     MOV    DL,VERTICAL_BAR        ;Draw left side of box
  141.     CALL    WRITE_CHAR
  142.     MOV    DL,' '
  143.     CALL    WRITE_CHAR
  144.                     ;Now write out 16 bytes
  145.     MOV    CX,16            ;Dump 16 bytes
  146.     PUSH    BX            ;Save the offset for ASCII_LOOP
  147. HEX_LOOP:
  148.     MOV    DL,SECTOR[BX]        ;Get 1 byte
  149.     CALL    WRITE_HEX        ;Dump this byte in hex
  150.     MOV    DL,' '            ;Write a space between numbers
  151.     CALL    WRITE_CHAR
  152.     INC    BX
  153.     LOOP    HEX_LOOP
  154.  
  155.     MOV    DL,VERTICAL_BAR        ;Write separator
  156.     CALL    WRITE_CHAR
  157.     MOV    DL,' '            ;Add another space before characters
  158.     CALL    WRITE_CHAR
  159.  
  160.     MOV    CX,16
  161.     POP    BX            ;Get back offset into SECTOR
  162. ASCII_LOOP:
  163.     MOV    DL,SECTOR[BX]
  164.     CALL    WRITE_CHAR
  165.     INC    BX
  166.     LOOP    ASCII_LOOP
  167.  
  168.     MOV    DL,' '            ;Draw right side of box
  169.     CALL    WRITE_CHAR
  170.     MOV    DL,VERTICAL_BAR
  171.     CALL    WRITE_CHAR
  172.  
  173.     POP    DX
  174.     POP    CX
  175.     POP    BX
  176.     RET
  177. DISP_LINE    ENDP
  178.  
  179. CODE_SEG    ENDS
  180.  
  181.  
  182. DATA_SEG    SEGMENT PUBLIC
  183. TOP_LINE_PATTERN    LABEL    BYTE
  184.     DB    ' ',7
  185.     DB    UPPER_LEFT,1
  186.     DB    HORIZONTAL_BAR,12
  187.     DB    TOP_TICK,1
  188.     DB    HORIZONTAL_BAR,11
  189.     DB    TOP_TICK,1
  190.     DB    HORIZONTAL_BAR,11
  191.     DB    TOP_TICK,1
  192.     DB    HORIZONTAL_BAR,12
  193.     DB    TOP_T_BAR,1
  194.     DB    HORIZONTAL_BAR,18
  195.     DB    UPPER_RIGHT,1
  196.     DB    0
  197. BOTTOM_LINE_PATTERN    LABEL    BYTE
  198.     DB    ' ',7
  199.     DB    LOWER_LEFT,1
  200.     DB    HORIZONTAL_BAR,12
  201.     DB    BOTTOM_TICK,1
  202.     DB    HORIZONTAL_BAR,11
  203.     DB    BOTTOM_TICK,1
  204.     DB    HORIZONTAL_BAR,11
  205.     DB    BOTTOM_TICK,1
  206.     DB    HORIZONTAL_BAR,12
  207.     DB    BOTTOM_T_BAR,1
  208.     DB    HORIZONTAL_BAR,18
  209.     DB    LOWER_RIGHT,1
  210.     DB    0
  211.  
  212.     PUBLIC    SECTOR
  213. SECTOR    DB    8192 DUP (0)
  214. DATA_SEG    ENDS
  215.  
  216.  
  217.     END
  218.