home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / SOURCE.ZIP / REGDISP.ASM < prev    next >
Assembly Source File  |  1986-05-29  |  8KB  |  272 lines

  1.  
  2. title   Display Registers
  3. page    65,131
  4. include struct.mac
  5. ;
  6. ; regdisp.asm
  7. ;
  8. ; Displays all the 8086 registers on the right side of the screen.
  9. ; The registers are sampled and displayed roughly 18 times per second.
  10. ; Toggle on and off by holding down both shift keys.
  11. ; To use with the monochromatic monitor, DISP_BUFFER should be equated
  12. ; to 0B000H.  In addition, the code in 'outchar' that is involved in
  13. ; waiting for horizontal retrace to write a character can be removed.
  14. ; This program is loaded into memory and stays resident.  It is activated by
  15. ; each clock tick (about 18/sec) and is a cpu hog (at least with the
  16. ; graphics monitor; about 40% of the cpu is consumed when using the
  17. ; graphics monitor due mainly to the busy waits used in writing to the
  18. ; screen).
  19. ;
  20. ; Installation:
  21. ;   masm regdisp;
  22. ;   link regdisp;       (should get 'No STACK segment' message)
  23. ;   exe2bin regdisp
  24. ;   copy regdisp.bin regdisp.com
  25. ;
  26. DISP_BUFFER     equ     0B000H
  27. LINE_SIZE       equ     19
  28. ON      equ     049  ;   254 is alternate
  29. OFF     equ     032  ;   250
  30. RED     equ     4
  31. GREEN   equ     2
  32. BLUE    equ     1
  33.  
  34. xx      STRUC
  35.     s_di    dw      ?
  36.     s_si    dw      ?
  37.     s_es    dw      ?
  38.     s_ds    dw      ?
  39.     s_dx    dw      ?
  40.     s_cx    dw      ?
  41.     s_bx    dw      ?
  42.     s_ax    dw      ?
  43.     s_sp    dw      ?
  44.     s_bp    dw      ?
  45.     s_pc    dw      ?
  46.     s_cs    dw      ?
  47.     s_fl    dw      ?
  48. xx      ends
  49.  
  50. REGOUT  MACRO   LINE, REG_NAME, REG_VAL, ATT
  51. .xlist
  52.         mov     si,offset REG_NAME
  53.         mov     di,160*LINE - LINE_SIZE*2
  54.         mov     bh,ATT
  55.         call    w_label
  56.         mov     si,offset rptr
  57.         mov     dx,REG_VAL
  58.         call    w_bits
  59. .list
  60.         endm
  61.  
  62. ERASE   MACRO   LINE
  63. .xlist
  64.         mov     cx,LINE_SIZE
  65.         mov     di,160*LINE - LINE_SIZE*2
  66. rep     stosw
  67. .list
  68.         endm
  69.  
  70. abs     segment at 0
  71. zero    proc    far
  72. zero    endp
  73. abs     ends
  74.  
  75. cseg    segment
  76.         org     100H
  77.         assume  cs:cseg
  78.         assume  ds:cseg
  79. start   proc    near
  80.         jmp     initial
  81. ;
  82. ; data block for display
  83.  
  84. d_fl    db      'FL:'
  85. d_si    db      'SI:'
  86. d_di    db      'DI:'
  87. d_ss    db      'SS:'
  88. d_es    db      'ES:'
  89. d_ds    db      'DS:'
  90. d_sp    db      'SP:'
  91. d_bp    db      'BP:'
  92. d_dx    db      'DX:'
  93. d_cx    db      'CX:'
  94. d_bx    db      'BX:'
  95. d_ax    db      'AX:'
  96. display_cs  equ $
  97.         db      'CS:'
  98. display_pc  equ $
  99.         db      'PC:'
  100. rptr    db      RED,RED,RED,RED
  101.         db      RED+GREEN,RED+GREEN,RED+GREEN,RED+GREEN
  102.         db      RED,RED,RED,RED
  103.         db      RED+GREEN,RED+GREEN,RED+GREEN,RED+GREEN
  104. fts     db      0
  105. display_flag db 0
  106.  
  107. intr    equ     $
  108.         sti
  109.         push    bp
  110.         mov     bp,sp
  111.         add     bp,8
  112.         push    bp              ; contents of sp before interrupt
  113.         push    ax
  114.         push    bx
  115.         push    cx
  116.         push    dx
  117.         push    ds
  118.         push    es
  119.         push    si
  120.         push    di
  121.         mov     bp,sp
  122.         push    cs
  123.         pop     ds                      ; address the data
  124. ;       mov     al,020H
  125. ;       out     020H,al
  126.         cld
  127.         mov     ax,40H                  ; BIOS data area
  128.         mov     es,ax
  129.         mov     cx,es:[17H]             ; KB_FLAG
  130.         and     cl,11B
  131.         xor     cl,11B
  132.         .if     z                       ; left and right shift keys pressed
  133.             cmp     fts,0
  134.             jnz     once_already
  135.             xor     display_flag,1          ; toggle the display flag
  136.             .if     nz
  137.                 call    set_up
  138.             .endif
  139.             mov     fts,1                   ; set the flag
  140.             jmp     once_already
  141.         .endif
  142.         mov     fts,0                   ; reset the flag
  143. once_already:
  144.         .ifs    display_flag,1
  145.             jmp     exit
  146.         .endif
  147. testloc equ     $
  148.         mov     ax,DISP_BUFFER          ; display buffer address
  149.         mov     es,ax                   ; setup for STOSW
  150.  
  151.         REGOUT  1,display_pc,[bp].s_pc,BLUE
  152.         REGOUT  2,display_cs,[bp].s_cs,BLUE+GREEN
  153.         REGOUT  3,d_ss,ss,BLUE+GREEN
  154.         REGOUT  4,d_es,[bp].s_es,BLUE+GREEN
  155.         REGOUT  5,d_ds,[bp].s_ds,BLUE+GREEN
  156.         REGOUT  6,d_sp,[bp].s_sp,RED
  157.         REGOUT  7,d_bp,[bp].s_bp,RED
  158.         REGOUT  8,d_si,[bp].s_si,GREEN
  159.         REGOUT  9,d_di,[bp].s_di,GREEN
  160.         REGOUT  10,d_ax,[bp].s_ax,BLUE+RED
  161.         REGOUT  11,d_bx,[bp].s_bx,BLUE+RED
  162.         REGOUT  12,d_cx,[bp].s_cx,BLUE+RED
  163.         REGOUT  13,d_dx,[bp].s_dx,BLUE+RED
  164.         REGOUT  14,d_fl,[bp].s_fl,BLUE
  165.  
  166. exit:   pop     di
  167.         pop     si
  168.         pop     es
  169.         pop     ds
  170.         pop     dx
  171.         pop     cx
  172.         pop     bx
  173.         pop     ax
  174.         pop     bp              ;dummy
  175.         pop     bp
  176. jmploc: jmp     zero
  177. ;
  178. ;
  179. ;   output character and attribute in bx to word at es:[di].  dx, ax are destroyed.
  180. ;   di is incremented by 2
  181. outchar:
  182.         push    dx
  183.         mov     dx,03DAH
  184. if disp_buffer-0b000H                   ; test for graphics buffer
  185.         in      al,dx
  186.         .ifc    al,8            ; if in the midst of vertical retrace, do the write
  187.             .repeat
  188.                 in      al,dx       ; wait for partial horiz retrace to finish
  189.                 test    al,1
  190.             .until  z
  191.             .repeat
  192.                 in      al,dx       ; wait for start of horiz or vert retrace
  193.                 test    al,9
  194.             .until  nz
  195.         .endif
  196. endif
  197.         mov     ax,bx
  198.         stosw
  199.         pop     dx
  200.         ret
  201.  
  202. w_label:
  203.         mov     cx,3
  204.         .repeat
  205.             mov     bl,[si]
  206.             call    outchar
  207.             inc     si
  208.         .until  loop
  209.         ret
  210.  
  211. w_bits:
  212.         mov     cx,16
  213.         .repeat
  214.             shl     dx,1
  215.             .if     c
  216.                 mov     bl,ON
  217.             .else
  218.                 mov     bl,OFF
  219.             .endif
  220.             mov     bh,[si]
  221.             call    outchar
  222.             inc     si
  223.         .until  loop
  224.         ret
  225.  
  226. set_up:
  227.         mov     ax,DISP_BUFFER          ; display buffer address
  228.         mov     es,ax
  229.         mov     ax,700H+' '             ; blank out display buffer
  230.  
  231.         ERASE   1
  232.         ERASE   2
  233.         ERASE   3
  234.         ERASE   4
  235.         ERASE   5
  236.         ERASE   6
  237.         ERASE   7
  238.         ERASE   8
  239.         ERASE   9
  240.         ERASE   10
  241.         ERASE   11
  242.         ERASE   12
  243.         ERASE   13
  244.         ERASE   14
  245.         ret
  246.  
  247. initial:
  248.         push    ds
  249.         xor     ax,ax
  250.         mov     ds,ax                   ; address interrupt vectors
  251.         mov     si,ds:[20H]             ; pickup TIMER interrupt values
  252.         mov     cx,ds:[22H]
  253.         mov     ds,cx                   ; entry to interrupt code
  254.         mov     bx,cs:testloc
  255.         .if     <word ptr [si+testloc-intr]> e bx
  256.             pop     ds
  257.             int     20H                     ; exit
  258.         .endif
  259.         pop     ds
  260.         mov     word ptr jmploc+1,si
  261.         mov     word ptr jmploc+3,cx
  262.         mov     dx,offset intr
  263.         mov     ax,2508H                ; setup new timer call
  264.         int     21H
  265.         mov     dx,offset initial
  266.         int     27H                     ; terminal and stay resident
  267. start   endp
  268. cseg    ends
  269.         end     start
  270.  
  271.  
  272.