home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / TASMSWAN.ZIP / SINGLE.ASM < prev    next >
Assembly Source File  |  1989-07-17  |  3KB  |  155 lines

  1. %TITLE  "Single-step (trap) demo"
  2.  
  3.     IDEAL
  4.     DOSSEG
  5.     MODEL    small
  6.     STACK    256
  7.  
  8.  
  9. cr        EQU     13
  10. lf        EQU    10
  11. Trapping    EQU    0
  12. TurnOnTrap    EQU    1
  13. TurnOffTrap    EQU    2
  14.  
  15.  
  16.     DATASEG
  17.  
  18. exitCode    db    0
  19. spaces        db    '    ',0
  20. offMsg        db    cr,lf,'Single-step trap is off',cr,lf,0
  21. onMsg        db    cr,lf,'Single-step trap is on',cr,lf,0
  22. pauseMsg    db    cr,lf,'Press any key to continue ...',0
  23. countMsg    db    cr,lf,lf,'Count = 50!',cr,lf,0
  24. trapSwitch    db    0
  25. string        db    40 DUP (?)
  26. count        dw    ?
  27. trapSeg        dw    ?
  28. trapOfs        dw    ?
  29.  
  30.  
  31.     CODESEG
  32.  
  33. ;--------- from STRIO.obj, BINASC.obj, KEYBOARD.obj
  34.     EXTRN    StrWrite:proc, NewLine:proc, BinToAscDec:proc
  35.     EXTRN    BinToAscHex:proc, GetCh:proc
  36.  
  37. Start:
  38.     mov    ax,@data
  39.     mov    ds,ax
  40.     mov    es,ax
  41.     mov    ax,3501h
  42.     mov    [trapSeg],es
  43.     mov    [trapOfs],bx
  44.     push    ds
  45.     mov    ax,2501h
  46.     push    cs
  47.     pop    ds
  48.     mov    dx, offset Stepper
  49.     int    21h
  50.     pop    ds
  51.     mov    di, offset offMsg
  52.     call    Counter
  53.     mov    di, offset onMsg
  54.     mov    [trapSwitch], TurnOnTrap
  55.     int    1
  56.     call    Counter
  57.     mov    [trapSwitch],TurnOffTrap
  58.  
  59.     mov    di, offset offMsg
  60.     call    Counter
  61. Exit:
  62.     push     ds
  63.     mov    ax,2501h
  64.     mov    ds,[trapSeg]
  65.     mov    dx,[trapOfs]
  66.     int    21h
  67.     pop    ds
  68.     mov    ah,04Ch
  69.     mov    al,[exitCode]
  70.     int    21h
  71.  
  72. PROC    Counter
  73.     call    StrWrite
  74.     call    Pause
  75.     mov    [count],0
  76. @@10:
  77.     inc    [count]
  78.     mov    ax,[count]
  79.     mov    cx,4
  80.     mov    di, offset string
  81.     call    BinToAscDec
  82.     call    StrWrite
  83.     mov    di, offset spaces
  84.     call    StrWrite
  85.     cmp    [count],100
  86.     jb    @@10
  87.     ret
  88. ENDP    Counter
  89.  
  90. PROC    Pause
  91.     mov    di, offset pauseMsg
  92.     call    StrWrite
  93.     call    GetCh
  94.     call    NewLine
  95.     ret
  96. ENDP    Pause
  97.  
  98. %NEWPAGE
  99. ;------------------------------------------------------------------------
  100. ; Stepper -   Single-step trap ISR
  101. ;------------------------------------------------------------------------
  102. ;    Input:   [trapSwitch] = TurnOnTrap    -> Single-step mode enabled
  103. ;         [trapSwitch] = TurnOffTrap   -> Single-step mode disabled
  104. ;         [trapSwitch] = ???           -> NO action
  105. ;    Output:  none
  106. ;       Registers:  none
  107. ;------------------------------------------------------------------------
  108. PROC    Stepper
  109.     sti
  110.     push    bp
  111.     mov    bp,sp
  112.     push    ax
  113.     push    bx
  114.     push    cx
  115.     push    dx
  116.     push    di
  117.     push    si
  118.     push    ds
  119.     push    es
  120.     mov    ax,@data
  121.     mov    ds,ax
  122.     mov    es,ax
  123.     cmp    [trapSwitch], TurnOnTrap
  124.     jne    @@10
  125.     or    [word bp + 6], 0100h
  126.     mov    [trapSwitch], Trapping
  127.     jmp    @@99
  128. @@10:
  129.     cmp    [trapSwitch], TurnOffTrap
  130.     jne    @@20
  131.     and    [word bp + 6], 0FEFFh
  132.     jmp    @@99
  133. @@20:
  134.     cmp    [count], 50
  135.     jne    @@99
  136.     mov    di,offset countMsg
  137.     call    StrWrite
  138.     call    Pause
  139.     inc    [count]
  140.     call    NewLine
  141. @@99:
  142.     pop    es
  143.     pop    ds
  144.     pop    si
  145.     pop    di
  146.     pop    dx
  147.     pop    cx
  148.     pop    bx
  149.     pop    ax
  150.     pop    bp
  151.     iret
  152. ENDP    Stepper
  153.  
  154.     END    Start
  155.