Advertisement
labib24

Untitled

Jun 9th, 2023
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 0.77 KB | None | 0 0
  1. .MODEL SMALL
  2. .DATA
  3. M1 DB 'Type a character :','$'
  4. M2 DB 0AH,0DH,'The ASCII Code of  '
  5. C1 DB ?,' In Binary is :','$'
  6. M3 DB 0AH,0DH,'The number of 1 bit is '
  7. C2 DB ?,'$'
  8. .CODE
  9.  
  10.  
  11. MAIN PROC
  12. MOV AX,@DATA                 ;Initialize DS
  13. MOV DS,AX
  14. MOV AH,9  
  15. LEA DX,M1
  16. INT 21H
  17.  
  18. MOV AH,1                     ;read the character
  19. INT 21H
  20. MOV BL,AL
  21. MOV C1,AL                    ;store the character
  22. MOV AH,9
  23. LEA DX,M2
  24. INT 21H
  25.  
  26. MOV BH,0  
  27. MOV CX,8
  28. MOV AH,2
  29. L1: SHL BL,1                ;display content of BL
  30. JC L2
  31. MOV DL,'0'
  32. INT 21H
  33. JMP L4
  34. L2: MOV DL,'1'
  35. INT 21H
  36. INC BH  
  37. L4: LOOP L1
  38. ADD BH,30H                  ;convert to char.
  39. MOV C2,BH
  40. MOV AH,9  
  41. LEA DX,M3
  42. INT 21H
  43.  
  44. MOV AH,4CH  
  45. INT 21H
  46. MAIN ENDP
  47. END MAIN
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement