Advertisement
madmaxhasan

Number of 0 in Binary

Apr 7th, 2018
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .MODEL SMALL
  2. .STACK 100
  3.  
  4. .DATA
  5.    
  6.     M1 DB 'ENTER CHAR: $'
  7.     M2 DB 0AH, 0DH, 'THE ASCII CODE OF: '
  8.     C1 DB ?, 'IN BINARY IS: $'
  9.     M3 DB 0AH, 0DH, 'THE NUMBER OF 0 BIT IS: '
  10.     C2 DB ?, '$'
  11.    
  12. .CODE
  13.  
  14. MAIN PROC
  15.    
  16.     MOV AX, @DATA
  17.     MOV DS, AX
  18.    
  19.     LEA DX, M1
  20.     MOV AH, 9
  21.     INT 21H
  22.    
  23.     MOV AH, 1
  24.     INT 21H
  25.    
  26.     MOV BL, AL
  27.     MOV C1, AL
  28.    
  29.     LEA DX, M2
  30.     MOV AH, 9
  31.     INT 21H
  32.    
  33.     MOV BH, 0
  34.     MOV CX, 8
  35.    
  36.     MOV AH, 2
  37.    
  38. L1: SHL BL, 1
  39.     JC L2
  40.     MOV DL, '0'
  41.     INT 21H
  42.     INC BH
  43.     JMP L3
  44.    
  45. L2: MOV DL, '1'
  46.     INT 21H
  47.    
  48. L3: LOOP L1
  49.    
  50.     ADD BH, 30H
  51.     MOV C2, BH
  52.    
  53.     LEA DX, M3
  54.     MOV AH, 9
  55.     INT 21H
  56.    
  57.     MOV AH, 4CH
  58.     INT 21H
  59.    
  60. MAIN ENDP
  61. END MAIN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement