Transfer data from memory to register / register to memory?

In summary: Opcode instruction mode example000000 nop 0 address ------000001 Load 1 number
  • #1
vead
92
0
hello
I need some help. I created one example to understand some basic
component
ram memory
A accumulator 4bit
R1 resistor 4 bit ( R1 is temporary data storage register )
  • Register memory address bus - 2 bits (RA0,1);
  • Register memory data bus - 4 bits (RD0~3);
  • Register memory read enable;
  • Register memory write enable.
Load the data directly with register R1
mov R1 # data

stored the content R1 register into register memory
Q1 how to write data (stored in R1) to register memory ?

load the data from memory register and store into A accumulator
Q2 how to read the content of R1 and stored into A register ?
 
Technology news on Phys.org
  • #2
vead said:
hello
I need some help. I created one example to understand some basic
component
ram memory
A accumulator 4bit
R1 resistor 4 bit ( R1 is temporary data storage register )
  • Register memory address bus - 2 bits (RA0,1);
  • Register memory data bus - 4 bits (RD0~3);
  • Register memory read enable;
  • Register memory write enable.
Load the data directly with register R1
mov R1 # data

stored the content R1 register into register memory
Q1 how to write data (stored in R1) to register memory ?
A register already is memory, so there's no difference between writing directly to, say, register R1 and writing to register memory.
vead said:
load the data from memory register and store into A accumulator
Q2 how to read the content of R1 and stored into A register ?
Since you are designing the instruction set for this hypothetical microprocessor, you should already have an instruction to do this. Something like mov A, R1. That will read the value in R1 and write it to the accumulator (A).
 
  • Like
Likes vead
  • #3
Mark44 said:
A register already is memory, so there's no difference between writing directly to, say, register R1 and writing to register memory.

Since you are designing the instruction set for this hypothetical microprocessor, you should already have an instruction to do this. Something like mov A, R1. That will read the value in R1 and write it to the accumulator (A).

instruction set for this hypothetical microprocessor

suppose we have 8 bit instruction

first 4 bit for opcode and last 4 bit for register specification I have following component component
ram memory
A accumulator 4bit
R1 resistor 4 bit ( R1 is temporary data storage register )

4 bit opcode +2 bit source register +2 bit destination register + 2 bit data

MOV A #data
mov R1 # data
how does A register or R1 know that Its a source register or destination register ?
 
  • #4
vead said:
instruction set for this hypothetical microprocessor

suppose we have 8 bit instruction

first 4 bit for opcode and last 4 bit for register specificationI have following component component
ram memory
A accumulator 4bit
R1 resistor 4 bit ( R1 is temporary data storage register )

4 bit opcode +2 bit source register +2 bit destination register + 2 bit data

MOV A #data
mov R1 # data
how does A register or R1 know that Its a source register or destination register ?
A register doesn't "know" anything. It's the mov instruction that determines which register is read from (the source) and which register is written to (the destination).
 
  • #5
Mark44 said:
A register doesn't "know" anything. It's the mov instruction that determines which register is read from (the source) and which register is written to (the destination).

look at my another effort

Instruction set
  • opcode - instruction name
  • operand - data or address
6 bit opcode +mode +5 bit source register + 6 bit for destination register
Mode
0 address (without #)
1 number (with #)

Code:
Opcode         instruction       mode                           example
000000          nop                  0 address                           ------
000001          Load                1 number                       Ld A # 12
000010          Load                0 address                       Ld 12
000100          Add                  0 address                       Add 12
001000          Add                  1 number                        Add A # 12
010000          Sub                  0 address                       Sub 12
100000          Sub                  1 number                        Sub A # 12
111111          Store               0 address                         ST 12

I wrote few instruction just for example .I have 256 instruction

Assembly code
loads the number 12 into the accumulator
Code:
Ld A # 12

Bianry code

000001 1 00000 001100

Assembly code
Code:
Add # 12
Add the number 12 into the accumulator

binary code

001000 1 00000 001100
stores the result into memory location 12
Code:
ST 12
Memory
address number
11 10
12 24
13 05
saves the accumulator result (24) to the memory address 12
Bianry code

001000 0 00000 001100

Assembly code

Ld A # 12
Add A # 12
ST 12
Code:
binary code

000001 1 00000 001100
001000 1 00000 001100
001000 0 00000 001100

Ld A #5
Ld R1#3
Add A,R1
look this example here I am using source and destination register

my main problem that I don't understand how to specify the operand ?

If I have accumulator , memory register R1,R2 R3.....etc
Q1 how to know that which register use as source register or destination register . ?
because both accumulator and memory register can be used as source or destination

Q2how to make binary sequence for instruction set ( opcode source and destination register ) ?

I already made some sequence but I am getting problem when I try to make binary sequence for following example
Add A,R1
 
  • #6
vead said:
look at my another effort

Instruction set
  • opcode - instruction name
  • operand - data or address
6 bit opcode +mode +5 bit source register + 6 bit for destination register
Mode
0 address (without #)
1 number (with #)

Code:
Opcode         instruction       mode                           example
000000          nop                  0 address                           ------
000001          Load                1 number                       Ld A # 12
000010          Load                0 address                       Ld 12
000100          Add                  0 address                       Add 12
001000          Add                  1 number                        Add A # 12
010000          Sub                  0 address                       Sub 12
100000          Sub                  1 number                        Sub A # 12
111111          Store               0 address                         ST 12

I wrote few instruction just for example .I have 256 instruction

Assembly code
loads the number 12 into the accumulator
Code:
Ld A # 12

Bianry code

000001 1 00000 001100

Assembly code
Code:
Add # 12
Add the number 12 into the accumulator

binary code

001000 1 00000 001100
stores the result into memory location 12
Code:
ST 12
Memory
address number
11 10
12 24
13 05
saves the accumulator result (24) to the memory address 12
Bianry code

001000 0 00000 001100

Assembly code

Ld A # 12
Add A # 12
ST 12
Code:
binary code

000001 1 00000 001100
001000 1 00000 001100
001000 0 00000 001100

Ld A #5
Ld R1#3
Add A,R1
look this example here I am using source and destination register

my main problem that I don't understand how to specify the operand ?
Do it the same way as you did the examples just before this (i.e., Ld A #12, Add A, #12, ST 12).
You're already specifying the operand in your binary code. For example, taking one of your examples above, you have
000001 1 00000 001100
Taking these in groups from left to right, we have:
000001 - Load
1 - number
00000 - accumulator
001100 - immediate value 12

vead said:
If I have accumulator , memory register R1,R2 R3.....etc
Q1 how to know that which register use as source register or destination register . ?
because both accumulator and memory register can be used as source or destination

Q2how to make binary sequence for instruction set ( opcode source and destination register ) ?

I already made some sequence but I am getting problem when I try to make binary sequence for following example
Add A,R1
I don't understand why this is so difficult for you. You have already specified how the bits in the binary code mean.
6 bit opcode +mode +5 bit source register + 6 bit for destination register
 

Related to Transfer data from memory to register / register to memory?

1. How do you transfer data from memory to a register?

The process of transferring data from memory to a register involves two steps: first, the address of the data in memory is loaded into the memory address register (MAR). Then, the actual data is transferred from the memory location specified by the MAR into the memory data register (MDR). This data can then be moved into the desired register for use.

2. What is the purpose of transferring data from memory to a register?

The purpose of this transfer is to make the data more easily accessible for the processor. Registers are much faster to access than memory, so by transferring frequently used data into registers, the processor can retrieve and use the data more quickly.

3. How is data transferred from a register to memory?

The process of transferring data from a register to memory is similar to the reverse process. The data is first loaded into the memory data register (MDR), and then the address of the memory location is loaded into the memory address register (MAR). The data is then written into the specified memory location.

4. Can data be transferred directly between two registers?

Yes, data can be transferred directly between two registers using a move instruction. This is often used for data manipulation or for transferring data between different parts of a program.

5. What are some common challenges in transferring data between memory and registers?

One common challenge is managing the limited number of registers available in a processor. This can require careful planning to ensure that all necessary data is transferred and stored in the available registers. Another challenge is ensuring that the data is transferred accurately and without any errors, as errors can lead to incorrect data being used by the processor.

Similar threads

Replies
1
Views
1K
  • Programming and Computer Science
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
  • Programming and Computer Science
Replies
18
Views
5K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
3K
  • Sticky
  • Programming and Computer Science
Replies
13
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
  • Programming and Computer Science
Replies
15
Views
3K
Back
Top