Presentation is loading. Please wait.

Presentation is loading. Please wait.

Processor Fundamentals

Similar presentations


Presentation on theme: "Processor Fundamentals"— Presentation transcript:

1 Processor Fundamentals
Assembly Language

2 Learning Objectives Show understanding of the relationship between assembly language and machine code, including symbolic and absolute addressing, directives and macros. Describe the different stages of the assembly process for a ‘two-pass’ assembler for a given simple assembly language program Trace a given simple assembly language program

3 Low Level Programming Languages / Paradigm (method of programming)
Instructions are either in machine code or they are one to one with machine code e.g. assembly language See next two slides. Are “close to the hardware” as they provide little or no abstraction from a computer's instruction set architecture (see Fetch-Decode-Execute-Reset Cycle). Meaning that each low level language instruction is one operation the processor executes which can only be one of 3 types: Arithmetic / Jump / Control. Low-level language programs written for 1 computer will not necessarily work on another using a different processor, chip or architecture.

4 Assembly Languages Use of mnemonics.

5 Absolute Addressing Refers directly to a memory location e.g. 2011.
Advantage: Simple. Disadvantages: Difficult to see the meaning of the data in location 2011. The data may not be able to be located at 2011 because another program is already using that location. Absolute addressing produces non-relocatable code.

6 Symbolic Addressing e.g. // Computes sum= 00 LDM 0 01 STO Index 02 STO Sum Loop: 03 LDD Index 04 CMP 101 05 JPE End 06 INC ACC 07 STO Index 08 LDD Sum 09 ADD Index 10 STO Sum 11 JMP Loop End: 12 End ….. 1024 Index: 1025 Sum: Define a symbol for the data item or location instead of referring to an absolute location, Labels / Variables: . Label various locations in the program with symbols. For example, one can declare the label loop to refer to the beginning of a certain code segment. Other commands in the program can then jump to loop, either conditionally or unconditionally. Assign symbolic variable names to memory addresses. Predefined Symbols: See slide 4. Forward References Forward References Forward References

7 Directives e.g. // Computes sum= 00 LDM 0 01 STO Index 02 STO Sum Loop: 03 LDD Index 04 CMP 101 05 JPE End 06 INC ACC 07 STO Index 08 LDD Sum 09 ADD Index 10 STO Sum 11 JMP Loop End: 12 End ….. 1024 Index: 1025 Sum: Provide information to the assembler but do not generate any code.

8 Macros Many programs contain sequence of instructions which are repeated in identical form. A macro facility permits us to attach a name to this sequence and to use this name in its place. e.g. Start of definition MACRO Macro name CNTR (for example) Sequence to be abbreviated - - END of a Macro definition MEND

9 Two-Pass Assembler First pass: Second pass:
The assembler builds a symbol table and generates no code. Second pass: The assembler replaces each symbol with its corresponding meaning (numeric address) and generates the final binary code. e.g. // Computes sum= 00 LDM 0 01 STO Index 02 STO Sum Loop: 03 LDD Index 04 CMP 101 05 JPE End 06 INC ACC 07 STO Index 08 LDD Sum 09 ADD Index 10 STO Sum 11 JMP Loop End: 12 End ….. 1024 Index: 1025 Sum: 00 LDM 0 01 STO 1024 02 STO 1025 03 LDD 1024 04 CMP 101 05 JPE 12 06 INC ACC 07 STO 1024 08 LDD 1025 09 ADD 1024 10 STO 1025 11 JMP 3 12 End ….. 1024 1025 Machine Code: Symbol Table Index 1024 Sum 1025 Loop 3 End 12 Forward References

10 Assembly Languages Use of mnemonics and names/labels (instead of addresses) for locations in memory. Each assembly instruction represents a single machine instruction which means that it is fairly easy to translate a program written in assembly language to machine code. Writing programs in assembly language, although easier than using machine code, is still tedious and takes a long time.

11 Plenary Explain the relationship between assembly languages and machine code.

12 Assembly Languages Use of mnemonics and names/labels (instead of addresses) for locations in memory. Each assembly instruction represents a single machine instruction which means that it is fairly easy to translate a program written in assembly language to machine code. Writing programs in assembly language, although easier than using machine code, is still tedious and takes a long time.

13 Plenary Describe how an assembler produces machine code from assembly language.

14 Two-Pass Assembler First pass: Second pass:
The assembler builds a symbol table and generates no code. Second pass: The assembler replaces each symbol with its corresponding meaning (numeric address) and generates the final binary code. e.g. // Computes sum= 00 LDM 0 01 STO Index 02 STO Sum Loop: 03 LDD Index 04 CMP 101 05 JPE End 06 INC ACC 07 STO Index 08 LDD Sum 09 ADD Index 10 STO Sum 11 JMP Loop End: 12 End ….. 1024 Index: 1025 Sum: 00 LDM 0 01 STO 1024 02 STO 1025 03 LDD 1024 04 CMP 101 05 JPE 12 06 INC ACC 07 STO 1024 08 LDD 1025 09 ADD 1024 10 STO 1025 11 JMP 3 12 End ….. 1024 1025 Machine Code: Symbol Table Index 1024 Sum 1025 Loop 3 End 12 Forward References


Download ppt "Processor Fundamentals"

Similar presentations


Ads by Google