CSCI 1120 Lecture Notes - Lecture 39: Opcode, Memory Address, Portable Executable
CSCI 1120 verified notes
39/39View all
Document Summary
Turn all labels into opcodes, mnemonics into memory locations. We can do this in one pass because assembly language does not need to keep track of memory addresses due to labels. The first pass is to build a symbol table: scan the code, identify the labels, identify the location in the program where the label is located, assign memory address to the labels. All memory addresses should be a multiple of 4, assuming a 32-bit environment (in a 64-bit environment, multiples of 8) each line would be encoded into 4 bytes. Scan code from top to bottom, write down memory address of labels. After the first scan, with our list of memory addresses, we need to find a way to convert out mnemonic into an actual opcode (for use in the decode phase of the execution cycle) Use the binary opcode, assumed to be 4 bits, to go back to the beginning of the code and design a portable executable.