Home > OS >  Is machine code and assembly code part of the architecture?
Is machine code and assembly code part of the architecture?

Time:12-17

Is assembly code and machine code specified by the architecture? I know that how you implement the architecutre is uo to you(it is up the microarchitecture can implement the architecture). But I don't understand if the assembly or machine code is specified by the architecture?

CodePudding user response:

Machine code is decoded by the CPU; its format, and the behaviour of each instruction, are part of the instruction-set architecture implemented by the CPU.

Assembly source code is arbitrary, only dealt with by software (assemblers and disassemblers). As @old_timer likes to say, assembly is defined by the software tool, not the CPu.

Often the vendor will define an asm syntax so they can use it in their manual when documenting how the ISA works, like register names and instruction names. So it gets used in the ISA documentation, but primarily as a way to describe it to humans. (Or also as a specification for an assembly language recommended by the vendor.)

For many real-world ISAs, nobody felt the need to invent a different text syntax for the same machine-code format. (Except maybe Go and the Plan 9 ecosystem it's derived from.)

But some ISAs, most notoriously x86, have many different text syntaxes. x86 machine code has some redundancy in how the same instruction can be encoded, and some syntaxes allow overrides to specify the details. But that wasn't the reason for people inventing different syntaxes.

There are multiple flavours of Intel syntax (https://stackoverflow.com/tags/intel-syntax/info), the syntax used in Intel and AMD's manuals. MASM/TASM are very similar, vs. NASM/FASM having some different interpretations. And that's just for the instruction syntax; directives also differ between assemblers that mostly agree on the syntax for instructions, operands, and addressing modes.

AT&T was designed to look more like PDP-11 syntax, with destination operand on the right, and with % decorations on register names to make parsing simpler. https://stackoverflow.com/tags/att/info

  • Related