Fetching and executing instruction?

In summary: I'm wrongIn summary, the instruction fetch process includes reading the instruction from memory, decoding it, and executing it.
  • #1
vead
92
0
Instruction should be fetch , decode and execute.
''Instruction fetch from memory''
I have read this statement many times but don't know which memory ROM or RAM memory ?
 
Physics news on Phys.org
  • #2
vead said:
Instruction should be fetch , decode and execute.
''Instruction fetch from memory''
I have read this statement many times but don't know which memory ROM or RAM memory ?

The actual program instruction could be stored on ROM, RAM, FLASH or ten other types of internal or external memory. Depending on the processor and system architecture the instruction might have moved thru several times before actual CPU execution in the processor SRAM cache or internal SRAM memory registers.

Take a look at a typical microcode processor instruction cycle: https://www.cs.umd.edu/class/fall2001/cmsc411/projects/DLX/proj.html
 
  • #3
Hello everyone I want understand how does microcontroller work so I have done some homework

Instruction should be fetch, decode and execute
assembly code
Mov A, #2
Mov R1, #3
Add A, R1

lets say program convert into hexa code

8000 0101 1st Instruction
8001 1o01 2nd instruction
8002 0101 3rd Instruction

this hex code stored into rom memory
address data
8000 0101
8001 1o01
8002 0101

location of data stored into RAM
location
8000
8001
8002

ok now we want to fetch 1st instruction

we now about accumulator register , decoder
Instruction 1st is 8000 0101 fetch from rom memory, decoder take the information and it will store the value in A register, processor send the request in Ram memory and it look location 8000 for data 0101

program counter execute instruction one by one
now 2nd instruction 8001 1001 fetch from rom memory decoder take instruction and it will store value into register R1 processor send request in ram memory and ram memory look location 8001 for data 1001

3rd instruction fetch from rom memory decoder decode instruction and tell the alu for addition
alu do addition and result will save in ram memory

In my above paragraph I think there are many wrong statement so please check out me and correct me
 

FAQ: Fetching and executing instruction?

What is the difference between fetching and executing an instruction?

Fetching refers to the process of obtaining the next instruction from memory, while executing refers to the actual implementation of that instruction by the computer's processor.

How does a computer know which instruction to fetch and execute next?

Computers use a program counter, which is a special register that keeps track of the memory address of the next instruction to be fetched and executed.

What happens if an instruction is not found in memory during the fetch stage?

If an instruction is not found in memory, the computer will encounter an error and may halt or crash. This can occur if there is a programming error or if the instruction is located in a different part of memory.

Can multiple instructions be fetched and executed at the same time?

Yes, modern computers have multiple cores and can therefore fetch and execute multiple instructions simultaneously, improving overall performance.

How does the computer know when to stop fetching and executing instructions?

The computer will continue to fetch and execute instructions until it reaches an instruction that indicates a stop or halt command. This could be a specific instruction or a condition set by the programmer.

Similar threads

Replies
3
Views
2K
Replies
8
Views
2K
Replies
1
Views
3K
Replies
11
Views
2K
Replies
7
Views
1K
Back
Top