Advertisement
Guest User

Print Binary Using LOGICAL SHIFT

a guest
Oct 24th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. ; You may customize this and other start-up templates;
  3. ; The location of this template is c:\emu8086\inc\0_com_template.txt
  4.  
  5. org 100h
  6. .stack small
  7. .data
  8.     count dw 0
  9.     input dw ?
  10.     string db ?
  11. ; add your code here    
  12. ;jc          
  13. .code
  14.  
  15. mov ah,01h
  16. int 21h
  17.      
  18.     mov cx,ax
  19.     sub cx,48
  20.  
  21. mov bx,16
  22.  
  23. whileLoop2:
  24.     shl cx,1    
  25.     jc print1
  26.     jmp print0
  27.    
  28.  
  29. print1:
  30.         mov ah,02h
  31.         mov dx,'1'
  32.         int 21h
  33.         dec bx
  34.         cmp bx,1
  35.         jge whileLoop2      
  36.          
  37.  
  38. cmp bx,0
  39. jmp end
  40.  
  41. print0:    
  42.         mov ah,02h
  43.         mov dx,'0'
  44.         int 21h
  45.         dec bx
  46.         cmp bx,1
  47.         jge whileLoop2
  48.                    
  49. end: ret                
  50. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement