home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / os2 / gtak212b.zip / SOURCE.ZIP / OS2-ST01 / debug.asm next >
Assembly Source File  |  1991-07-21  |  2KB  |  135 lines

  1.     SUBTTL    Debug Module
  2.         INCLUDE DEFS.INC
  3.  
  4.     debug_def equ 1
  5.     include    debug.inc
  6.  
  7. ScreenH    equ    0Bh
  8. ScreenL    equ    0000h
  9.  
  10. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  11.  
  12. StartData
  13.  
  14.     public    tracelvl
  15.  
  16. line        dw    0
  17. col        dw    0
  18. hex        db    '0123456789ABCDEF'
  19. tracelvl    db    1
  20.  
  21. EndData
  22.  
  23. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  24.  
  25. StartCode
  26.  
  27.     public    out_char
  28.     public    out_text
  29.     public    out_byte
  30.     public    init_debug
  31.  
  32. out_char    proc near
  33.     if    trace
  34.     push    gs
  35.     push    fs
  36.     push    es
  37.     pusha
  38.  
  39.     push    ax
  40.  
  41.     mov    ax, ScreenH            ;Screen -> ES:DI
  42.     mov    bx, ScreenL
  43.     mov    cx, 25 * 80 * 2
  44.     mov    dh, 1
  45.     DevHlp    DevHlp_PhysToVirt
  46.     jc    short oc_f
  47.  
  48.     pop    ax
  49.     
  50.     cmp    al, '$'
  51.     je    short oc_lf
  52.     cmp    al, 0Ah
  53.     jne    short oc_nrm
  54.  
  55. oc_lf:    mov    col, 0                ;LF = CR-LF
  56.     inc    line
  57.     cmp    line, 25
  58.     jne    short oc_r
  59.     dec    line
  60.     lea    si, [di + (80 * 2)]        ;Scroll
  61.     mov    cx, 24 * 80
  62.     cld
  63.     rep movs word ptr es:[di], word ptr es:[si]
  64.     mov    cx, 80
  65.     mov    ax, 0720h
  66.     rep stos word ptr es:[di]
  67.     jmp    short oc_r
  68.  
  69. oc_nrm:    imul    bx, line, 80
  70.     add    bx, col
  71.     shl    bx, 1
  72.     mov    ah, 07h
  73.     mov    es:[di+bx], ax
  74.     cmp    col, 79
  75.     je    short oc_r
  76.     inc    col
  77.  
  78. oc_r:    DevHlp    DevHlp_UnPhysToVirt
  79.  
  80. oc_f:    popa
  81.     pop    es
  82.     pop    fs
  83.     pop    gs
  84.     endif
  85.     ret
  86. out_char    endp
  87.  
  88.  
  89. out_text    proc near
  90.     if    trace
  91.     xchg    si, [esp]
  92.     push    ax
  93. ot1:        lods    byte ptr cs:[si]
  94.         cmp    al, 0
  95.         je    ot2
  96.         call    out_char
  97.         jmp    ot1
  98. ot2:    pop    ax
  99.     xchg    si, [esp]
  100.     endif
  101.     ret
  102. out_text    endp
  103.  
  104.  
  105. out_byte    proc near
  106.     if    trace
  107.     push    bx
  108.     mov    ah, al
  109.     shr    al, 4
  110.     mov    bx, offset hex
  111.     xlat
  112.     call    out_char
  113.     mov    al, ah
  114.     and    al, 0Fh
  115.     xlat
  116.     call    out_char
  117.     pop    bx
  118.     endif
  119.     ret
  120. out_byte    endp
  121.  
  122. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  123.  
  124. init_debug    proc near
  125.     outtext    2, 'DBG init$'
  126. init_r:    clc
  127.     ret
  128. init_debug    endp
  129.  
  130. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  131.  
  132. EndCode
  133.  
  134.     end
  135.