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