We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,420 Members — Technology Publication meets Social Media

# NEED HELP ASAP

Can someone tell me what I am doing wrong in this program?
Write, assemble, and test a program to input 3 signed values (a, b, and c, in that order) and to calculate and
display the signed value of the expression b + 2(3a - 4c) + 5.

``````"call getVal  ;AX = a (user input)
mov M1, AX   ;M1 = a
call getVal  ;AX = b (user input)
mov M2, AX   ;M2 = b
call getVal  ;AX = c (user input)
mov M3, AX   ;M3 = c
call getVal  ;AX = d (user input)
mov BX, AX   ;BX = d
call getVal  ;AX = x (user input)
mov CX, AX   ;CX = x

mul BX       ;DX:AX = AX*BX = x*d = dx (usually DX=0
mov DX,M3    ; DX=c
mul Cx       ; Ax=(c + dx)x

mov DX,M2    ; DX=b
add AX ,Dx   ; Ax=b + (c + dx)x
mul CX       ;AX=(b + (c + dx)x)x

mov DX,M1    ; DX=a
add Ax,Dx    ;Ax=a + (b + (c + dx)x)x
call putVal  ;displays contents of AX, which is a + (b + (c + dx)x)x"
``````
3
Contributors
2
Replies
2 Hours
Discussion Span
10 Months Ago
Last Updated
3
Views
Denise23
Newbie Poster
1 post since Jul 2012
Reputation Points: 0
Skill Endorsements: 0

What is the problem you are having? This looks like a legitimate assembly program fragment (assuming you are using EMU8086 or a DOS box of some sort), but not exactly a complete program. The biggest issue I can see is that it doesn't compute what your supposed to; this takes in five variables, not the three specified, and the formula it calculates does not match that in the problem statement.

Schol-R-LEA
Veteran Poster
1,042 posts since Oct 2010
Reputation Points: 452
Skill Endorsements: 11

I can help you with this problem, but there are several inconsistencies to deal with first.

1:) Formula:

b + 2(3a - 4c) + 5

So how does d (line 7) & x (line 9) fit into the scheme of things. and

a + (b + (c + dx)x)x

Is this what the result is supposed to be

2:) What does getVal do. I'm assuming it strips MSB from input. This means that when you enter the digit 9, what is returned is actually DEC 57 - HEX 39 - BIN 0011 1001. Does getVal adjust so AX = 9?

ShiftLeft
Light Poster
31 posts since Jun 2012
Reputation Points: 0