Advertisement
Guest User

Untitled

a guest
Nov 9th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PrintNumber:  PUSH DX      ;Push DX to use it to print output[i] using interrupt
  2.                 MOV DL, 10   ;Clear DX
  3.                
  4.                 PUSH CX      ;Use CX to keep track of how many digits to print in this number
  5.                 MOV CX, 0                                                                      
  6.                 PUSH BX      ;Push BX to use it to store remainder that is in AH
  7.        
  8.        Divide:  INC CX       ;Increment digit counter
  9.                 DIV DL       ;Divide AX/DX
  10.                 MOV BX, 0
  11.                 MOV BL, AH   ;Store remainder in BL
  12.                 MOV AH, 0
  13.                 PUSH BX      ;Push remainder
  14.                 CMP AL, 0  
  15.                 JNZ Divide   ;Divide till number is reaches 0
  16.                 MOV AH, 2h   ;Prepare the call to print character ( 2h )
  17.                
  18.         Print:  
  19.                 POP DX       ;Pop remainders(digits)
  20.                 ADD DX, 48   ;Add 48 to make it an ASCII char
  21.                 INT 21H      ;Print digit
  22.                 LOOP Print   ;Loop till CX = 0
  23.                 MOV DL, 20H ;Print a space
  24.                 INT 21H      ;^
  25.                 POP BX       ;Restore all changed registers
  26.                 POP CX
  27.                 POP DX
  28.                 JMP Cont3    ;Continue calculating filter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement