944,108 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 2408
  • Assembly RSS
Mar 26th, 2006
0

is this code Right and why

Expand Post »
Guys..
See this code? is it right code or have it mistake?please advice in details,

1- By knowing the numbers: so i guess here the numbering is knowing

mov AX, 2
mov BX, 2
mov CX, 2
add AX,BX
add AX,CX
put AX
end


2- By entering the number enering from the users. here i am using memordy addressing and inderect addressing

Get AX,[AX]
Get BX,[BX]
Get CX,[CX]
add AX[AX], BX,[BX]
add AX, [AX] , CX,[CX]
put AX[AX]
end
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Dabdob is offline Offline
26 posts
since Dec 2005
Mar 26th, 2006
0

Re: is this code Right and why

Hellooooo
anybody here?!!
Reputation Points: 10
Solved Threads: 0
Light Poster
Dabdob is offline Offline
26 posts
since Dec 2005
Mar 26th, 2006
0

Re: is this code Right and why

>anybody here?!!
Yes, but let me make it clear that just because you ask a question, it doesn't mean you're entitled to an answer. We're all volunteers here, and we aren't obliged to help you if we don't want to. Bumping your thread on the assumption that you deserve an answer is very rude.

>is it right code or have it mistake?
I'm inclined to think that it's a mistake. Let's see why:
Assembly Syntax (Toggle Plain Text)
  1. Get AX,[AX]
  2. Get BX,[BX]
  3. Get CX,[CX]
What does Get do? Unless ax, bx, and cx hold the addresses of memory locations that you want to write to, I would question why you're using indirect memory addressing here, and the purpose of the other operand.
Assembly Syntax (Toggle Plain Text)
  1. add AX[AX], BX,[BX]
That's not even a valid syntax for add. You have 3 operands instead of 2, and it looks like you're trying to use ax as an offset for ax?
Assembly Syntax (Toggle Plain Text)
  1. add AX, [AX] , CX,[CX]
Once again, add doesn't have a valid syntax that takes 4 operands.
Assembly Syntax (Toggle Plain Text)
  1. put AX[AX]
You're using ax as an offset into ax?

My only suggestion for the correct code would be a guess:
Assembly Syntax (Toggle Plain Text)
  1. Get dx ; Using ax for other things
  2. Get bx
  3. Get cx
  4. mov ax,[dx] ; add doesn't allow mem,mem operands
  5. add ax,[bx]
  6. add ax,[cx]
  7. Put ax
This is on the assumption that dx, bx, and cx already contain addresses to memory that you want to write to. Then Get uses those addresses to get user input. The value of contained at the address of dx is stored in ax, then the values contained at the addresses of bx and cx are added to ax, and the value of ax (the result) is sent to Put to be printed to the screen.

But even then it's still not entirely correct. IIRC, dx and cx can't be used for addressing in 16-bit programs.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: Control Intructions
Next Thread in Assembly Forum Timeline: copy string and convert to upper case





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC