Processor Registers

Thread Starter

abhimanyu143

Joined Aug 25, 2014
211
Hello

I am reading about registers from this page.http://en.wikipedia.org/wiki/Processor_register.I want to know some detail about type of registers. I understand only definition from this page
Can anybody tell me some example

Register : register is temporary storage device that is used to store binary Digit

Type of Register
Accumulator
Instruction register
Data register
Address register
Memory data register
Memory address register

Accumulator : accumulator is register that store data or result

Example :LDA ,Register Load Data from register to accumulator
Register = 0100
Accumulator =----
After loading
Accumulator=register
0100 = 0100
STA ,register Store data from register to Accumulator
Accumulator =0110
Register =-----
After storing
Register =0111

Instruction register: holding the instruction currently being executed
Instruction binary data
LD 0001
ST 0101
ADD 0110
AND 0111

Data register hold Data
A=0101
R=0001

Address register hold Address
Memory address register Hold the address of memory

What are example of Address register, memory address register , memory data register.
 

Papabravo

Joined Feb 24, 2006
21,226
A register is an array of basic devices called flip-flops or latches. When they are used to hold a number they have a most significant bit and a least significant bit. A program inside a processor is executed by a sequence of operations on registers that move data and compute arithmetic results from one or more operands.

I'm not sure what kind of examples you are looking for. Can you elaborate?
 

Thread Starter

abhimanyu143

Joined Aug 25, 2014
211
A register is an array of basic devices called flip-flops or latches. When they are used to hold a number they have a most significant bit and a least significant bit. A program inside a processor is executed by a sequence of operations on registers that move data and compute arithmetic results from one or more operands.

I'm not sure what kind of examples you are looking for. Can you elaborate?
I am not understanding what is Difference between Data register s and memory data registers . they are same or Different
So that's why I am asking some example about Data register , address register , memory data register and memory address register , to find out how they are different from each other ?
 

Veracohr

Joined Jan 3, 2011
772
It might depend on the system/processor, but you might be able to consider a "data register" to hold data currently being used and a "memory data register" to hold data recently retrieved from memory. An address register holds the location address of a piece of data in memory.

They're basically all the same, just given different names for the specific kind of numbers they hold.
 

Papabravo

Joined Feb 24, 2006
21,226
All of the different registers are implemented in the same way. The difference in the names relates to where the data comes from, for the inputs; and where the data from the outputs goes to.
 

Thread Starter

abhimanyu143

Joined Aug 25, 2014
211
Ok , like this

registers for code memory
memory Address register
Memory Data register

Instruction register
0001 hold the 4 bit ADD instruction
0101 hold the 4 bit AND instruction

Accumulator Hold data
01011 data
 

absf

Joined Dec 29, 2010
1,968
In the block diagram attached

6502 block diagram.PNG

The block diagram is the inside of 6502 MPU or microprocessor.

I believe the Address Register is the "PCL" and "PCH"
and Memory Data Register is "Data Bus Buffer"
and Memory Address Register is "ABL" and "ABH"

Allen
 

Thread Starter

abhimanyu143

Joined Aug 25, 2014
211
thanks to all for giving me important Information
I saw two link http://en.wikipedia.org/wiki/Register_file
Register file : register file is array of processor register Inside central processing unit that hold the data and address
some example :
data register
address register
Instruction register
program counter
psw register

Register bank
and another link http://www.cpu-world.com/Arch/8048.html
There are two register bank in this link. register Bank 0 register bank1. each bank has 8 bit registers

I Don't understand why the microcontroller use register bank. they can use address register, data registers. why they use register bank. what is difference between register file and register Bank
please someone solve my doubt.
 

WBahn

Joined Mar 31, 2012
30,071
In any given design, there are limits to how many registers you can directly access. If you need more registers than that, you have to change the design. One common way of doing this is to "bank" the registers somehow. For instance, let's say that you had a simple design that is 8-bits wide. This might limit you to 256 registers. But you might want more than that, so you might use a particular register, say register 12, as a bank select register and whatever value you write to that register would serve as the upper byte in a 16-bit address. Now you could have as many as 65,536 registers in your address space. But this causes problems, too. If you select a bank other than Bank 0, how can you write to the Bank Select Register (register 12) which is in Bank 0? A common approach is to have a small set of registers at the low end of the bank address range only decode the low bits of the address so that they are shared by all the banks. So you might have 16 or 32 registers that are common to all banks and the rest be unique to each bank.
 

Thread Starter

abhimanyu143

Joined Aug 25, 2014
211
From above post one thing is cleared for me that I understood what is address registers , data registers, and Instruction Register
now going to learn more things
Data memory
data memory use memory address registers and memory data register
memory address register - memory address register
If memory address register is 4 bit and memory address register is 4 bit
I think code memory should be following
Data MEMORY 16X4
Code:
Address      Data
0000           0000
0001           0000
0002           0000
0003           0000
0004           0000
0005           0000
0006           0000
0007           0000
0008           0000
0009           0000
000A           0000
000B           0000
000C           0000
000D           0000
000E           0000
000F           0000
I am not sure. Is it right example ?
 
Last edited:

Thread Starter

abhimanyu143

Joined Aug 25, 2014
211
and also look this Program Memory
program memory store Instruction , data and Address
I think I have to use these three registers in Program Memory
4 bit address , 4 bit instruction , 4 bit data
Code:
Address   Instruction          Data
0000          xxxx             xxxx
0001          LD                A
0002         LD                R1
0003         ADD               R2
0004         SUB                A
0005         ADD               R3
0006         AND               R1
0007         LD                R4
0008        ST                 R5
0009        NOT                R6
000A       X-OR                R7
000B       LD                  R8
000C       ST                  R9
000D       ADD                 R10
000E        LD                 R11
000F        ST                   A
 

absf

Joined Dec 29, 2010
1,968
From above post one thing is cleared for me that I understood what is address registers , data registers, and Instruction Register
now going to learn more things
Data memory
data memory use memory address registers and memory data register
memory address register - memory address register
If memory address register is 4 bit and memory address register is 4 bit
I think code memory should be following
Data MEMORY 16X4
Code:
Address      Data
0000           0000
0001           0000
0002           0000
0003           0000
0004           0000
0005           0000
0006           0000
0007           0000
0008           0000
0009           0000
000A           0000
000B           0000
000C           0000
000D           0000
000E           0000
000F           0000
I am not sure. Is it right example ?
Yes, that's right .... But I dont think anyone is going to design a mpu with 4 bit address.

Allen
 

absf

Joined Dec 29, 2010
1,968
Code:
Address   Instruction          Data
0000          xxxx             xxxx
0001          LD                A
0002         LD                R1
0003         ADD               R2
0004         SUB                A
0005         ADD               R3
0006         AND               R1
0007         LD                R4
0008        ST                 R5
0009        NOT                R6
000A       X-OR                R7
000B       LD                  R8
000C       ST                  R9
000D       ADD                 R10
000E        LD                 R11
000F        ST                   A
In your code, 4 bit instruction + 4 bit data combined is normally called Op-code. After the op-code there is usually an operand which is also 8 bit in width.

For example, the op-code LD A mean Load Accumulator. But what do you want to load Acc with? The operand can be an immediate data (numeric constant) or a memory Address or even another register Rn. Same case with LD R4 or AND R1. For ST instructions, You have to store the Register to somewhere like a Memory Address. Otherwise the instruction would not make sense.

Allen
 
Last edited:

Thread Starter

abhimanyu143

Joined Aug 25, 2014
211
In your code, 4 bit instruction + 4 bit data combined is normally called Op-code. After the op-code there is usually an operand which is also 8 bit in width.

For example, the op-code LD A mean Load Accumulator. But what do you want to load Acc with? The operand can be an immediate data (numeric constant) or a memory Address or even another register Rn. Same case with LD R4 or AND R1. For ST instructions, You have to store the Register to somewhere like a Memory Address. Otherwise the instruction would not make sense.

Allen
you mean like this
4bit address+ 4 bit instruction + 4 bit destination + 4 bit source (all is 4 bit so I choose 4 bit only for example)

Code:
Address         Instruction     Destination     source
0000                xxxx             xxxx                      xxxx
0001                LD                    A                          R1
0002               LD                    R1                        A
0003               ADD                 R2                        A  
0004               SUB                  A                         R4
0005               ADD                R3                        R5
0006             AND                  R1                         R2
0007            LD                      R4                         R3
0008              ST                     R5                        A  
0009              NOT                   R6                       R3
000A           X-OR                   R7                         R2
000B            LD                       R8                         A
000C          ST                       R9v                        A
000D           ADD                  R10                         R2
000E            LD                       R11                        A
000F           ST                          A                          R3
 
Last edited:

Thread Starter

abhimanyu143

Joined Aug 25, 2014
211
Yes, that's right .... But I dont think anyone is going to design a mpu with 4 bit address.

Allen
I am just learning, I start to learn with small topics because small thing is always help me lots to understand big things , so I did with small example And I want to continue with this example to learn another topics
can we do ?
 
Last edited:

Thread Starter

abhimanyu143

Joined Aug 25, 2014
211
A Von Neumann Architecture
Instruction and data should be same
example:
read enable
Data 4 bit
instruction 4 bit

Address instruction operand
8 bit 4 bit 4 bit


Harvard Architecture
Instruction and Data may be different
Read Enable
write Enable
Data bus 4 bit
Address bus 2 bit

Address instruction operand
8 bit 4 bit 2 bit


How does cpu read program memory

please someone can point out me with the example
 
Last edited:

WBahn

Joined Mar 31, 2012
30,071

absf

Joined Dec 29, 2010
1,968
Code:
Address     Instruction     Destination     source
0000        xxxx            xxxx            xxxx
0001        LD              A               R1
0002        LD              R1              A
0003        ADD             R2              A  
0004        SUB             A               R4
0005        ADD             R3              R5
0006        AND             R1              R2
0007        LD              R4              R3
0008        ST              R5              A  
0009        NOT             R6              R3
000A        X-OR            R7              R2
000B        LD              R8              A
000C        ST              R9v             A
000D        ADD             R10             R2
000E        LD              R11             A
000F        ST              A               R3
No, I prefer something like this.....

Code:
Address      Instruction     operand     Comments
==========================================================================================
0000         xxxxxxxx        xxxxxxxx
0001         LDA             #56         ;load A with numeric decimal 56 constant
0003         LD              R1, A       ;load R1 with contents of A
0005         ADD             A, R2       ;Add A with R2 and put result in A  
0007         SUB             A, R4       ;Subtract A with R4 and put result in A
0009         AND             R2, R5      ;Logical And R2 with R5 and place result in A 
000B         LD              R4, R3      ;load R4 with contents of R3
000D         ST              R5 , A      ;this instruction can be replaced with LD  
000F         NOT             R6, R3      ;this instruction is useless
--------------You run out of program memory here-------------------
0010         XOR             R7, R2      ;where does the result go to?
0012         ST              R9, $0300   ;store contents of R9 into memory address 0300
Allen
 
Last edited:

absf

Joined Dec 29, 2010
1,968
I think that the Nand2Tetris project might be something that you would find very informative. I give an overview of it in one of my blogs, so take a look:

http://forum.allaboutcircuits.com/blog/nand2tetris-overview.590/
Yes I agreed with WBahn....

We have given the same advice to "vead" and he didn't bother at all. Otherwise he wouldn't be asking those questions he asked in his posts about mcu design.

BTW are you perhaps a friend of vead or may be even classmate? He was persuing the same thing as you're asking for the past few months. If you read all the post by member "vead", you will see that he has asked similar questions as to yours. One of his recent posts is here

http://forum.allaboutcircuits.com/threads/8051-instruction-set.103714/

Allen
 
Last edited:

Thread Starter

abhimanyu143

Joined Aug 25, 2014
211
Yes I agreed with WBahn....

We have given the same advice to "vead" and he didn't bother at all. Otherwise he wouldn't be asking those questions he asked in his posts about mcu design.

BTW are you perhaps a friend of vead or may be even classmate? He was persuing the same thing as you're asking for the past few months. If you read all the post by member "vead", you will see that he has asked similar questions to yours. One of his recent post is here

http://forum.allaboutcircuits.com/threads/8051-instruction-set.103714/

Allen
I looked that post. I think he is doing course on embedded system designing. he asked about 8051 microcontroller Design. There is degree course in India. In which we read about embedded micro controller. generally we study about what is processor ROM memory , Ram memory , timer , interrupt i/o device and c programming so may be many student ask about microcontroller I don't think that I can design processor without learning basics. Designing processor is also good but very tough idea
for my semester exam I have to learn about 8051 , Pic and ARM controller so that's why I am asking
 
Top