90 likes | 231 Vues
Assembly Programming. Notes for Practical 4. Basic Arithmetic. Addition Add destination, source Subtraction Sub destination, source Multiplication Division. Addition. 10 + 6 = 16 mov ax, 10 add ax, 6 Java: ax = 10; ax = ax + 6;. Subtraction. 10 – 6 = 4 mov ax, 10 sub ax, 6
E N D
Assembly Programming Notes for Practical 4 http://www.osdata.com/topic/language/asm/intarith.htm#integerarithmetic
Basic Arithmetic • Addition • Add destination, source • Subtraction • Sub destination, source • Multiplication • Division http://www.osdata.com/topic/language/asm/intarith.htm#integerarithmetic
Addition • 10 + 6 = 16 • mov ax, 10 • add ax, 6 • Java: ax = 10; ax = ax + 6; http://www.osdata.com/topic/language/asm/intarith.htm#integerarithmetic
Subtraction • 10 – 6 = 4 • mov ax, 10 • sub ax, 6 • Java: ax = 10; ax = ax - 6; http://www.osdata.com/topic/language/asm/intarith.htm#integerarithmetic
Multiplication • 4 * 5 (= 20) • mov ax, 4 • imul 5 • Java: ax = 4; ax = ax * 5; http://www.osdata.com/topic/language/asm/intarith.htm#integerarithmetic
Division • 13 ÷ 5 ( = 2 remainder 3) • mov ax, 13 • idiv 5 • ax would have the quotient value • dx has the remainder value http://www.osdata.com/topic/language/asm/intarith.htm#integerarithmetic
Prac 4 • 1. Fibonacci Series • Back-generate the series to 1. Ni = Ni-2 - Ni+1 ; N1 = 1 N2 = 1; for i>0 • 2. Long division • x divided by y, where x < y. • Use integer division to calculate decimals • 123 ÷ 100 = 1.23 http://www.osdata.com/topic/language/asm/intarith.htm#integerarithmetic
For more learning!!! • http://www.osdata.com/topic/language/asm/intarith.htm#integerarithmetic http://www.osdata.com/topic/language/asm/intarith.htm#integerarithmetic