CS270 Colorado State University ============= LC3 assembler ============= Ch 7 -------------------------- Canonical Starting Example .ORIG x3000 LEA R0, MYSTR PUTS HALT MYSTR .FILL x48 .FILL x69 .FILL x20 .STRINGZ "World!\n" .END What does the above assembly program do? How can we convert it to LC3 machine code? ----------------------- Overview of PA4 Part 1 - Implement sym_table_lookup() function. Part 2 - Implement pass_two of assembler, which figures out offsets and pass_three, which constructs machine code. Use the available documentation. Example READMEs ----------------------- Symbol Table A symbol table is a kind of dictionary. Key, Value pairs Key is label. Value is address. Binary tree is one way to implement a dictionary. Each node holds a key, value pair. A node's left subtree contains only keys that are less than the key stored at the node. A node's right subtree contains only keys that are more than the key stored at the node. Labels are stored as C strings char a; String comparison int strcmp ( const char * str1, const char * str2 ); #include #include int main() { char mystr = "hi"; char other = "bye"; printf("strcmp(mystr, other) = %d\n", strcmp(mystr, other)); printf("strcmp(other, other) = %d\n", strcmp(other, other)); printf("strcmp(other, mystr) = %d\n", strcmp(other, mystr)); return 0; } Insertion into a binary tree struct sym_node_struct { char* symbol; int address; sym_node_t* left; sym_node_t* right; }; ------------------------------------- Pointers and Pointer to Pointers in C C uses pass-by-value semantics. Examples of when we need a pointer? Examples of when we need a pointer to a pointer? ------------------------ mstrout@cs.colostate.edu, 10/15/08