Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Another mock exam Q - Convert machine code into instructions

Status
Not open for further replies.

Spadez

New Member
Hi,

Another question for you, sorry! :)

My question goes like this:
Convert the following machine code into an instruction: 0064h

This is my working out so far. I assume we want this in binary since figure 15.2 has the instructions in binary. I have this so far.

0064H
------
4 x 1 = .4
6 x 16 = .96
Total = .100

.100 in Binary is 0110 0100

What I dont understand is how to convert this binary into an instruction. There are 14 bits, and I have only 8. Bits 13 to 8 is the opcode apparently.

The way I see it is it has to be:
Bit Test f, Skip if Clear

This has the code:
01 10bb bfff ffff

Is this right? Im really not sure about this, and im guessing its probably wrong.

James
 

Attachments

  • Capture3.GIF
    Capture3.GIF
    54.9 KB · Views: 285
Last edited:
The instruction that assembles to 0x0064 is CLRWDT.

Mike.
 
Last edited:
Just to run this past again.

"Convert the following machine code into instructions"

b) 000h = 0000 0000 = NOP

c) 1283h = 0001 0010 1000 0011
I beleive this is a IORWF which has the following value:

00 0100 DFFF FFFF

This means D = 1 and F= 10 1000 0011


What does this actually mean?
 
The binary code about is 16, but the Opcode is actually 14. Do I strip off the two MSB's? If that is the case then I think the answer will be BCF

01 0010 1000 0011

B = 101 = 5
F = 000 0011 = 3

I dont understand what these B and F values mean though.
 
"Convert the following machine code into instructions"

b) 000h = 0000 0000 = NOP
Correct

c) 1283h = 01 0010 1000 0011
I beleive this is a IORWF which has the following value:

00 0100 DFFF FFFF
00 0010 1000 0011 is IORWF STATUS, d

01 0010 1000 0011 is BCF STATUS, 05 where bit 05 is the RP0 bit.

This means D = 1 and F= 10 1000 0011
Make your mind up which opcode you are examining 0283 or 1283!

Wrong for the OP code first stated 1283h, there is no d bit.

And wrong for the second opcode 0283
D=1 and F= 000 0011 (3 in decimal)

What does this actually mean?
For all PIC instructions, when d=0 the result of the instruction is placed in the W register, and when d=1 the result is put into the register f.

To find which register is "3" look in the register file summary for your PIC, on the sheet I have beside me (16C84, no heckling from the gallery now!), "03" is the STATUS register.
(Just looked at the sheet for a 16F887 and 03 is the STATUS reg there, again, probably the same on all PICs).

JimB

Having re-hashed this reply, I think I have given a reasonable answer to a confused question.
 
Last edited:
Your HEX to binary need to be worked on because it's really simple:

0064H

is 0000 0000 1100 0100

Note that 0000 = 0, 0000 = 0, 1100 = 6h, and 0100 = 4h

So, just expand in groups of 4. It works in reverse too from binary to hex (separate into groups of 4).
 
Thank you both for your reply. I understand now that my conversion was a bit ass about face, its a lot easier and quicker to do now.

Im sorry Jim, I was switching between the two accidently. It should be 1283h. So, with respect to that we have it like this:

01 0010 1000 0011
-- -- BB BFFF FFFF

So we have BBB as 101 (.5), and F as 000 0011 (.3)

Third 03H file register is Status and bit 5 of the status register is RP0. I understand im repeating what you said but it helps me to go through it. Thank you for helping me to clear it up.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top