0

Can someone check if my algorithm is correct

.data
    val1        BYTE        15h
    val2        WORD        8765h
    val3        DWORD   0FFFFh
    val4        WORD        7FFFh

Implement the following expression in assembly language: val3 = (-val4 + val3) – val2

movzx eax, val4
neg eax
add val3, eax
movzx ebx, val2
sub val3 ebx
1
  • did i use movzx correctly, because the types are different, and I wanted to changed to 32 buts Commented Feb 21, 2013 at 22:37

1 Answer 1

2

The code looks correct if your 16-bit variables are assumed to hold non-negative values only.

However, the comma is missing in the last instruction.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.