Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 11 Implementing an Assembler and a Linker Using C++ and Java.

Similar presentations


Presentation on theme: "Chapter 11 Implementing an Assembler and a Linker Using C++ and Java."— Presentation transcript:

1 Chapter 11 Implementing an Assembler and a Linker Using C++ and Java

2 An assembler must handle

3

4

5 Assembler pseudocode—pass 1

6 Pass 2

7 Symbol table How to implement?

8 Relationship of opcode index (position of its mnemonic in an alphabetized table) and the opcode

9 Computing an opcode from its table index

10 Opcode table in Java

11 Implement the symbol table using the SymbolTable class

12

13 Assembler should check for duplicate labels when making an entry into the symbol table.

14 Text files Contain ASCII codes exclusively. A “.mas” file is an example of a text file.

15 Binary files Do not contain ASCII codes exclusively. “.mob” and “.mac” files are binary files. No translation of end-of-line markers occurs during input or output of binary files.

16 Creates text file.

17 Creates binary file

18 Creates text file

19 Creates binary file

20 Binary input file in Java

21 Binary input file in C++

22 Reading the input text file

23 Creating an R entry

24 assemble method in Assembler class constructs machine word

25 Constructing the machine word requires shifting. For example, for a 4-bit opcode: Machine_word = (short)(opcode <<12) | operand_value;

26

27 To handle endian problem (e.g., if assembler written in Java and linker in C++ on a PC).

28 Using reverseOrder Use

29

30 Linker should detect these errors

31 As linker loads modules, it keeps track of its module’s starting address

32 Implement the P, E, R, and S tables using classes.

33

34 Implement the text buffer using a class.

35

36 Linker pseudocode—phase 1

37

38 Processing modules from a library


Download ppt "Chapter 11 Implementing an Assembler and a Linker Using C++ and Java."

Similar presentations


Ads by Google