DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Assembly (http://www.daniweb.com/forums/forum125.html)
-   -   shrd instruction and converting integers to ascii (http://www.daniweb.com/forums/thread22915.html)

unseen May 1st, 2005 9:56 pm
shrd instruction and converting integers to ascii
 
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 :)


All times are GMT -4. The time now is 12:43 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC