943,972 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 5544
  • Assembly RSS
May 1st, 2005
0

shrd instruction and converting integers to ascii

Expand Post »
I have 2 programs im stuck with at the moment.
In the first one im supposed to use the shrd instruction to shift a variable & get a specific number.

Assembly Syntax (Toggle Plain Text)
  1.  
  2. title 'exercise 13'
  3.  
  4. .model small
  5. .stack 100h
  6. .386
  7. .data
  8. byte1 db 3Bh ;after 03h
  9. byte2 db 46h ;after B4h
  10. byte3 db 0FFh ;after 6Fh
  11. value db ?
  12. .code
  13. main proc
  14. mov ax,@data
  15. mov ds,ax
  16.  
  17. mov bx,0Bh
  18. mov dl,byte2
  19. movzx ax,dl
  20. shrd ax,bx,4 ; ah:1011 0000 al: 0000 0100 (B004h)
  21. mov bx,ax
  22. shld ax,bx,4
  23. and ax,0000000011111111b ;ah:0000 0000 al: 0100 1011 ; 4Bh (should be B4h)
  24.  
  25.  
  26. mov dx,06h
  27. mov bl,byte3
  28. movzx ax,bl
  29. shrd ax,dx,4 ;(600Fh)
  30.  
  31.  
  32. mov cx,4
  33. L1:
  34. shr byte1,1 ; 03h
  35. loop L1
  36.  
  37. mov ax,4C00h
  38. int 21h
  39. main endp
  40. end main

and in the second im supposed to take a decimal number and convert it to individual ascii characters. I've used it with a hexadecimal number because that's all i've got working so far , but I need to do it with a decimal number and that's where im stuck.

Assembly Syntax (Toggle Plain Text)
  1.  
  2. .model small ; works but only with hexadecimal
  3. .stack 100h
  4. .data
  5. packedval dw 3425h
  6. .code
  7. main proc
  8. mov ax,@data
  9. mov ds,ax
  10.  
  11. mov si,0
  12. mov cx,2
  13.  
  14. next:
  15. mov al,byte ptr packedval[si]
  16. and al,00001111b
  17. or al,30h
  18. mov ah,6
  19. mov dl,al
  20. int 21h
  21. mov al,byte ptr packedval[si]
  22. and al,11110000b
  23. shr al,1
  24. shr al,1
  25. shr al,1
  26. shr al,1
  27. or al,30h
  28. mov ah, 6
  29. mov dl,al
  30. int 21h
  31. inc si
  32. loop next
  33.  
  34. mov ax,4C00h
  35. int 21h
  36. main endp
  37. end main

thanks for any help
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
unseen is offline Offline
3 posts
since Mar 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: Assembly newbie question
Next Thread in Assembly Forum Timeline: Extreme beginner





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC