TITLE Addition and Subtraction (AddSub3.asm)
INCLUDE Irvine32.inc
includelib irvine32.lib
.data
Rval SDWORD ?
Xval SDWORD 26
Yval SDWORD 30
Zval SDWORD 40
var1 SDWORD 3
var2 SDWORD 6
var3 SDWORD 4
var4 SDWORD ?
.code
mainCRTStartup PROC
; Expression: Rval = -Xval + (Yval - Zval)
mov eax,Xval
neg eax ; -26
mov ebx,Yval
sub ebx,Zval ; -10
add eax,ebx
mov Rval,eax ; -36
; Expression: var4 = (var1 * -5) / (-var2 % var3);
mov eax,var2 ; begin right side
neg eax
cdq ; sign-extend dividend
idiv var3 ; EDX = remainder
mov ebx,edx ; EBX = right side
mov eax,-5 ; begin left side
imul var1 ; EDX:EAX = left side
idiv ebx ; final division
mov var4,eax ; quotient
exit
mainCRTStartup ENDP
END