home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / progrmng / xm.lzh / XMMISC.ASM < prev    next >
Assembly Source File  |  1990-10-08  |  3KB  |  183 lines

  1.         .386
  2. ;
  3. ;
  4.     include        xmhd.inc
  5.     include        xmmac.mac
  6. _DATA        segment    para public USE16 'DATA'
  7.         extrn    debugflag:word
  8. _DATA        ends
  9.         
  10. _TEXT        segment    para public USE16 'CODE'
  11.         assume    cs:_TEXT, ds:_DATA
  12.         public    Msg, PutSpace, PutChar, GetChar
  13.         public    CRLF, Msg2ch, put2char, Hex32s, Hex, Hex32
  14.         public    Hexs, HexALs
  15.         extrn    a20_off:near, a20_on:near
  16. ;
  17.  
  18. Msg        proc    near
  19.         push    si
  20.         mov    si, dx
  21.         cld
  22. MsgMore:
  23.         lodsb    
  24.         cmp    al, 0
  25.         je    .MsgX
  26.         call    putchar
  27.         jmp    MsgMore
  28. .MsgX:        pop    si
  29.         ret
  30. Msg        endp
  31.  
  32. ;
  33. ; now putchar/getchar support output to the commnunication port.
  34. ;
  35. PutSpace    proc    near
  36.         mov    al,' '
  37. putchar        label    near
  38.         test    DebugFlag, MASK Sys_Out_COM
  39.         jnz    .putCom
  40. IF  PCAT
  41.         mov    ah, 0eh
  42.         int    10h
  43. ENDIF
  44. IF  FMR70
  45.         push    dx
  46.         call    a20_off
  47.         mov    dl, al
  48.         mov    ah, 1dh
  49.         int    91h
  50.         call    a20_on
  51.         pop    dx
  52. ENDIF
  53.         ret
  54. .putCom:
  55. IF PCAT        
  56.         mov    ah, 1
  57.         push    dx
  58.         mov    dx, CommPort
  59.         int    14h        
  60.         pop    dx
  61. ENDIF
  62. IF FMR70
  63. ENDIF
  64.         ret
  65.         endp
  66.  
  67. getchar        proc    near
  68. ;        test    DebugFlag, MASK Sys_Out_COM
  69. ;        jnz    .getCom
  70. IF PCAT
  71.         mov    ah,0
  72.         int    16h
  73. ENDIF
  74. IF FMR70
  75.         push    dx
  76.         push    bx
  77.         mov    ax, 0900h
  78.         int    90h
  79.         mov    al,dl
  80.         pop    bx
  81.         pop    dx
  82. ENDIF        
  83.         ret
  84. .getCom:
  85. IF PCAT
  86.         mov    ah,2
  87.         push    dx
  88.         mov    dx, CommPort
  89.         int    14h
  90.         pop    dx
  91. ENDIF
  92. IF FMR70
  93.         push    dx
  94.         mov    dl, al
  95.         mov    ah, 7
  96.         mov    al, CommPort
  97.         int    9bh
  98.         pop    dx
  99. ENDIF
  100.         ret
  101.         endp
  102.  
  103. ;
  104. ; put2char will be used to output Kanji character.
  105. ;
  106. CRLF        proc    near
  107.         mov    ax, 0d0ah
  108. Msg2ch        label    near
  109. put2char    label    near
  110.         push    ax
  111.         mov    al, ah
  112.         call    putchar
  113.         pop    ax
  114.         call    putchar
  115.         ret
  116.         endp
  117.  
  118. HexS        label    near
  119.         push    ax
  120.         call    PutSpace
  121.         pop    ax
  122.         jmp    Hex
  123.  
  124. HexALS        label    near
  125.         push    ax
  126.         call    PutSpace
  127.         pop    ax
  128.         jmp    HexAL
  129.  
  130. Hex32s        proc    near
  131.         push    eax
  132.         call    PutSpace
  133.         pop    eax
  134. Hex32:        push    eax
  135.         shr    eax, 16
  136.         call    Hex
  137.         pop    eax
  138. Hex:        push    ax
  139.         mov    al, ah
  140.         call    HexAL
  141.         pop    ax
  142. HexAL:        push    ax
  143.         shr    al, 4
  144.         call    HexDig
  145.         pop    ax
  146. HexDig:        and    ax, 0fh
  147.         mov    ah, 3
  148.         aaa
  149.         adc    al, 0
  150.         shl    al, 4
  151.         shr    ax, 4
  152.         call    PutChar
  153.         ret
  154. Hex32S        endp
  155.  
  156. _TEXT        ends
  157.         end    
  158. comment %
  159. ;
  160. ; copy parsed argument into stack of child program.
  161. ; used for C-interface (=UNIX interface)
  162. ;
  163. CopyArg        proc    near
  164.         push    ds
  165.         mov    ds, PSP
  166.         assume    ds: nothing, es: _DATA
  167.         mov    esi, 81h
  168.         movzx    ecx, ArgLen
  169.         mov    edi, ExeESP
  170.         sub    edi, ecx
  171.         and    edi, NOT 3
  172.         mov    ArgP, edi
  173.         mov    ExeESP, edi
  174.         add    edi, EData.Base
  175.         sub    edi, ThisDataBase
  176.         prefix32
  177.     rep    movsb        ;copy command line
  178.         pop    ds
  179.         assume    ds: _DATA, es: nothing
  180.         ret
  181. CopyArg        endp
  182. %
  183.