Transfer data from memory to register / register to memory?

Click For Summary

Discussion Overview

The discussion revolves around the design of a hypothetical microprocessor's instruction set, focusing on how to transfer data between registers and memory. Participants explore the mechanics of writing data to register memory, reading data from registers, and specifying operands in assembly language instructions.

Discussion Character

  • Technical explanation
  • Conceptual clarification
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • Some participants inquire about how to write data from a temporary data storage register (R1) to register memory.
  • Others suggest that the instruction set should include a command like "mov A, R1" to facilitate reading from R1 into the accumulator (A).
  • There is a proposal for an instruction format consisting of a 6-bit opcode, mode, and specifications for source and destination registers.
  • Some participants express confusion about how the instruction determines which register is the source and which is the destination, suggesting that the instruction itself dictates this rather than the registers having inherent knowledge.
  • Participants present examples of assembly code and corresponding binary sequences for various operations, including loading values into the accumulator and performing arithmetic operations.
  • Questions arise regarding how to specify operands when both the accumulator and memory registers can serve as either source or destination registers.
  • There is a challenge in creating binary sequences for specific instructions, particularly for operations involving both the accumulator and registers.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best way to specify operands or the structure of the instruction set, indicating multiple competing views and ongoing confusion regarding the design choices.

Contextual Notes

Limitations include unresolved questions about the binary encoding of instructions and the specific roles of source and destination registers in the instruction set design.

Who May Find This Useful

This discussion may be useful for individuals interested in computer architecture, assembly language programming, and instruction set design.

vead
Messages
92
Reaction score
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
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   Reactions: vead
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 ?
 
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).
 
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
 
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
 

Similar threads

Replies
1
Views
1K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 18 ·
Replies
18
Views
6K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 7 ·
Replies
7
Views
4K
  • Sticky
  • · Replies 13 ·
Replies
13
Views
8K
  • · Replies 15 ·
Replies
15
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 15 ·
Replies
15
Views
3K