home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / microcrn / issue_48.arc / TRAP.ARC / SUBROUTS.ASM < prev    next >
Assembly Source File  |  1989-04-17  |  2KB  |  137 lines

  1. ;************************************************
  2. ;*  02/17/89  *  SUBROUTS.ASM  *  Version 1.00    *
  3. ;************************************************
  4. ;*                        *
  5. ;*    Handy Subroutines            *
  6. ;*                        *
  7. ;************************************************
  8.  
  9. ;Stack during most interrupts
  10.  
  11. ;if pusha, mov bp,sp followed by
  12. ;  push es, push ds.
  13.     PALL_DS    EQU -4
  14.     PALL_ES    EQU -2
  15.     PALL_DI    EQU 0
  16.     PALL_SI    EQU 2
  17.     PALL_BP    EQU 4
  18.     PALL_SP    EQU 6
  19.     PALL_BX    EQU 8
  20.     PALL_DX    EQU 10
  21.     PALL_CX    EQU 12
  22.     PALL_AX    EQU 14
  23. ;if pusha done after int
  24.     PALL_IP    EQU 16
  25.     PALL_CS    EQU 18
  26.     PALL_FLAGS    EQU 20
  27.       CARRY_FLAG      EQU 0001H
  28.       ZERO_FLAG          EQU 0040H
  29.       INT_ENABLE_FLAG      EQU 0200H    
  30.  
  31. ;*********************************************************
  32. PrinterPort    equ 0
  33. PrinterFlag    DB    0    ;set by equate in COTRAP.ASM
  34.  
  35. Putc   PROC NEAR  ;sends character in AL to video/Printer
  36.   CMP    PrinterFlag, 0
  37.   JNE    @F
  38.   RomCall    Video, TTYOut
  39.   JMP    short    PC_99
  40. @@:
  41.   PUSH    DX
  42.   MOV    DX, PrinterPort
  43.   RomCall    Printer, PSend
  44.   POP    DX
  45. PC_99:
  46.   RET
  47. Putc   ENDP
  48.   
  49. Puts PROC NEAR    ;sends string at DS:SI to video/printer
  50.   CLD
  51.   CMP    PrinterFlag, 0
  52.   JNE    SO_20
  53. SO_11:    ;send output to video
  54.   LODSB
  55.   OR    AL, AL
  56.   JZ    SO_10
  57.   RomCall    Video, TTYOut
  58.   JMP    SO_11
  59.  
  60. SO_20:
  61.   PUSH    DX
  62.   MOV    DX, PrinterPort
  63. SO_21:    ;send output to printer
  64.   LODSB
  65.   OR    AL, AL
  66.   JZ    SO_22
  67.   RomCall    Printer, PSend
  68.   JMP    SO_21
  69. SO_22:
  70.   POP    DX
  71. SO_10:
  72.   RET
  73. Puts ENDP
  74.  
  75. IP_StringOut PROC NEAR
  76.   PUSH    BP
  77.   MOV    BP,SP
  78.   PUSH    AX
  79.   PUSH    SI
  80.   PUSH    DS
  81.   MOV    AX, CS
  82.   MOV    DS, AX
  83.   MOV    SI, 2[BP]
  84.   CALL    Puts
  85.   MOV    2[BP], SI
  86.   POP    DS
  87.   POP    SI
  88.   POP    AX
  89.   POP    BP
  90.   RET
  91. IP_StringOut ENDP
  92.  
  93. HexNibble:
  94.   push    ax
  95.   and    al, 0fh
  96.   cmp    al, 9
  97.   jbe    @f
  98.   add    al, 7
  99. @@:
  100.   add    al, '0'
  101.   call    Putc
  102.   pop    ax
  103.   ret
  104.   
  105. HexByte PROC NEAR
  106.   push    ax
  107.   shr    ax, 4
  108.   call    HexNibble
  109.   pop    ax
  110.   call    HexNibble
  111.   ret
  112. HexByte ENDP
  113.  
  114. HexWord PROC NEAR
  115.   push    ax
  116.   mov    al, ah
  117.   call    HexByte
  118.   pop    ax
  119.   call    HexByte
  120.   ret
  121. HexWord ENDP
  122.  
  123. Space PROC NEAR USES AX
  124.   mov    al, ' '
  125.   call    Putc
  126.   ret
  127. Space ENDP
  128.  
  129. CRLF PROC NEAR USES AX
  130.   mov    al, CR
  131.   call    Putc
  132.   mov    al, LF
  133.   call    Putc
  134.   ret
  135. CRLF ENDP
  136. ;------------------------------------------------
  137.