assembly Instructions

vead

Nov 27, 2011
473
Joined
Nov 27, 2011
Messages
473
Hello
I need help to understand how does instruction fetch , decode and execute
code
Code:
ORG 000
MOV A,#55H ;load immediate value 55H into reg. A
MOV R0,A  ; move the content of A into R0
END
p>
Immediate ------------   Accumulator
Accumulator------------- register

CODE Memory
74 55 F8
MOV A,#55= 01110100  01010101
MOV R0, A = F8= 11111000
Code Memory
[CODE]ADDRESS                                          Value
0000= 0000000000000000           74= 01110100
0001= 0000000000000001           55= 01010101
0002= 0000000000000010           F8= 11111000

Processor read Byte from Program memory at the address indicate by program
processor read Byte form program memory at the address 0000 indicate by program counter
Where 0000 is memory address. 74 is opcode

So the processor doesn't read any more bytes from program memory; it start to decode and execute the instruction immediately.

I don't understand how does this instruction decode and execute ?
 
Last edited:

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
vead. For one, please don't double post. https://www.electronicspoint.com/threads/assembly-instructions.271967/
Secondly, this is usually leaned at the same time, if not before learning Assembly.
Are you familiar with Machine Code? (Machine Language)

Think of it this way:
You build your own CPU from scratch... this requires a different circuit for adding, subtracting, shifting, etc...
You have 8 wires. (8-bits) that run to each and every circuit you made.
The first 4 bits dictate which circuit will activate, and the second 4-bits will contain 'data' you want to work with.
So... to move data, you select the proper 'code' to select the circuit to move data, then you provide it with a value to work with.

The difference here, is that all of these different circuits are built into a processor. Each circuit remains OFF, and will only function when the proper 'code' is put on the wire. Once the code is put on the wire, the circuit starts up, and will read the data and do something with it.
Your processor will read through the code you write like a book, and will only read one line at a time, and will do whatever the line tells it.
I don't really know how to describe this more to you, you seem to lack some basics on this, and I am uncertain of what you are after with your question.
 

vead

Nov 27, 2011
473
Joined
Nov 27, 2011
Messages
473
vead. For one, please don't double post. https://www.electronicspoint.com/threads/assembly-instructions.271967/
Secondly, this is usually leaned at the same time, if not before learning Assembly.
Are you familiar with Machine Code? (Machine Language)

Think of it this way:
You build your own CPU from scratch... this requires a different circuit for adding, subtracting, shifting, etc...
You have 8 wires. (8-bits) that run to each and every circuit you made.
The first 4 bits dictate which circuit will activate, and the second 4-bits will contain 'data' you want to work with.
So... to move data, you select the proper 'code' to select the circuit to move data, then you provide it with a value to work with.

The difference here, is that all of these different circuits are built into a processor. Each circuit remains OFF, and will only function when the proper 'code' is put on the wire. Once the code is put on the wire, the circuit starts up, and will read the data and do something with it.
Your processor will read through the code you write like a book, and will only read one line at a time, and will do whatever the line tells it.
I don't really know how to describe this more to you, you seem to lack some basics on this, and I am uncertain of what you are after with your question.
due to some technical problem, post have been generate double. I have send request to moderator to delete my one thread
look this opcode

opcode 74= 01110100 ; 8 wires tell the cpu that store data into Accumulator

In cpu , I have Accumulator , I want activate accumulator , which wire will tell that do the mov operation and which bit will tell that activated Accumulator
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
due to some technical problem, post have been generate double. I have send request to moderator to delete my one thread
look this opcode

opcode 74= 01110100 ; 8 wires tell the cpu that store data into Accumulator

In cpu , I have Accumulator , I want activate accumulator , which wire will tell that do the mov operation and which bit will tell that activated Accumulator
I cannot answer either question for you at the moment. One of the reasons being that the actual instruction will vary based on the CPU, as will the wires.
If you can get your hands on a data sheet for the particular processor you are working with, you can determine which wires will be used. You can also figure out exactly which opcode values are available.
 

vead

Nov 27, 2011
473
Joined
Nov 27, 2011
Messages
473
I cannot answer either question for you at the moment. One of the reasons being that the actual instruction will vary based on the CPU, as will the wires.
If you can get your hands on a data sheet for the particular processor you are working with, you can determine which wires will be used. You can also figure out exactly which opcode values are available.
ok I will come with complete instruction set. and then I will ask question
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
ok I will come with complete instruction set. and then I will ask question
May I ask what you are after?
Are you asking for the sake of knowing, or are you working on a project/homework?
 

vead

Nov 27, 2011
473
Joined
Nov 27, 2011
Messages
473
May I ask what you are after?
Are you asking for the sake of knowing, or are you working on a project/homework?
Look my post #1 I have written some assembly code 8051
I want to know how does these code each instruction fetch , decode and execute. I know every opcode contain every information that how it will execute.processor fetch code and put into instruction register, decode unit decode instruction and control unit execute instruction In my code there are three opcode.
I just want to know how does they fetch , decode and execute
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
vead. I'm still unsure of your purpose, and the question seems vague.

I have an interesting approach for you.
Do you play Minecraft?
Boot up 'creative mode' and build your own computer.
http://minecraft.gamepedia.com/Tutorials/Redstone_computers

This should give you any and all information you could ever possibly want for how a processor does anything.
 

vead

Nov 27, 2011
473
Joined
Nov 27, 2011
Messages
473
Think of it this way:
You build your own CPU from scratch... this requires a different circuit for adding, subtracting, shifting, etc...
You have 8 wires. (8-bits) that run to each and every circuit you made.
The first 4 bits dictate which circuit will activate, and the second 4-bits will contain 'data' you want to work with.
So... to move data, you select the proper 'code' to select the circuit to move data, then you provide it with a value to work with.

The difference here, is that all of these different circuits are built into a processor. Each circuit remains OFF, and will only function when the proper 'code' is put on the wire. Once the code is put on the wire, the circuit starts up, and will read the data and do something with it.
Your processor will read through the code you write like a book, and will only read one line at a time, and will do whatever the line tells it.
I don't really know how to describe this more to you, you seem to lack some basics on this, and I am uncertain of what you are after with your question.
according to you. assume we have 8 wires
ADD A,R0
ADD A,R1
ADD A,R2
look following image
00101 000
00101 001
00101 010

first five wire are used to activate adder circuit with accumulator and last three for register specification
00101 means Add A
000 means R0 register
001 means R1 register
010 means R2 register
 

Attachments

  • adder.jpg
    adder.jpg
    49.5 KB · Views: 121
Last edited:

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Vead, what you really need to know is that an instruction is fetched, then it is executed, then another one is fetched, then it is executed, ...

This may seem kinda intuitive, yet there are architectures out there where this relationship does not hold (for example, some processors may pre-emptively fetch several instructions and then place them in an execution pipeline). In those architectures, something which causes those instructions to be skipped over (a branch) will typically clear out the pipeline so that those extra instructions are not actually processed, however there are architectures where this does not always happen the way you think it might!

Unless you are using one of these very odd architectures (The early HP RISC architectures were an example) then you can normally ignore these details.

The one area where it impacts microcontrollers is in the area of interrupts. Again, this is typically not important, but the interrupts can be processed between fetch and execute, or between execute and the next fetch. The exact point at which they are processed can determine the latency of the interrupt, especially if the interrupt is generated in response to some action by the microcontroller itself. Again, this is typically unimportant unless you need to count clock cycles for exact timing.

In my opinion, you should concentrate on understanding the instruction set and addressing modes before you delve into the minutia of the architecture.
 

vead

Nov 27, 2011
473
Joined
Nov 27, 2011
Messages
473
Vead, what you really need to know is that an instruction is fetched, then it is executed, then another one is fetched, then it is executed, ...

This may seem kinda intuitive, yet there are architectures out there where this relationship does not hold (for example, some processors may pre-emptively fetch several instructions and then place them in an execution pipeline). In those architectures, something which causes those instructions to be skipped over (a branch) will typically clear out the pipeline so that those extra instructions are not actually processed, however there are architectures where this does not always happen the way you think it might!

Unless you are using one of these very odd architectures (The early HP RISC architectures were an example) then you can normally ignore these details.

The one area where it impacts microcontrollers is in the area of interrupts. Again, this is typically not important, but the interrupts can be processed between fetch and execute, or between execute and the next fetch. The exact point at which they are processed can determine the latency of the interrupt, especially if the interrupt is generated in response to some action by the microcontroller itself. Again, this is typically unimportant unless you need to count clock cycles for exact timing.

In my opinion, you should concentrate on understanding the instruction set and addressing modes before you delve into the minutia of the architecture.
forget all thing , I am not going to design my own, I am learning only basic. I except I don't have enough knowledge to design my own
I am learning basics
I made diagram where I have connected Adder with two data registers. I am not sure that diagram I have posted is right .If my diagram is correct then I want to add register that will store temporary data (register for immediate data )
 

Attachments

  • adder.png
    adder.png
    268.5 KB · Views: 166

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
What you have there is totally irrelevant to learning how to write code.
 

vead

Nov 27, 2011
473
Joined
Nov 27, 2011
Messages
473
What you have there is totally irrelevant to learning how to write code.
I want to make small circuit that will do some operation with registers
for example
ADDER with accumulator and register R0
AND logic with accumulator and register R0
here I am making circuit for mov operation with two registers
MOV A, R0
 

Attachments

  • movoperation.jpg
    movoperation.jpg
    70.4 KB · Views: 133

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Steve,

He is trying to design hardware to execute the 8051 instruction set. And he has wants us to teach him the basics of computer architecture, one forum post at a time.

I understand someone has tweeted "War And Peace". His quest is similar to asking us to do that.

Bob
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
Yeah... vead, can you please clarify exactly what you want?
Do you want to be able to code for it,
of do you want to understand the inner working of a processor?

I still think it's wise for you to look at minecraft redstone computers. The 'blocks' used replicate transistors so you will end up building it from nothing.
I think the only way you can learn the intricate behaviour inside a processor is to build one yourself, or have the drive to do a bunch of research yourself.
This is a potentially complicated question with many tangents, and to be able to actually cover the topic would take a structured collection of well written tutorials and resources.
 

vead

Nov 27, 2011
473
Joined
Nov 27, 2011
Messages
473
Yeah... vead, can you please clarify exactly what you want?
Do you want to be able to code for it,
of do you want to understand the inner working of a processor?

I still think it's wise for you to look at minecraft redstone computers. The 'blocks' used replicate transistors so you will end up building it from nothing.
I think the only way you can learn the intricate behaviour inside a processor is to build one yourself, or have the drive to do a bunch of research yourself.
This is a potentially complicated question with many tangents, and to be able to actually cover the topic would take a structured collection of well written tutorials and resources.
yes I want to learn how does processor make. But I am talking only basic. I am just reading basics. so I am making simple circuit to understand how dose processor make
here I made simple ALU , and other circuit made to understand how data load or store from one register to another


I don't want to use word processor because I feel very afraid I don't want to being banned from this forum.
 

Attachments

  • alu.png
    alu.png
    611 KB · Views: 137
  • dj.png
    dj.png
    537.4 KB · Views: 129
  • adder.jpg
    adder.jpg
    49.5 KB · Views: 120
  • adder.png
    adder.png
    268.5 KB · Views: 118

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
I still greatly encourage you to look at Minecraft Restone Computers.
The clock is slow, and the redstone dust will give you visual feedback of what is happening.

Look at youtube videos or get a copy of the game and build it yourself.

This will work much better than attempting to describe how the data actually moves to the working register, and then manipulated by the processor.
I can't see a reason for this not to work for you. The only draw-back is the actual circuits built in the game will not be using any standard electronics symbols. They cover building the program counter, program memory, the ALU, etc...
 

gorgon

Jun 6, 2011
603
Joined
Jun 6, 2011
Messages
603
yes I want to learn how does processor make. But I am talking only basic. I am just reading basics. so I am making simple circuit to understand how dose processor make
here I made simple ALU , and other circuit made to understand how data load or store from one register to another


I don't want to use word processor because I feel very afraid I don't want to being banned from this forum.


Inside each microprocessor/ controller there is a hardcoded statemachine that process each instruction like it is coded. This statemachine is the reason that there is a difference in the number of clock cycles for the different instructions. Each programming instruction will run its own small 'program' in what is called microcode, inside the microprocessor. This microcode is designed into the microprocessor hardware. Due to this, there is no easy way to tell you what is happening with your ALU and the registers inside the micro. Thr closest you can get is to study the programmers manual for the processor and see what the effect is for each instruction.
 
Top