dhc@exodus.UUCP (David H. Copp) (05/03/84)
If it really is a small job, for a small machine--writing your own assembler might be easier than you think. I once saw an assembler that consisted of little more than two tables, a reserved word table and a symbol table. The reserved word table contained the mnemonic names for the opcodes and the registers, etc.. Each entry consisted of the pair <word> <bit pattern> where the bit pattern was one machine word wide, and consisted of the corresponding op-code, etc., in the right place in the word, and zeros elsewhere. The symbol table contained (as I recall) only address symbols and their definitions (numerical addresses). This was a teeny bit complicated--a hash table--but only a teeny bit. Again, each definition was one machine word wide, with the address in the appropriate field and zeros elsewhere. The assembler only did two basic things; make entries in the address table (whenever a label was encountered), and -- TA DA ... generate code, by Boolean-ORing the definitions for all tokens (except labels and comments) on one line of assembler input! It implements a primitive assembly language, but it works. -- David H. Copp