# Instruction Encoding [assembly]

1. Nov 24, 2012

### twoski

1. The problem statement, all variables and given/known data

A 1-address computer is one whose instruction can contain at most one operand address. MARIE is an example of such a computer. Typically each instruction is stored as a single word in the memory. Assume the following machine details.

(i) A word contains n bits, and k bits (k < n) are used to encode each opcode. The remaining bits are used to specify memory address(es).
(ii) There are 100 distinct opcodes in the ISA.
(iii) The largest program requires 128M words of memory to run.

(a) What is the minimum value of k required? What is the minimum value of n required? Keeping minimum value of k, what is the maximum number of opcodes that can be used?

(b) If the size of each word must be an integer number of bytes, what is the minimum value of n required? What is largest memory that can be used in this computer then?

3. The attempt at a solution

A) The minimum value for k is 7 since the ISA has 100 distinct opcodes. The minimum value for n is 9 since the lowest possible size for instructions is 1 bit (our professor's slides say that possible sizes for instructions are 8,16,32 or 64 and i don't think having 1 bit for the address makes any sense). If k = 7, then the maximum amount of opcodes is 128.

B) I don't get this... It's saying that i can only have 8/16/32/etc bits which i have already assumed. Did i miss something?

2. Nov 24, 2012

### rcgldr

Does this mean 128,000 or 128,000,000 words or 128*1024 or 128*1024*1024 words?

This part of a is not restricting the word size to be a multiple of 8 bits.

3. Nov 24, 2012

### twoski

The assignment just says 128M, i was hoping someone here would be able to hazard a guess as to what that means. It's ambiguous so maybe i'll email the professor about it.

If the minimum bits for k is 7 (since 128 is the closest to 100 without being lower than 100) then the minimum size for n would be 1 which makes the minimum amount of total bits 8. Although i don't know how smart this would be since having 1 bit for addresses would be absurd - is there a specific limit on how small addresses can be?

4. Nov 24, 2012

### rcgldr

The minimum size for n is the the number of bits required to address 128M words, except I don't know that M stands for in this case, but mostly likely it's 1024*1024 = 1048576 (asssuming that small m would mean 1,000,000).

Last edited: Nov 24, 2012
5. Nov 27, 2012

### twoski

Well in similar questions he uses "128 Mbits" so maybe it was just a typo and he meant 128 Mbits instead of 128M words?

So if the total words is size m, the minimum size would be n where n^2 = m, right?

6. Nov 27, 2012

### rcgldr

Just assume he mean 128M words.

Yes, if total bits size is m, then n^2 = m / 8.