??? 04/16/08 11:36 Read: times |
#153456 - Now I understand. Far more interesting. Responding to: ???'s previous message |
Uttam Bansal said:
i dont have an assembler but i am making one for 8052.
You have looked up the opcode mnemonic, and have a list of legal modes. You have parsed the addressing mode (expression in single operand). You evaluate the expression in the operand. You have the location counter of your current instruction and you know the size of your instruction (2) from your mode table. You calculate the offset as ( xpr - (PC + 2)) in the same way that you would calculate a relative branch instruction. A branch must be -0x80 to +0x7f to be legal. A page must be +0x00 to +0x7ff to be legal. You report an addressing error in the same way as you would report a branch out of range error. You continue assembling with PC += 2. If legal then the top 3 bits go into the opcode, the bottom go into the operand byte. Are you making absolute assembler or one with linkable objects ? David. |