JDS
JDS

Reputation: 16978

What is the minimum assembly instructions needed?

If you were to build a processor that would be used to run any arbitrary program, what is the minimum set of instructions (ISA) you could get away with?

I was thinking:

What do you think?

Upvotes: 1

Views: 796

Answers (3)

Nathan Binkert
Nathan Binkert

Reputation: 9124

Technically, you only need One Instruction. It needs to do math and conditional branching. e.g. subtract and branch if negative.

Upvotes: 5

Vinayak Garg
Vinayak Garg

Reputation: 6606

While programming in 8085 I felt there were several ways to do the same thing. So, if this is the case, you know your instruction set is not minimal.

I would propose following instructions- Add, complement, logical AND, OR, and load store. Conditional and unconditional jump.

Most of the other instructions can be performed with above instructions.


EDIT: Just to list the assembly instructions (based on 8085):

I will consider a model, wherein there are 3 registers. With operations like A = B + C

ADD B, C (A = B + C)
CMA (A = A')
OR B, C (A = B OR C) JMP xxxx (set PC to xxxx)
LDA xxxx (load A with contents at xxxx address)
STA xxxx
JZ xxxx (Jump if zero flag is set)

NOTE: I realise additional instruction to copy data between registers is quite useful. But can be omitted. Please present a case where one cannot do without it.

Upvotes: 1

paxdiablo
paxdiablo

Reputation: 881113

You don't need any instruction that can be built from other instructions.

So, no need for mul or div since you can do that with repeated addition or subtraction, and no need for sub if you have neg (negate) and numbers will wrap, such as with two's complement.

And certainly you can get away with two branch instruction, one for equal, one for less than - all the others can be built from combinations of those.

Because you have no I/O instructions, you'll probably need to use memory-mapped I/O where communications with other devices is via memory accesses.

And, without native push and pop, you'll probably need to implement your own stack with a dedicated register (and memory location since you don't appear to have a register-to-register move).

Now that won't be a very nice architecture but it should function. As the Matrix Architect stated, "there are levels of survival we are prepared to accept".


As an aside, have a look into the RCA1802 CPU (from days of yore). It had no dedicated program counter or stack pointer, instead implementing all that in software (see here for details).

Upvotes: 1

Related Questions