Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

arithmetic expression: help me please!

hello. im new here.
i have a problem.
i cant get the exactly output for my code.
i should get this as my output:

OUTPUT:
Before Exchange:
Result for Expression 1 (X): -146

BUT,
i got this:
Before Exchange:
Result for Expression 1 (X): -6

--------------------------------------------------
INCLUDE Irvine32.inc

.data

a DWORD 4
b DWORD 26
see SDWORD -6 ; see == c
y DWORD 23
ex1 SDWORD 0
ex1a SDWORD 0
ex2 SDWORD 0
resultX SDWORD 0
resultZ SDWORD 0
str1 BYTE "Before exchange: ", 0
str2 BYTE "Result for expression 1 (X): ",0
str3 BYTE "Result for expression 2 (Y): ",0
str4 BYTE "After exchange: ", 0
str5 BYTE "Result for X: ",0
str6 BYTE "Result for Y: ",0

.code
main PROC

;int 3
mov edx,OFFSET str1
call WriteString
call Crlf

mov edx,OFFSET str2
call writeString

; Expression 1: X = [(a) + (b*c)]-[(y+1)/ (-a)]
; bracket 1

mov eax, b ; eax = 0
imul see ; eax = 26d ; 1Ah
mov ebx, a ; eax = fffffff64h ;-156d
add ebx, eax ; ebx = 4h ; ebx = ffffff68h (jawapan ;bracket 1=ebx)

mov ecx, y ; ex1a = ffffff68h ; -152d
inc ecx ; ecx = 17h ; 23d
neg a ; ecx = 18h ; 24d
;cdq
idiv ecx ; a = -4h ;-4d
;mov edx, ecx ; ecx = fffffffAh ; -6d
sub ecx, ebx ; edx = fffffffAh ;-6d(jawapan bracket 2=edx)
mov ex1, ecx ;ebx = (-152-(-6)) = -146d ;ffffff6Eh

;mov ebx, ex1
call WriteInt
;mov ex1, eax
call Crlf
call WaitMsg
exit
main ENDP
END main
Sign In or Register to comment.