0

I just started learning computer organization and architecture. Computer organization by Carl Hamacher, Zaki... is my reference textbook. Currently, I am learning basic assembly instruction for adding two numbers A and B, and storing the result in C. What is the correct way to represent this basic operation;

Add A, B, C Operation Source 1, Source 2, Destination

(Page 37 section 2.4.3 Computer Organization by Carl Hamacher 5th Edition ISBN:7-111-10346-7)

Or

Add C, A, B Operation Destination, Source 1, Source 2

(Page 32 section 2.3 COMPUTER ORGANIZATION AND EMBEDDED SYSTEMS by Carl Hamacher 6th Edition ISBN 978–0–07–338065–0)

This is a dumb question I know, but it really confuses me. The first method is what I saw in the 5th edition of my reference book. But in the 6th edition, the same operation is represented like in the second method (Also many websites prefer the second method).

Is there any point in this 'order'?

mig001
  • 179
  • 1
  • 18

1 Answers1

2

Different assemblers use different syntax. e.g. AT&T and Intel syntax use opposite orders for the same ISA (x86). Use the order that matches the actual assembler (software) you're using, for your target machine.

Either way it's just syntax to represent machine code, no fundamental difference.

related:

Most of these operand-order Q&As focus on x86, primarily because there are multiple syntaxes in widespread use, and the one used by tools like gcc and GDB by default is opposite the one used in Intel's manuals.

On ISAs with only one syntax, but destination-last order, like M68K and PDP-11, it's just normal and doesn't get talked about.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • So I shouldn't be worried about this order. right? – mig001 May 19 '21 at 05:32
  • @ACA: Oh, were you asking about x86 assembly specifically? If you'd said so, this could have just been closed as a duplicate instead of spending time writing an answer about assembly in general across different architectures. – Peter Cordes May 19 '21 at 05:37
  • No. I wasn't asking about anything specifically. I am learning assembly for the first time. I only wanted to know if there is some convention that I should know (Because I saw two versions of instructions by the same author). Thanks for the clarification. – mig001 May 19 '21 at 06:28
  • @ACA: Ok, that's fine then. I was surprised that that x86 example would help so much for the general case, but glad it did. You didn't say what (if any) real-world instruction-set the book is talking about. – Peter Cordes May 19 '21 at 06:54