COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Expanding opcode question

• Email
• Follow

```Aloha everyone,
I have a quandry; I'm attempting to understand expanding opcodes, but
Tannenbaum doesn't adequately explain it, at least for my understanding.
When it is presented in the text book, it has 2^k operations and 2^n
operands.  That much I understand.  What I can't figure out how to do is to

"determine if it is possible to design an expanding opcode for the
following to be encoded in a x-bit instruction:
xxx instructions with yyy registers
xxxx instructions with yy registers
xx instructions with yyyy registers
a register is xxx bits"
(using whatever numbers you wish for the x's and y's)

Can anyone help me out with this?  I asked my instructor, but he kind of
just glossed over it and I never got an adequate explanation.

Thanks in advance for any assistance,

William Jones
```
 0
Reply whjones (11) 12/9/2004 7:21:10 PM

See related articles to this posting

```
William Jones wrote:
> Aloha everyone,
>   I have a quandry; I'm attempting to understand expanding opcodes, but
> Tannenbaum doesn't adequately explain it, at least for my understanding.
>  When it is presented in the text book, it has 2^k operations and 2^n
> operands.  That much I understand.  What I can't figure out how to do is to
>
> "determine if it is possible to design an expanding opcode for the
> following to be encoded in a x-bit instruction:
> xxx instructions with yyy registers
> xxxx instructions with yy registers
> xx instructions with yyyy registers
> a register is xxx bits"
> (using whatever numbers you wish for the x's and y's)
>
> Can anyone help me out with this?  I asked my instructor, but he kind of
> just glossed over it and I never got an adequate explanation.
>
> Thanks in advance for any assistance,
>
> William Jones

A specific example might illustrate.

The Z80 has a load instruction that can transfer data from any of 8
sources to any of 8 destinations.  The sources and destinations can each
be 8-bit registers a,b,c,d,e,h,l or the byte held at the address in
16-bit register hl (it can't do ld (hl),(hl) though; that would be 0x76
which is HALT).  The load instruction is 01 sss ddd, and sss and ddd
represent b,c,d,e,h,l,(hl),a as 0-7.  So for instance ld a,(hl) is 0x7e
which is 01 111 110, and the general form is 01 ddd sss (d=destination,
s=source).

In effect this is a two bit opcode.

It can also load a single byte from the program into a register, for
which the opcode is 00 rrr 110, and the complete instruction is two bytes.

In effect this is a five bit opcode.

You can also add to the 16 bit register hl the contents of other 16 bit
registers bc, de, hl, sp.  The opcode for that is 00 rr 1001.

In effect this is a six bit opcode.

I don't remember using the term "expanding opcodes" when I did a lot of
Z80 programming, so it could be terminology used either academically or
in some other processor.

A quick google revealed the following:

Design an expanding opcode (i.e., give the opcodes) to allow all the
following to be encoded in a 36 bit instruction:

* 7 instructions with two 15-bit addresses and one 3-bit register
number
* 512 instructions with one 15-bit address and one 3-bit register
number
* 64 instructions with no address or registers

Taking the first, we could represent the first, using i for the 7
instructions, a,b for the addresses and r for the registers:
iiia aaaa aaaa aaaa aabb bbbb bbbb bbbb brrr

At least one of the 8 values for iii cannot be used in this form
otherwise no other operations are possible.  This is the case, so the
rest of the operands can be encoded iff they can be fully expressed in
33 bits.

The same page asks: Is it possible to design an expanding opcode to
allow the following to be encoded in a 12-bit instruction? A register is
3 bits.

* 4 instructions with 3 registers
* 255 instructions with one register
* 16 instructions with zero registers

Using i for instruction and p/q/r for registers we can see the answer to
this is no.

Four instructions with three registers requires two bits for the opcodes
and nine for the registers, this leaves one bit spare:

0iip ppqq qrrr

All combinations of ii are used, so we cannot use 0xxxxxxxxxxx for any
other instruction.

We can represent 255 instructions on 1 register as follows:

1iii iiii ippp

If all combinations of iiiiiiii are used, then no further instructions
are possible.  However, one combination is free as there are only 255
instructions of this form, so let's say 0000 0000 is unused; this leaves
the following form for the remaining 16 instructions:

1000 0000 0iii

16 instructions cannot be encoded in only 3 bits.

However, this assumes there are 8 registers.  If there are only 7
possibilities for just one of p,q,r, then we can fit in the extra
instructions; if for example we decide not to allow r=111, then we have
the following available for another 256 instructions:

0xxx xxxx x111

Dave.
```
 0

1 Replies
257 Views

Similar Articles

12/11/2013 12:14:42 AM
page loaded in 4886 ms. (0)

Similar Artilces:

Re: I feel stupid... "Invalid combination of opcode and operand", was, now is FORTH question
"Jean-Fran�ois Michaud" <spamtrap@crayne.org> wrote in message news:1155863113.110086.228150@b28g2000cwb.googlegroups.com... > And if every you are interrested in exploring Forth further, this will > get you started on writing your OS bug free more quickly than you can > imagine. This is the core of the indirect threaded address interpreter > (NEXT, DOCOLON and EXIT). > Many years ago I remember learning about NEXT, DOCOLON, and EXIT. But today, every time I look for stuff on FORTH. The material indicates that there is an: 1) inner or address interpreter that...

Re: I feel stupid... "Invalid combination of opcode and operand", was, now is FORTH question #3 3045
"Jean-Fran�ois Michaud" <spamtrap@crayne.org> wrote in message news:1156548815.222715.206890@i3g2000cwc.googlegroups.com... > > Sorry can't help you with most of this stuff, but my instruction for > jumping to pmode in AT&T is this (assuming that the idt and gdt are set > up correctly, that the CR bit is set and the A20 line is also set): > I appreciate that, but I'm not implementing FORTH at the moment. Although, I do have a situation in mind where I'd like to use something very similar to FORTH. Currently, I'm in the middle of writing an...

Re: I feel stupid... "Invalid combination of opcode and operand", was, now is FORTH question #2 3570
"Jean-Fran�ois Michaud" <spamtrap@crayne.org> wrote in message news:1156126735.665747.98570@p79g2000cwp.googlegroups.com... > <snip> If QUIT is the first high-level FORTH word that I want to be executed, what is the preferred method to initialize and start the interpreter for executing QUIT from my OS-specific startup code? 1) NEXT called with with address of QUIT-4 in I 2) EXIT_ASM called with address of QUIT on return stack 3) DOCOLON_ASM called with ? ... 4) other... Thanks, I appreciate your help, Rod Pemberton Rod Pemberton wrote: > "Jean-Fran�ois ...

Question
I have a history that I have written in MS Word. It is composed of text and images. Is Pagemaker the best program to use for setting up the pages images etc and if so how do I import a MS document into Pagemaker? Thanks folks, I know the questions are probably rather dumb but...... ;-) Wolf wrote: > I have a history that I have written in MS Word. > It is composed of text and images. > Is Pagemaker the best program to use for setting up the pages images etc and > if so how do I import a MS document into Pagemaker? > > Thanks folks, I know the questions are probably...

Question
Can anyone define the difference between ITS vs. simulation? Anne L. Michaels almichaels@dynasims.com "simarts" <almichaels@crashzoom.com> wrote in news:1125937604.488797.222670@g14g2000cwa.googlegroups.com: > Can anyone define the difference between ITS vs. simulation? Probably, if you'd care to say what "ITS" means. All the best, John. On Mon, 05 Sep 2005 15:06:43 -0400, "simarts" <almichaels@crashzoom.com> wrote: >Can anyone define the difference between ITS vs. simulation? What is ITS?... A.L. A.L. <alewando@alamakota.co...

Newbie question...simple rule question...
Dear All, I am trying to understand the best way to write a rule which checks on all the elements. ------------- people(a). people(c). ok(b). ok(a). everybodyok_works :- findall(X,ok(X),List),maplist(people,List). everybodyok_bad :- people(X),ok(X). ------------- What am I missing? Is there a better way to write rule which says: "Everybody is ok if for all people we know has said they are OK." ? Thanks in Advance, Mans On 2005-08-11, mans <mshapshak@gmail.com> wrote: > Dear All, > > I am trying to understand the best way to write a rule which checks on > a...

Question?
Do you know of anything that I could get Jeri for her Birthday? I need to know ASAP! Mother would like to know of something too! William William Cunningham wrote: > Do you know of anything that I could get Jeri for her Birthday? I need to > know ASAP! > Mother would like to know of something too! Well, if you don't like Jeri, you should buy her Paint Shop Pro 8 or 9. However, if you like her, a better alternative would be Adobe Photoshop Elements! :-) Uni > > William > > Of couse, you could also buy her Uni's book of wit and wisdom. Small but bea...

questions
1.which is better for processor architecture design and why? external RAM or internal RAM? 2.which is better for processor architecture design and why? external ROM or internal ROM? 3.what is the advantages and disadvantages of simple processor with pipelining and without pipelining? > > 3.what is the advantages and disadvantages of simple processor with > pipelining and without pipelining? one advantage: Because of partitioning the logic task into several stages the timing of your circuit can be improved. one disadvantage : Latency is introduced by the use of the...

i have a question
i need to wipe out my hard drive and was wondering if i will lose all of my music on my ipod or does the ipod back it up or if i will lose all of the music is there anything i can do about it "andy bond" <abond4life@yahoo.com> writes: >i need to wipe out my hard drive and was wondering if i will lose all >of my music on my ipod or does the ipod back it up or if i will lose >all of the music is there anything i can do about it There are tools that will let you upload your music from your iPod to the Mac (or you should be able to copy it via the filesystem). One too...

MS Perl question -- how to use hacked script to work correctly(was Question on loops and return values or sumpin)
First off, thanks to all who replied to my original post, I will go back and reply to each of you .. thank you for your time. And to everyone else now here, thank you for your time. I have altered a couple scripts to work in IndigoPerl and Win32::Resources to accomplish a simple task - read in a list of servers from a text file, query them for their drives and space on the drives, and put all the information on space out to a second text file, space delimited. My questions are before the code: The important question is this: How to get an array of drive letters in use in a foreach loop, and a...

Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question
This is the most important question of your life. The question is: Do you floss? It is not a question of how well you brush, nor if you use mouthwash, but do you floss? Are you sure you will keep all the teeth you still have? The reason some people don't know for sure if they are maintaining a preventitive oral dentifrice is because they just don't know what those words mean. The good news is that you can know for sure whether you will keep all of your teeth. Dental textbooks describe full-toothed-ness as a beautiful place with no death, sorrow, sickness or pain. Dentitists tell...

Newbie question.
Newbie to Linux that is. Please have mercy on a person about to move from Windows VC++/Borland CBuilder to Linux and hold the flames. What is the difference between g++ and gcc ?? My new books are split between the two. For a while I thought there was no difference since "man g++" and "man gcc" seem to bring up the same page. But, just playing around with a very (VERY) simple main.cpp like this... #include <iostream> using namespace std; int main() { cout << "Test\n"; return 0; } shows that g++ compiles it just fine and gcc chokes on it. So...

question #3
hey, adding the lxUseCell on the schematic did it! now the connectivity is fine on the layout- routing will happen soon. one question though: about pads W30 and W29. on the schematic they are WVVAD0, on the layout they are WC3I40D - i checked the latest pin list and the layout is wrong. i'm changing them to WVVAD0 but I wanted to let you know so I do not carry the whole responsibility :) see you st�phane sorry it's me again sending messages to the wrong place I'll take a bit of rest st�phane S. Badel wrote: > hey, > adding the lxUseCell on the schematic did it! > now th...

svg question
Here is a trivial example using svg (from Erik Ray's book) <?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd"> <svg xmlns="http://www.w3.org/2000/svg" width="500" height="500"> <desc>Three shapes</desc> <rect fill="yellow" x="5" y="10" width="3cm" height="3cm"/> <circle fill="orange" cx="100" cy="150" r=...

Sockets question
Hi, One of the exercises in front of me is: "Write a server in perl that will send the client a sleepy string of "ZZZZZZZZZ" whenever it connects using port 54321 from the same host using a socket in the UNIX domain." Can someone possibly re-phrase the question? I have no idea about sockets - just found a chapter on it in Prog. Perl but have not read it yet :(. Any links out there I can get ideas/learn from? Thanks in advance. John wrote: > > One of the exercises in front of me is: > "Write a server in perl that will send the client a sleepy string of &...