processor fundamentals assembly language. learning objectives show understanding of the relationship...

Download Processor Fundamentals Assembly Language. Learning Objectives Show understanding of the relationship between assembly language and machine code, including

If you can't read please download the document

Upload: godfrey-dean

Post on 18-Jan-2018

215 views

Category:

Documents


0 download

DESCRIPTION

Low Level Programming Languages 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).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.

TRANSCRIPT

Processor Fundamentals Assembly Language 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 Low Level Programming Languages 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).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. Assembly Languages Use of mnemonics. Absolute (Immediate) Addressing Refers directly to a memory location e.g Advantage: Advantage:Simple. Disadvantages: Disadvantages: Difficult to see the meaning of the data in location 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. Absolute addressing produces non-relocatable code. Symbolic Addressing e.g. Instead of referring to an absolute location assembly language to define a symbol for the data item or location. Labels / Variables:. Labels / Variables:. Mark 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. 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: Predefined Symbols: See slide 4. slide 4slide 4 // Computes sum= LDM 0 01STO Index 02 LDM 0 03STO Sum Loop: 04 LDD Index 05CMP JPE End 07 INC ACC 08STO Index 09LDD Sum 10ADD Index 11STO Sum 12 JMP Loop End: 13 End Index: 1025 Sum: e.g. Provide information to the assembler but do not generate any code. Directives // Computes sum= LDM 0 01STO Index 02 LDM 0 03STO Sum Loop: 04 LDD Index 05CMP JPE End 07 INC ACC 08STO Index 09LDD Sum 10ADD Index 11STO Sum 12 JMP Loop End: 13 End Index: 1025 Sum: 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. e.g. Start of definitionMACRO Macro nameCNTR (for example) Sequence to be abbreviated- - - END of a Macro definitionMEND // Computes sum= LDM 0 01STO Index 02 LDM 0 03STO Sum Loop: 04 LDD Index 05CMP JPE End 07 INC ACC 08STO Index 09LDD Sum 10ADD Index 11STO Sum 12 JMP Loop End: 13 End Index: 1025 Sum: 00 LDM 0 01 STO LDM 0 03STO LDD CMP JPE INC ACC 08STO LDD ADD STO JMP 4 13 End Two-Pass Assembler First pass: The assembler builds a symbol table and generates no code. The assembler builds a symbol table and generates no code. e.g. Index1024 Sum1025 Loop4 End13 Symbol Table Second pass: The assembler replaces each symbol with its corresponding meaning (numeric address) and generates the final binary code. The assembler replaces each symbol with its corresponding meaning (numeric address) and generates the final binary code. Machine Code: 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. Plenary Explain the relationship between assembly languages and machine code. 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. Plenary Describe how an assembler produces machine code from assembly language. // Computes sum= LDM 0 01STO Index 02 LDM 0 03STO Sum Loop: 04 LDD Index 05CMP JPE End 07 INC ACC 08STO Index 09LDD Sum 10ADD Index 11STO Sum 12 JMP Loop End: 13 End Index: 1025 Sum: 00 LDM 0 01 STO LDM 0 03STO LDD CMP JPE INC ACC 08STO LDD ADD STO JMP 4 13 End Two-Pass Assembler First pass: The assembler builds a symbol table and generates no code. The assembler builds a symbol table and generates no code. e.g. Index1024 Sum1025 Loop4 End13 Symbol Table Second pass: The assembler replaces each symbol with its corresponding meaning (numeric address) and generates the final binary code. The assembler replaces each symbol with its corresponding meaning (numeric address) and generates the final binary code. Machine Code: