i have this code i have to translate it to machine code assembly language and this is really confusing
i have to right

x = 8
	y = 12
           if(x > y)
		x = y - x
	   else
		x = x - y
and
  
   int  x = -5
   int rslt = 0

        while (x !=0)
           {
               rslt = rslt + x
               x = x + 1
           }

and i would really appericate it if any body could help me

while (x !=0)
           {
               rslt = rslt + x
               x = x + 1
           }

and i would really appericate it if any body could help me

i think this is your answer, hope you know abit of assembly

x db 8d   ;defines a byte 8 in decimal
y db 12d
mov ax,[x]
mov bx, [y]
cmp ax,bx   ;compare the value of bx and ax
jg  x_more_y  ;jumps if more
sub bx,ax    ;subtract ax from bx
x_more_y:
sub ax,bx

now the fiisrt part has been solved
2nd part is also simple...

x db -5d
rslt db 0d
loop:
inc [rslt]
inc [x]   ;increment value of x
mov ax,[x]
cmp ax,0d
jne loop    ;if x!=0 then it will jump to the top of the loop. try it
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.