madhawaseeeee

bits

Sep 23rd, 2016
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .MODEL  SMALL   ; use memory model
  2. .STACK  100H    ; reserves 100h bytes for stack
  3. .CODE           ; starts code segment
  4.  
  5. START:  
  6.     MOV    DX, 379H    ; select status port of LPT1
  7.     IN     AX, DX      ; read input X from status port of LPT1
  8.     MOV    AH, 00H     ; neglect higher bytes of AX since LP1 is 8bit
  9.     MOV    BX,AX
  10.     MOV    CX,256      ; CX=256
  11.     SUB    CX,BX       ; CX=256-X
  12.     MOV    AX,00H      ; set initial value 0 for count
  13.  
  14. COUNTUP:
  15.         MOV     DX,378H    ; select data port of LPT1
  16.         OUT     DX,AX      ; write value in AX to DATA port
  17.         CMP     AX,CX      ; compare  current count value with CX
  18.         JZ      DONE       ; if AX and CX equal goto DONE
  19.         INC     AX         ; else keep incrementing AX
  20.         JUMP    COUNTUP    ; loop again counter
  21.  
  22. DONE:
  23.     MOV AH, 4CH    ; turminate programe with exit code of ( 256-X )
  24.     INT     21H    ; Call the interrupt to exit
  25.  
  26. END START
Advertisement
Add Comment
Please, Sign In to add comment