Assign values to registers and add and subtract them

后端 未结 1 1756
失恋的感觉
失恋的感觉 2021-01-26 02:09

I am completely lost with this. I need to program that calculates the following expression, using registers: varA = (varA + varB) − (varC + varD), where varA, varB, etc., are v

相关标签:
1条回答
  • 2021-01-26 03:02
    mov    eax,varA
    add    eax,varB
    mov    ecx,varC
    add    ecx,varD
    

    This all makes perfect sense, eax = varA + varB. ecx = varC + varD.

    At this point, just

    sub eax, ecx
    

    to get eax = (varA + varB) - (varC + varD).

    I'm not sure what was intended with

    mov  ebx,varA
    sub  edx,varD
    

    That sets ebx = varA, and then sets edx = edx - varD. edx wasn't defined before, so this is a random number. Or maybe edx was originally cleared to zero, in which case edx is now equal to -varD. I wouldn't count on it though.

    0 讨论(0)
提交回复
热议问题