'Accessing DCB and DCW memory types in KEIL

I'm a newbie at assembly and I am currently working on a project to try and develop a word cloud using ARM Assembly language and C++. I am developing the following function:

GetFreq to access a number in a table declared as a DCW memory type. One of the restraints is the function must be written in assembly and then called by my C++ program

This is currently how the function is looking:

GetFreq ADR r3, table ;load the table into memory
        LDRB R2, [R3, #4] ;access a byte
        CMP r2, #0  ;compare it to 0 to see if we are at the end of the table
        LDRB R0, [R2]   ;return output
        BNE GetFreq  ;go to the next
        BX LR  

This is how the data is being stored:

            ALIGN               ; use this directive to start the entire data block on a word boundary
table       DCB "pears",0       ; strings must be null-terminated
            DCW 8               ; frequency is a 16-bit half-word
            DCB "apples",0
            DCW 16               
            DCB "pie",0
            DCW 30
            DCB "beans",0
            DCW 12
            DCB 0               ; A zero byte here indicates table termination

If I remove the CMP r2, #0 I get the value 8 returned, however I can not seem to work out how to access the other numbers. I've also been struggling to find any other documentation on accessing memory like this, so I would really appreciate any and all help.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source