aksikan -1 Newbie Poster

Hi: This is the question with my answer. Can you please check and tell me if my answer is correct or if it needs any sort of improvement?
1. Given the data below, design IA-32 instructions to add the two
numbers in x and y using ascii operations and save the sum in z.
("5321" + "2389" ---> "7710")

x byte "5321"
y byte "2389"
z byte 5 dup ('0')

Answers:


;TO ADD THE TWO NUMBERS IN X AND Y USING ASCII
;OPERATIONS AND SAVE THE SUM IN Z.
;("5321" + "2389" ---> "7710")

include irvine32.inc
.data
X BYTE "5321"
Y BYTE "2389"
Z BYTE 5 DUP ('0')
.code
begin:
mov esi,SIZEOF x - 1
mov edi,SIZEOF x
mov ecx,SIZEOF x
mov bh, 0
next:
mov ah,0
mov al,x[esi]
add al,bh
aaa
mov bh,ah
or bh,30h
add al,y[esi]
aaa
or bh,ah
or bh,30h
or al,30h
mov z[edi],al
dec esi
dec edi
loop next
mov z[edi],bh
;print
mov edx,offset z
call WriteString
call Crlf
mov eax,10000
call delay
exit
end begin

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.