Should I initialize the register in x86 assembly? -


i'm trying solve exercise :

assume given values in eax,ebx,ecx. write code adds values inside registers, , stores final result inside edx.

my code :

mov eax,3 mov ebx,4 mov ecx,1 add edx,eax add edx,ebx add edx,ecx 

do have initialize register edx (mov edx,0) ?

do have initialize register edx (mov edx,0) ?

the way code written need clear edx prior first add, either mov edx, 0 or xor edx, edx. instead of adding instruction can replace first add mov:

mov edx,eax   ; edx = eax add edx,ebx   ; edx += ebx add edx,ecx   ; edx += ecx 

or, 1 instruction less:

lea edx,[eax + ebx]  ; edx = eax + ebx add edx,ecx          ; edx += ecx 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -