Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Transfer data from memory to register / register to memory?

Tags:
  1. Nov 11, 2014 #1
    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 ?
     
  2. jcsd
  3. Nov 11, 2014 #2

    Mark44

    Staff: Mentor

    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).
     
  4. Nov 11, 2014 #3
    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 ?
     
  5. Nov 12, 2014 #4

    Mark44

    Staff: Mentor

    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).
     
  6. Nov 12, 2014 #5
    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 (Text):

    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 (Text):

    Ld A # 12

    Bianry code

    000001 1 00000 001100
     
    Assembly code
    Code (Text):

    Add # 12
    Add the number 12 into the accumulator

    binary code

    001000 1 00000 001100
     


    stores the result into memory location 12
    Code (Text):

    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 (Text):

    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
     
  7. Nov 12, 2014 #6

    Mark44

    Staff: Mentor

    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

    I don't understand why this is so difficult for you. You have already specified how the bits in the binary code mean.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Transfer data from memory to register / register to memory?
Loading...