Unit 3 assembler and processor

1,707 views
1,664 views

Published on

Published in: Education, Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,707
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
69
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide
  • Forward References : When one pass assembler constructing the object code, if it finds usage of the variables before the declaration then forward reference problem will occur. To avoid forward reference problem: i) Declare the symbols before using it ii) Use more than one pass assembler(multi pass assembler)
  • Unit 3 assembler and processor

    1. 1. Assembly Language Prakash Khaire UTU
    2. 2. Assembly Language A programming language that is one step away from machine language. Each assembly language statement is translated into one machine instruction by the assembler. Programmers must be well versed in the computers architecture, and, undocumented assembly language programs are difficult to maintain. It is hardware dependent; there is a different assembly language for each CPU series.
    3. 3. Assembly Language It was introduced in 1952 Helped to overcome machine language programmingDefinition : “A language that allows instructions and storage locations to be represented by letters and symbols instead of numbers is called assembly language or symbolic language”
    4. 4. Assembly Language Model … add r1,r2 sub r2,r3PC cmp r3,r4 ALU bne I1 Registers Memory sub r4,1 I1: jmp I3 …
    5. 5. Assembly Language InstructionsBuilt from two pieces Add R1, R3, 3 Opcode Operands What to do with Where to get the data data and put (ALU operation) the results
    6. 6. Types of OpcodesArithmetic, logical add, sub, mult and, or CmpMemory load/store ld, stControl transfer jmp bne
    7. 7. OperandsEach operand taken from a particular addressing mode:Examples:Register add r1, r2, r3Immediate add r1, r2, 10Indirect mov r1, (r2)Offset mov r1, 10(r3)PC Relative beq 100Reflect processor data pathways
    8. 8. Advantages over Machine LanguageEasier to understand and useEasier to locate and correct errors.Easier to modifyNo worry about addressesEasily relocatableEfficiency of machine language
    9. 9. Limitations of Assembly LanguageMachine DependentKnowledge of hardware requiredMachine level coding
    10. 10. Architecture of 8086
    11. 11. Registers in 8086 CPU There are four general purpose registers  AX [divided into AH/AL] – the accumulator register  BX [divided into BH/BL] – the base address register  CX [divided into CH/CL] – the count register  DX [divided into DH/DL] – the data registerOther registers  SI – source index register  DI – destination index register  BP – Base pointer  SP – Stack pointer
    12. 12. Registers in 8086 CPU This registers are of 16 bits and divided into two 8 bit registers  For Example If AX = 0011000000111001b then AH = 00110000b and AL=001111001b  Registers are located in CPU, Segment Registers  Used for special purpose pointing at accessible blocks of memory  It stores any data  Four segment registers during execution  CS – Points the segment storing the current program  DS – Points the segment where variable are defined  ES – Extra Segment register, depends on the usage of coder  SS – Points to the segment containing the stack Along with general purpose registers, segment registers work to access any memory value.
    13. 13. Flags FLAG : The FLAG register is the status register in the Intel 8086 microprocessor that contains the current state of the microprocessor. This register is 16 bits wide.  carry flag (CF)- indicates a carry after addition or a borrow after subtraction, also indicates error conditions.  parity flag (PF)- is a logic “0” for odd parity and a logic “1” for even parity.  auxiliary carry flag (AF)- important for BCD addition and subtraction; holds a carry (borrow) after addition (subtraction) between bits position 3 and 4. Only used for DAA and DAS instructions to adjust the value of AL after a BCD addition (subtraction).  zero flag (ZF)- indicates that the result of an arithmetic or logic operation is zero.  sign flag (SF)- indicates arithmetic sign of the result after an arithmetic operation.  overflow flag (OF)- a condition that occurs when signed numbers are added or subtracted. An overflow indicates that the result has exceeded the capacity of the machine.
    14. 14. Offset The offset address in an 8086/8088 is the logical address that the program "thinks about" when it addresses a location in memory. The Execution Unit (EU or CPU) is responsible for generating the offset address. The Bus Interface Unit (BIU), on the other hand, takes the offset address and adds it to four times the selected segment register value in order to determine a real address, which is now 20-bits in length.
    15. 15. Registers in 8086 CPU Programmers access various memory locations on combining BX, SI, DI and BP registers.  The value in segment registers[CS, DS, SS,ES] is called “segment”  The value in purpose registers [BX, SI, DI, BP] is called “offset”  For Example  DS contains value 1234h and SI contains the value 7890h it can also be recorded as 1234:7890 Two special purpose registers  IP – Instruction Register  Flags Register – determines the current state of the processor
    16. 16. Registers in 8086 CPU IP works along with CS register and points to the currently executing instruction Flags register is modified by CPU, while performing mathematical operations
    17. 17. Assembler Design ApproachAssembler generates object code.Role of assembler – Translates the source code into target codeDuring this translation process it uses various table like Machine Opcode Table Symbol table Literal table
    18. 18. Assembler Design ApproachMachine Opcode Table  It holds opcode used by the processor for different instructions mnemonics Mnemonic size Opcode Holds various instructions Size of instructions in bytes Size of instructions in bytes
    19. 19. Symbol Table It is data structure used by assmebler It keeps into account attributes of the identifier and other information.  Attributes : type, value, scope and address It also performs the function of book keeping. It is composed of multiple word entries in fixed format Name Value Type
    20. 20. One Pass AssemblerDoes everything in one passProblem: How do we handle forward references?Could eliminate forward references easy for data – just define the data areas before they are referenced not easy in code – how do we handle selection or loop statements which have forward jumps?Two types of one pass assemblers: produce object code directly in memory produce object program for later execution
    21. 21. One Pass Assembler Assembler generates object code instructions as it scans source program If an operand symbol has not yet been defined  operand address is set to 0 in instruction  symbol is entered into the symbol table (unless it is already present)  entry is flagged to indicate the symbol is undefined  address of instruction is added to list of forward references associated with this symbol When symbol definition is encountered  forward reference list is scanned, and proper address is inserted in any instructions previously generated (in memory)
    22. 22. One pass assembler that produces object programs Use the same procedure When the definition of a symbol is encountered  if instruction which made the forward reference is still in memory, then fix it  if not, the instruction has already been written out in a Text record, so generate a new Text record with the correct operand address  (could also use a modification record)  The loader will fix up the address field
    23. 23. One pass assembler that produces object programs Problem : Forward Reference  It be eliminated by declaring variable before using them  However, elimination can’t be done easily because sometimes program needs a forward jump.

    ×