{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

eee410_lecture9 - EEE 410 Microprocessors I Spring 04/05...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
EEE 410 – Microprocessors I Spring 04/05 – Lecture Notes # 9 Outline of the Lecture Unsigned Subtraction Unsigned Multiplication and Division Arithmetic and Logic Instructions and Programs S UBTRACTION OF UNSIGNED NUMBERS SUB dest,source ; dest = dest - source ¾ In subtraction 2’s complement method is used. ¾ Execution of SUB instruction 1. Take the 2’s complement of the subtrahend (source operand) 2. Add it to the minuend (destination operand) 3. Invert the carry Ex: MOV AL,3FH ; load AL=3FH MOV BH,23H ; load BH=23H SUB AL,BH ; subtract BH from AL. Place result in AL Execution steps: AL 3F 0011 1111 0011 1111 – BH 23 – 0010 0011 + 1100 0001 (2’s complement) 1C 0001 1100 1 0001 1100 (CF=0) Step 3 CF=0, ZF=0, PF=0, SF=0. If the CF=0, the result is positive and the destination has the result. If the CF=1, the result is negative and the destination has the 2’s complement of the result. NOT and INC increment instructions can be used to change it. Ex: ;from the data segment: DATA1 DB 4CH DATA2 DB 6EH RESULT DB ? ;from the code segment: MOV DH,DATA1 ;load DH with DATA1 value (4CH) SUB DH,DATA2 ;subtract DATA2 (6E) from DH (4C) JNC NEXT ;if CF=0 jump to NEXT target NOT DH ;if CF=1 take the 1’s complement INC DH ;and increment to get 2’s complement NEXT : MOV RESULT,DH ;save DH in RESULT Analysis: Following the 3 steps for “SUB DH,DATA2” 4C 0100 1100 0100 1100 6E 0110 1110 2’s comp + 1001 0010 22 0 1101 1110 CF=1(Step 3) the result is negative
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
SBB (subtract with borrow) SBB dest,source ; dest = dest - source - CF ¾ Used in multibyte (multiword) numbers.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern