My file contains the following code:
test.asm
^^^^^^^^^^^^^^^^
!START:
!LDA #97
!LDX #$A000
!STA, X
!END
I store the above code in my program in a string called sourcecode.
Every Label (kind of a keyword for me here) begins with an ! mark.
Thus, START / LDA / LDX / STA / END are labels which i would like to store.
Now the contents of file may vary.
I would like to know which STL Container can i use to store my Keywords.
Mind you each keyword is to be stored in single element of that container.
If vector can solve my problem, can an example be shown?
My main aim is to use these labels/keywords to pass in functions to be interpreted
as Mnemonics (which i will define).
Also, would like to know how would i iterate if my vector is of type string: vector<string>
Thanks in advance.
6502 assembly – what fun!
As tenfour says, a vector is good for compact and relatively immutable storage and access, but your usage over the lifetime of your app should guide your selection. (The good news is that if you use STL iterators, you should be able to switch container types with little impact on the rest of your code.)
Here’s a couple pages to look at to help decide:
http://www.cplusplus.com/reference/stl/
http://en.wikipedia.org/wiki/Standard_Template_Library
Have fun!