Dump value from FIFO read data pointer HPS FIFO

Hi all, I have made a simple fifo that reads value from HPS on cyclone V board. I have trouble in understanding how fifo is giving me back data here. If you see the output below then there are couple of things that I dont understand

  1. Why read pointer is always 1 step behind the write pointer.

  2. What is this dump value at position zero of read pointer.

  3. How can I get all my values back from read pointer?
    Here is the snapshot of my design and my code and output.
    The c code to read and write data to fifo

    #include <stdio.h>
    #include <unistd.h>
    #include <stdlib.h>
    #include <stdint.h>
    #include <fcntl.h>
    #include <sys/mman.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include “C:\altera\15.1\embedded\ip\altera\hps\altera_hps\hwlib\include\hwlib.h”
    #include “C:\altera\15.1\embedded\ip\altera\hps\altera_hps\hwlib\include\soc_cv_av\socal\socal.h”
    #include “C:\altera\15.1\embedded\ip\altera\hps\altera_hps\hwlib\include\soc_cv_av\socal\hps.h”
    #include “C:\altera\15.1\embedded\ip\altera\hps\altera_hps\hwlib\include\soc_cv_av\socal\alt_gpio.h”
    #include “D:\TestDesigns\customfifoloopback1\hps_0.h”
    //fifo status pointers
    //#define FIFO_FULL (((FIFO_write_status_ptr+1))& 1 )
    //#define FIFO_EMPTY ((
    (FIFO_read_ptr+1))& 2 )

    //LW Addresses
    #define REG_BASE 0xFF200000
    #define REG_SPAN 0x00200000

    //initializing the pointers
    void* virtual_base;
    volatile unsigned int * FIFO_write_status_ptr= NULL;
    volatile unsigned int * FIFO_read_status_ptr = NULL ;
    volatile unsigned int * FIFO_write_ptr = NULL ;
    volatile unsigned int * FIFO_read_ptr = NULL ;
    unsigned int value;
    int data[5];
    int i;
    //int FIFO_FULL;
    //int FIFO_EMPTY;
    //main functions
    int main ()
    {

    int fd = EXIT_FAILURE;
    fd=open("/dev/mem",(O_RDWR|O_SYNC));
    if (fd < 0) {
    perror(“open”);
    exit(EXIT_FAILURE);
    }
    printf(“fd is ok\n”);

    //accessing the virtual addresses of the fifo pointers
    virtual_base=mmap(NULL,REG_SPAN,(PROT_READ|PROT_WRITE),MAP_SHARED,fd,REG_BASE);
    printf(“virtual base pointer to open device memory file is ok\n”);

    FIFO_write_status_ptr = (unsigned int *)(virtual_base+FIFO_0_IN_CSR_BASE);
    FIFO_read_status_ptr = (unsigned int *)(virtual_base+FIFO_0_OUT_CSR_BASE);
    FIFO_write_ptr=(unsigned int *)(virtual_base+FIFO_0_IN_BASE);
    FIFO_read_ptr= (unsigned int *)(virtual_base+FIFO_0_OUT_BASE);
    printf(“fifo pointers are ok\n”);

    //entering data into the fifo
    for(i=0;i<8;i++)
    {
    data[i]=i+1;
    *FIFO_write_ptr=data[i];
    printf("////////////////////////////\n");
    printf(“you entered the value %d\n”,*FIFO_write_ptr);
    printf(“fifo write status pointer is %d\n”,*FIFO_write_status_ptr);
    printf("//////////////////////////////\n");
    }

    printf(“reading back the data\n”);

    for(i=0;i<8;i++)
    {
    //reading data from the fifo
    printf("////////////////////////////\n");
    printf(“the output value from the fifo is%d\n”,*FIFO_read_ptr);
    printf(“fifo read status pointer is %d\n”,*FIFO_read_status_ptr);
    printf("/////////////////////////////\n");
    }
    return 0;
    }