is this code Right and why

Reply

Join Date: Dec 2005
Posts: 26
Reputation: Dabdob is an unknown quantity at this point 
Solved Threads: 0
Dabdob Dabdob is offline Offline
Light Poster

is this code Right and why

 
0
  #1
Mar 26th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 26
Reputation: Dabdob is an unknown quantity at this point 
Solved Threads: 0
Dabdob Dabdob is offline Offline
Light Poster

Re: is this code Right and why

 
0
  #2
Mar 26th, 2006
Hellooooo
anybody here?!!
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,570
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 708
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: is this code Right and why

 
0
  #3
Mar 26th, 2006
>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:
  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.
  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?
  1. add AX, [AX] , CX,[CX]
Once again, add doesn't have a valid syntax that takes 4 operands.
  1. put AX[AX]
You're using ax as an offset into ax?

My only suggestion for the correct code would be a guess:
  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.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Assembly Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC