1 / 14

Microprocessor

Microprocessor. MA Rahim Khan Computer Engineering and Networks Department. Flag Register.

kelda
Télécharger la présentation

Microprocessor

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Microprocessor MA Rahim Khan Computer Engineering and Networks Department

  2. Flag Register • Carry Flag (CF) - this flag is set to 1 when there is an unsigned overflow. For example when you add bytes 255 + 1 (result is not in range 0...255). When there is no overflow this flag is set to 0.  • Zero Flag (ZF) - set to 1 when result is zero. For none zero result this flag is set to 0.  • Sign Flag (SF) - set to 1 when result is negative. When result is positive it is set to 0. Actually this flag take the value of the most significant bit. Overflow Flag (OF) - set to 1 when there is a signed overflow. For example, when you add bytes 100 + 50 (result is not in range -128...127). 

  3. Flag Register Cont…. Parity Flag (PF) - this flag is set to 1 when there is even number of one bits in result, and to 0 when there is odd number of one bits. Even if result is a word only 8 low bits are analyzed! Auxiliary Flag (AF) - set to 1 when there is an unsigned overflow for low nibble (4 bits). Interrupt enable Flag (IF) - when this flag is set to 1 CPU reacts to interrupts from external devices. Direction Flag (DF) - this flag is used by some instructions to process data chains, when this flag is set to 0 - the processing is done forward, when this flag is set to 1 the processing is done backward. 

  4. Carry Flag • include 'emu8086.inc' • ORG 100h • MOV AL, 255 • ADD AL, 1 • JC label1 • PRINT 'no carry.' • JMP exit • label1: • PRINT 'has carry.' • exit: • RET

  5. Jump if CX Register is Zero • include 'emu8086.inc' • ORG 100h • MOV CX, 0 • JCXZ label1 • PRINT 'CX is not zero.' • JMP exit • label1: • PRINT 'CX is zero.' • exit: • RET

  6. Jump if Parity Even • include 'emu8086.inc' • #make_com# • ORG 100h • MOV AL, 00000101b ; AL = 5 • AND AL, 11111111B ; just set flags. • JP label1 • PRINT 'parity odd.' • JMP exit • label1: • PRINT 'parity even.' • exit: • RET

  7. Jump if Parity Even • include 'emu8086.inc' • ORG 100h • MOV AL, 00000101b ; AL = 5 • OR AL, 0 ; just set flags. • JPE label1 • PRINT 'parity odd.' • JMP exit • label1: • PRINT 'parity even.' • exit: • RET

  8. Jump if Parity Odd. • include 'emu8086.inc' • ORG 100h • MOV AL, 00000111b ; AL = 7 • OR AL, 0 ; just set flags. • JPO label1 • PRINT 'parity even.' • JMP exit • label1: • PRINT 'parity odd.' • exit: • RET

  9. Jump if Signed • include 'emu8086.inc' • ORG 100h • MOV AL, 10000000b ; AL = -128 • OR AL, 0 ; just set flags. • JS label1 • PRINT 'not signed.' • JMP exit • label1: • PRINT 'signed.' • exit: • RET

  10. Jump if Not Signed • ORG 100h • MOV AL, 00000111b ; AL = 7 • OR AL, 0 ; just set flags. • JNS label1 • PRINT 'signed.' • JMP exit • label1: • PRINT 'not signed.' • exit: • RET

  11. Complement Carry flag(CMC) • if CF = 1 then CF = 0if CF = 0 then CF = 1 • No operands

  12. Clear Carry flag(CLC)  • Clear Carry flag. Algorithm: CF = 0  • No operands

  13. Signed divide.(IDIV)  • Signed divide. Algorithm:when operand is a byte:AL = AX / operandAH = remainder (modulus)when operand is a word:AX = (DX AX) / operandDX = remainder (modulus) • Example: • MOV AX, -203 • ; AX = 0FF35h • MOV BL, 4 • IDIV BL • ; AL = -50 (0CEh), AH = -3 (0FDh) • RET

  14. Signed Multiply  • when operand is a byte:AX = AL * operand. when operand is a word:(DX AX) = AX * operand. • Example: • MOV AL, -2 • MOV BL, -4 • IMUL BL ; AX = 8 • RET

More Related