home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / lptpick / lpt.asm next >
Assembly Source File  |  1989-12-03  |  3KB  |  111 lines

  1. ; LPT-2.asm
  2. ; Reverses initial LPT1 and LPT2 ports (ports 0378h and 0278h)
  3. ; Note: 0000:0408h begins port addresses, initially 78 03 78 02
  4.  
  5. jmp LPTS
  6.  
  7. LPTS:
  8.    push ES           ; save registers being used
  9.    push AX
  10.    push DX
  11.    push SI
  12.  
  13.    call CMDLINE      ; command line-> CMDLN    its length-> CMDLEN (not used)
  14.    call DLCHAR       ; puts first non-blank in DL
  15.    call LPT1         ; if DL = '1' ports 0378h and 0278h respectively
  16.    call LPT2         ; if DL = '2' ports 0278h and 0378h respectively
  17.  
  18. ENDLPT:
  19.    pop  SI           ; restore registers
  20.    pop  DX
  21.    pop  AX
  22.    pop  ES
  23.    int  20h
  24.  
  25. ;* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  26. ;Procedure LPT1
  27. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  28. LPT1 proc
  29.    cmp  DL,'1'
  30.    jne  RETLPT1
  31.    xor  AX,AX        ; ES = 0000
  32.    mov  ES,AX
  33.    mov  AX,0378h     ; move 0378 (LPT1 port address) to 0000:0408
  34.    mov  [ES:408H],AX
  35.    mov  AX,0278h     ; move 0278 (LPT2 port address) to 0000:040A
  36.    mov  [ES:40Ah],AX
  37. RETLPT1:
  38.    ret
  39. LPT1 endp
  40.  
  41. ;* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  42. ;Procedure LPT2
  43. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  44. LPT2 proc
  45.    cmp  DL,'2'
  46.    jne  RETLPT2
  47.    xor  AX,AX        ; ES = 0000
  48.    mov  ES,AX
  49.    mov  AX,0278h     ; move 0278 (LPT2 port address) to 0000:0408
  50.    mov  [ES:408H],AX
  51.    mov  AX,0378h     ; move 0378 (LPT1 port address) to 0000:040A
  52.    mov  [ES:40Ah],AX
  53. RETLPT2:
  54.    ret
  55. LPT2 endp
  56.  
  57. ;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  58. ;*  Procedure CMDLINE (from CMDLINE.asp)
  59. ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  60. ;*  Copies DOS command line to data storage area CMDLN, appending '$'
  61. ;*  Copies DOS command length to data storage area CMDLEN
  62. ;*
  63. ;*  Gets command line from the PSP (Program Segment Prefix)
  64. ;*     offset 128 : length of command line
  65. ;*     ofset  129 : beginning of commandline
  66.  
  67. CMDLINE  PROC
  68.  
  69.          JMP CMDSTART
  70.  
  71. ; -----data storage area-------
  72. CMDLEN   db  ?
  73. CMDLN    db  127 dup(?)
  74.          db  '$'
  75.  
  76. ; -----code-------
  77. CMDSTART:
  78. ; copy command line length to CMDLEN
  79.        mov al,[ds:128]
  80.        mov cmdlen,al
  81. ; copy command line
  82.        mov  ax,129     ; command line offset in Program Segment Prefix
  83.        mov  si,ax      ; ...into source index register
  84.        lea  DI,CMDLN   ; command line storage area into destimation index reg
  85.        xor  cx,cx      ; length of command line
  86.        mov  cl,cmdlen  ; ...into cx register
  87.        rep  movsb      ; move command line --> CMDLN
  88.        mov  [di],'$'   ; append '$' at end
  89.  
  90.        ret
  91. CMDLINE ENDP ; end of procedure CMDLINE
  92.  
  93. ;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  94. ;* Procedure DLCHAR
  95. ;* strips leading blanks from CMDLINE
  96. ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  97. DLCHAR proc
  98.        lea SI, CMDLN
  99. GETDLCHAR:
  100.        mov DL, [SI]
  101.        cmp DL, ' '
  102.        jne RETDLCHAR
  103.        cmp DL, '$'
  104.        je  RETDLCHAR
  105.        inc SI
  106.        jmp GETDLCHAR
  107. RETDLCHAR:
  108.        ret
  109. DLCHAR endp ; end procedure DLCHAR
  110.  
  111. end