Lecture7

Lecture7 - Abhishek Bhattacharjee Topics s Introduction to...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Abhishek Bhattacharjee Topics s Introduction to Assembly Programming c x86 assembly Assembly Programming Rutgers University Abhishek Bhattacharjee 2 Review Rutgers University Abhishek Bhattacharjee 3 Decimal to IEEE Floating Point 5.625 In binary 101.101 b 1.01101 x 2 2 Exponent field has value 2 s add 127 to get 129 Exponent is 10000001 Mantissa is 01101 Sign bit is 0 0 10000001 0110100000000000000000 Rutgers University Abhishek Bhattacharjee 4 2s Complement Addition & Subtraction Addition = binary addition, ignore carry out Subtraction = invert subtrahend and add 4 2 = 4 + -2-7 1001 + 5 0101-----------2 1110-5 1011 + -2 1110-------------7 11001 4 0100 + -2 1110------------ 2 0010 Rutgers University Abhishek Bhattacharjee 5 2s Complement Overflow What happens when overflow occurs with 2s complement? s Need one extra bit so sign bit will be wrong s How to detect? c Adding 2 positive numbers b negative result c Adding 2 negative numbers b positive result 6 0110 + 5 0101------------5 1011-6 1010 + -6 1010------------ 4 0100 Rutgers University Abhishek Bhattacharjee 6 Multiplication Algorithm 1011 x 101------ 1011 0000 1011------ 110111 (multiplicand x 1) shift left 0 (multiplicand x 0) shift left 1 (multiplicand x 1) shift left 2 Rutgers University Abhishek Bhattacharjee 7 Algorithm 1. result = 0 2. If LSB of multiplier = 1, add multiplicand to result else, add 0 to result 3. Shift multiplicand left by 1 bit (fill LSB with 0) 4. Shift multiplier right by 1 bit (fill MSB with 0) 5. If multiplier > 0, go to 1 6. Stop We only need to know how to add and shift in order to multiply 7 Sign extension Signed integer 4-bit representation 8-bit representation 16-bit representation +1 0001 00000001 0000000000000001-1 1111 11111111 1111111111111111 Rutgers University Abhishek Bhattacharjee 9 Assembly Programming Brief tour through assembly language programming Why? s Machine interface: where software meets hardware s To understand how the hardware works, we have to understand the interface that it exports Why not binary language? s Much easier for humans to read and reason about s Major differences: c Human readable language instead of binary sequences c Relative instead of absolute addresses Rutgers University Abhishek Bhattacharjee 10 Programming Meets Hardware High-Level Language Program Assembly Language Program Machine Language Program movl $1, -8(%ebp)...
View Full Document

Page1 / 31

Lecture7 - Abhishek Bhattacharjee Topics s Introduction to...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online