User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Assembly section within the Software Development category of DaniWeb, a massive community of 422,542 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,650 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Assembly advertiser: Programming Forums
Views: 3746 | Replies: 0
Reply
Join Date: Mar 2005
Posts: 3
Reputation: unseen is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
unseen unseen is offline Offline
Newbie Poster

shrd instruction and converting integers to ascii

  #1  
May 1st, 2005
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.

title 'exercise 13'

.model small
.stack 100h
.386
.data
byte1 db 3Bh  ;after 03h
byte2 db 46h  ;after B4h
byte3 db 0FFh ;after 6Fh
value db ?
.code
main proc
   mov ax,@data
   mov ds,ax
   
   mov bx,0Bh
   mov dl,byte2
   movzx ax,dl
   shrd ax,bx,4   ; ah:1011 0000  al: 0000 0100  (B004h)
   mov bx,ax
   shld ax,bx,4
   and ax,0000000011111111b  ;ah:0000 0000 al: 0100 1011  ; 4Bh (should be B4h)
   
   
   mov dx,06h
   mov bl,byte3
   movzx ax,bl
   shrd ax,dx,4   ;(600Fh)
   
   
   mov cx,4
   L1:
     shr byte1,1  ; 03h
     loop L1
     
   mov ax,4C00h
   int 21h
main endp
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.

.model small   ; works but only with hexadecimal 
.stack 100h
.data
packedval dw 3425h
.code
main proc
   mov ax,@data
   mov ds,ax
   
   mov si,0
   mov cx,2
   
   next:
     mov al,byte ptr packedval[si]
     and al,00001111b
     or al,30h 
     mov ah,6
     mov dl,al
     int 21h
     mov al,byte ptr packedval[si]
     and al,11110000b
     shr al,1
     shr al,1
     shr al,1
     shr al,1
     or al,30h
     mov ah, 6
     mov dl,al
     int 21h
     inc si
   loop next
   
   mov ax,4C00h   
   int 21h
main endp
end main

thanks for any help
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Assembly Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Assembly Forum

All times are GMT -4. The time now is 12:34 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC