Device - Register

> Computer System > Computer - Device

1 - About

Register is a hardware device component that is used for two purposes:

The term is often used to refer only to the group of registers that are directly encoded as part of an instruction, as defined by the instruction set. More properly, these are called the “architectural registers”.

Zoom of CPU register of the Z80 processor (Source)

Advertising

3 - Usage

3.1 - Storage

In a CPU, most registers are used as high-speed storage for temporary data.

They are also memory location.

It is a small amount of storage available on the CPU whose contents can be accessed more quickly than storage available elsewhere.

Processor registers are at the top of the memory hierarchy, and provide the fastest way for a CPU to access data.

Allocating frequently used variables to registers can be critical to a program's performance. This action (register allocation) is performed by a compiler in the code generation phase.

3.2 - Interface

A software can control a hardware device via its register by:

  • writing to them
  • or receiving information from them

Every devices controlled by the CPU have a set of registers for interfacing with the CPU. Processor registers are located inside the processor.

Each register typically holds a word of data (from 8-bit to 128 bit). CPU instructions instruct the arithmetic and logic unit (ALU) to perform various calculations or other operations on this data (or with the help of it).

The CPU can compute an addition by:

  • placing the two numbers into two separate registers
  • compute the sum and saved it in a third register.

Example of assembly code - Copy a block of memory from one location to another with the 16bit - general purpose register.

memcpy.asm
;
; Entry registers
;       BC - Number of bytes to copy
;       DE - Address of source data block
;       HL - Address of target data block
;
; Return registers
;       BC - Zero
 
            org     1000h       ;Origin at 1000h
memcpy      public
            mov     a,b         ;Test BC,
            ora     c           ;If BC = 0,
            rz                  ;Return
loop:       ldax    d           ;Load A from (DE)
            mov     m,a         ;Store A into (HL)
            inx     d           ;Increment DE
            inx     h           ;Increment HL
            dcx     b           ;Decrement BC (does not affect Flags)
            mov     a,b         ;Test for done
            ora     c           ;B | C = 0 and done
            jnz     loop        ;Repeat loop until BC = 0
            ret
Advertising

4 - Documentation / Reference

computer/device/register.txt · Last modified: 2019/01/07 09:08 by gerardnico