Switch to full style
PIC Assembly Articles
Post a reply

Types of Registers

Sun Mar 31, 2013 4:02 pm

WREG Register:
It also named as "Program memory space".
  • has a size 8-bits.
  • A temp storage for information at CPU.
  • WREG stands for Working Register
  • Can be used for arithmetic and logical instruction like move and add.
Example :

asm code
MOVLW	N

means ; move literal value (N) into WREG register
Note that :
  • Literal means actual value, certain value not pointer.
  • N ranges from 0-255 in decimal and from 00-FF in hexadecimal.
  • Code:
    MOVLW    30H    or   MOVLW   0x30

    This says move number 30 in hexadecimal to WREG register.
  • To write in hexadecimal, number followed by H, or begin the number by 0x.
  • To write in Binary, B ’the number in binary’.
  • To write in decimal, “.” Then the number in decimal.

Example :
Add two numbers 50H + 1FH in WREG register:
asm code
MOVLW 	50H
ADDLW 1FH


File Register:
It also called Data Memory Space, they exist in RAM
Consists of:
  • Special Function Registers (SFR):
    Which are dedicated to special functions such as ALU status, timers, serial communication and I/O ports. Examples: (PORTA, PORTB, PORTC, LATA, LATB, LATC, TRISA, TRISB, TRISC). They are fixed numbers per microprocessor. Their counts range from 7 bytes up to 158 bytes. Also the size of each one of them is 8-bits(1 Byte).
  • General Purpose Registers: (GP-RAM):
    Used for data storage in RAM, spaces that not allocated to SFR is used for GP-RAM. The size of each register is 8-bits( 1 Byte).

It is also important to talk about "Access Bank:"
File Register is divided into 256-byte blocks or banks. This bank called access- bank. At least one access block exists in any microprocessor. For PIC18 family, these 256-bytes are divided into 128 bytes for GP-RAM and 128 bytes for SFRs.

Status registers:
It is a 8bit register , each bit is used for specific status.

  • C: Carry Flag: is set to 1 whenever there is a carry out from the D7 bit.
  • DC: Digital Carry Flag: is set to 1 whenever there is a carry out from D3 to D4.
  • Z: Zero flag: is set to 1 if the arithmetic or logical operation result is zero, and zero otherwise.
  • OV: Overflow flag: is set to 1 whenever the result of a signed number operation is too large, causing high order bit to overflow into sign bit.
  • N: Negative flag: N=0, the result is positive, else if N=1, the result is negative.

Example:
asm code
MOVLW 38H
ADDLW 2FH


Answer :
Code:
38H ->   0011 1000
+ 2FH->  0010 1111
---------------------------------------
67H         0110 0111



  • C=0 , there is no carry after D7.
  • DC=1 , there is a carry from D3 to D4.
  • Z=0; the value at WREG is not zero.




Post a reply
  Related Posts  to : Types of Registers
 Job Project : Check verification module for NCR registers     -  
 Types of Pointers in C++     -  
 pointers to derived types     -  
 temperature transformer between different types     -  
 java data types     -  
 assembler directives types     -  
 What are the types of jdbc drivers.?     -  
 Get Registered File Types and Their Associated Icons in C#     -  
 lesson9: XSD Complex Types Indicators     -  
 MYSQL TEXT field types lengths     -