2

I have a few confusions

  • Is assembly implemented only in software with assembler?

  • Who updates and writes assemblers?

  • Is the cpu not even aware that assembly exists?

  • If let's say Intel releases a new cpu with added new instructions, what needs to be done to utilize those new instructions?

    I mean In the end the cpu executes only machine code which is then translated to electrical signals through microcode engine.

Community
  • 1
  • 1
lychee
  • 1,771
  • 3
  • 21
  • 31
  • 1
    This isn't entirely clear. Assembly language is just another programming language that happens to be *very* close (like practically 1:1) with the underlying instruction set. – Oliver Charlesworth Feb 08 '15 at 20:03
  • So the in this context x64 assembly designs and implements intel? – lychee Feb 08 '15 at 20:10
  • Related: [How does an Assembler work at a hardware level?](https://stackoverflow.com/q/71719425) - assemblers are just software. – Peter Cordes Apr 03 '22 at 01:02

3 Answers3

5

Is assembly implemented only in software with assembler?

Yes. Assembly language is a programming language just like any other, it just uses operation codes that are very close to the instruction set in the processor. It still compiles from a text file that contains source code into machine code that the processor can use.

Who updates and writes assemblers?

Anyone who likes to, from large software companies like MASM from Microsoft, to open source projects like The netwide assembler (NASM).

The companies creating the processors specify the instruction sets, and anyone can write an assembler that compiles to that set.

Is the cpu not even aware that assembly exists?

Exactly. The processor only executes machine code, it can't know if it was created by compiling assembly source code or Visual Basic source code.

If let's say Intel releases a new cpu with added new instructions, what needs to be done to utilize those new instructions?

You can use them directly in the assembler by just putting the byte codes for the instructions in the code. If you want to use assembly operation codes to use them, those needs to be added in the assembler.

Guffa
  • 687,336
  • 108
  • 737
  • 1,005
  • Good explanation. Does that mean that Intel and AT&T syntax is like a standard that when mapping machine code to assembly mnemonics assemblers must follow? – lychee Feb 08 '15 at 20:43
  • 1
    @BsD: No, assemblers doesn't need to follow the instruction sets at all, anyone could invent their own set if they liked, but keeping close to the defined set means that a lot of programmers already know it. One notable exception is [CIL](http://en.wikipedia.org/wiki/Common_Intermediate_Language) used in the .NET framework, an object oriented assembly language which compiles into bytecode that is not specific to any CPU. When the code is executed, it's first automaticaly converted by the JIT (just-in-time) compiler to machine code for the specific CPU where it will run. – Guffa Feb 08 '15 at 21:17
  • Two niggles: First, for "companies creating the processors specify the instruction sets", it is not clear if ARM (and others that sell *designs* not hardware) would be said to "create" processors and one can license an ISA for creating hardware without being licensed to alter the ISA; second, ISA specifiers usually specify the opcode name and even an assembly format. –  Feb 09 '15 at 12:10
  • @PaulA.Clayton I havent fully understood what have you said. You mean ARM sells only ISA's and not cpu's? second what do you mean by ISA specifiers? – lychee Feb 09 '15 at 14:32
  • @BsD ARM (currently) only sells designs for processors (and other hardware like GPU cores), which others integrate into chip designs and have manufactured, and the right to design and manufacture an ARM-compatible processor (and the right to extend the ISA). ARM does not sell hardware. By ISA specifier I mean organizations like MIPS, ARM, Tensilica, et al. that define ISAs and typically [provide processor designs](https://en.wikipedia.org/wiki/List_of_semiconductor_IP_core_vendors#General_purpose_microprocessors) as well as Intel, AMD, Oracle, et al. who define ISAs and sell hardware, i.e., –  Feb 09 '15 at 18:17
  • anyone who defines an ISA (which would also include hobbyists and academics). –  Feb 09 '15 at 18:18
  • Oops, "MIPS" should have been "Imagination Technologies". –  Feb 09 '15 at 18:44
4

Assembly language is nothing but a form of encoding the machine instructions, the same as the hex or decimal numbers, with addition of some directives for describing data fields placed in the memory. (notice, that in the Von Neumann architecture, the data and the executable code does not differs)

Of course, the encoding provided by assembler is much more convenient for a human reading, writing and understanding. It is invented especially with this goal in mind.

The assemblers are written by humans. For example, FASM has been written and is supported by Tomasz Grysztar, a brilliant programmer and mathematician from Poland.

NASM is another good assembler. It has been written by a team of programmers.

johnfound
  • 6,857
  • 4
  • 31
  • 60
  • So in order to write an assembler the developer must know machine code of every instruction,also every encodings in machine code of registers? – lychee Feb 08 '15 at 20:19
  • 3
    @BsD you make that sound hard, but it's not. Of course, they would not need to know every opcode by heart, they can look them up as needed. – harold Feb 08 '15 at 20:24
2

Is assembly implemented only in software with assembler?

Assembly is a language that is very very close to machine code. So it must be considered software.

Who updates and writes assemblers?

So everyone who has a good knowledge of the instruction set can write an assembler but also he needs to know the object file format. That means he has also to know how the os wants this format. Cpu manufacturers have the needed knowledge but also if adequate documentation is provided, everyone can write assemblers like the open source community.

Is the cpu not even aware that assembly exists?

Cpu isn't aware of how machine code was generated. It just executes machine instructions.

If let's say Intel releases a new cpu with added new instructions, what needs to be done to utilize those new instructions?

If Intel adds new instructions, then the assemblers must be updated by adding new mnemonics for these instructions.

JuniorCompressor
  • 19,631
  • 4
  • 30
  • 57