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 :)