Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the minimum instruction set required for any Assembly language to be considered useful?

Tags:

I am studying Assembly programming in general, so I've decided to try and implement a "virtual microprocessor" in software, which has registers, flags and RAM to work with, implemented with variables and arrays. But since I want to simulate only the most basic behavior of any microprocessor, I want to create an assembly language that has only the essential instructions, only those instructions without which it couldn't be useful. I mean, there are assembly languages that can do multiplication and swapping register values, etc, but these operations are not basic because you can implement them using simpler instructions. I don't want to implement instructions like those.

I can imagine a couple of instructions which (I believe) must always be present in any assembly language, such as MOV to move bytes around and JP to send the instruction pointer to another address.

Could you suggest a set of the most basic and essential assembly instructions? Thanks!

like image 759
Fernando Aires Castello Avatar asked Feb 24 '12 22:02

Fernando Aires Castello


People also ask

How many minimum operand are required for an instruction to be executed in assembly language programming?

Theoretically, a single instruction computer is possible. However on real hardware, you would need a minimum of 4.

What is the smallest instruction set?

A simple instruction set of only 8 instructions used for teaching is known as the MU0 instruction set.

How many machine code instructions do you need for one assembly language?

Assembly Language Statements Each instruction consists of an operation code (opcode). Each executable instruction generates one machine language instruction.


1 Answers

Control structures comprise the basic feature without which there is no language. This means that your language must provide arithmetic operations on two variables; and then allow a program to change the program counter -- that is, to branch -- based on the result of an operation. Very often, the crucial operation is SUB, for subtract one operand from another. And the conditions on which you would allow a branch are:

  1. result is zero;
  2. result is greater than zero;
  3. result is less than zero.
  4. no condition, i.e., branch unconditional

You also need instructions to move data around: LOAD and STORE, say.

These three conditions and their corresponding branches (or skips, which is another way to do it) are necessary for any program. Not only that, but just these three simple operations plus data-moving instructions, are sufficient to do anything in a program except I/O. If you wanted to, and given a cooperating memory organization, you could rewrite Linux using just LOAD, STORE, ADD, SUB, and the three conditional branches.

The PDP-8 was a much more powerful machine than this: it had a rich set of eight instructions, including I/O.

HTH

like image 116
Pete Wilson Avatar answered Oct 11 '22 11:10

Pete Wilson