$29.99
I. Topic Overview:
The lab is designed to introduce the students to get the basic idea on the registers involved in an Intel 8086 processor. In other words, students will be taught about how the registers can be used as variables and be introduced to some of the registers’ special features. Furthermore, on successfully understanding how a register works, they will learn to perform basic arithmetic operations using those registers. Lastly, they will be introduced to an Intel 8086 instructions which is called ‘MOV’.
II. Lesson Fit:
In order to do the lab with ease, the student must have completed Lab 1 of the CSE341
Course, which was ‘Introduction’. The lab was designed to introduce the students with the simulator and its functions.
III. Learning Outcome:
a. know about the registers and their functions in an Intel 8086 processor.
b. perform arithmetic operations using the registers.
c. use the ‘MOV’ instruction in their assembly language coding.
IV. Anticipated Challenges and Possible Solutions
a. Use of 8 bit and 16 bit registers together during arithmetic operations Solutions:
i. Mention of keeping the registers bit size fixed.
ii. Give them examples
V. Acceptance and Evaluation
Code: 50% Viva: 50%
VI. Activity Detail a. Hour: 1 Discussion: Registers
16-bit storage for holding data temporarily during operations. Do not confuse with RAM. Registers can be divided into 4 types.
i. Data Registers: AX, BX, CX, DX
These 4 registers are used to hold data for carrying out mathematical and logical operations. These 4 registers are byte accessible. This means each 16-bit register can be used as two separate8-bit registers. AX = AH and AL, same goes for others. These four registers also perform other special functions. AX = During multiplication and division, one of the numbers must be inside AX or AL. BX = Used as address registers. CX = used in loop. CX increases automatically by 1DX = Used in multiplication/division and i/o operations.
ii. Segment Registers: CS, DS, SS, ES
To understand the these registers we must understand what memory segments are. The 8086 is a 16-bit Microprocessor and contains a memory of 20 bits. Now to store a value of10 bits the registers had to be of 20 bits each but they are not. To overcome this problem the whole memory is divided into a 3 segments data segment, stack segment and code segment. The segment registers will contain the address of the segments. Each segment register will be combined with index registers (16 bit) to form a 20-bit storage to store memory locations. [The combination of 2 16-bit registers to form a 20-bit location will be covered in theory class].
iii. Index and Pointer Registers: SP, BP, SI, DI
They contain the offset addresses mentioned in the previous section. There are restrictions of using a segment register and index registers.
SP used with SS
BP used with DS, SS
SI used with DS
DI used with DS
b. Hour: 2 Discussion: Instructions (mov, add, sub, inc, dec, neg)
i. MOV: used to transfer data between registers; to a register from a memory location, from a memory location to register. Moving constants to register or memory locations. syntax: mov destination, source mov al,5 - the decimal value 5 will be stored in al
ii. ADD/SUB: addition/ subtraction between numbers. These operations occur between 2 registers, register/memory location and a number, register and memory location.
Syntax: add/sub destination, source
i.e. destination = destination +/ - source
iii. INC: This is used to increment a value of a register by 1. inc ax; // this would increase the value of ax by 1. iv. DEC: This is used to decrement a value of a register by 1.
dec ax; // this would decrease the value of ax by 1.
v. NEG: This is used to negate the contents of the destination. NEG does this by replacing the contents by its two's. complement. The syntax is:
NEG destination
Problem Task: Task 01 - 06
c. Hour: 3 Discussion: Instructions (mul. div)
i. MUL: multiplication between 2 numbers. You must be very careful while carrying out multiplication. This is because 2 n bit numbers will result a 2n bit number. Therefore, multiplication is divided into2branches. byte multiplication where the operands are 8-bit numbers and word multiplication where the numbers are 16-bit numbers.
For byte multiplication one number is contained in the source and the other number has to be in AL. The result is saved in AX. The source can be a register or a memory location but not a constant. mul BL; the 8-bit number is AL is multiplied by the 8-bit number in BL.
The result is in AX.
For word multiplication one number is contained in the source and the other number has to be in AX. The result will be a 32-bit number. The higher 16 bits will be in DX and the lower 16-bit will be in AX. The source can be a register or a memory location but not a constant.
ii. DIV: When division is performed there are 2 results- quotient and remainder. Division is also divided into byte and word form. In the byte form the divisor is an 8 bit register or memory location. The dividend is 16 bit and it must be in AX. After division the 8-bitquotient is in AL and the 8-bit remainder is in AH. The divisor can't be a constant. div BL; the 16-bit number is AX is divided by the 8-bit number I n BL. The quotient is in AL and the 8-bit remainder is in AH.
In the word form, the divisor is a 16-bit register or memory location. The dividend is 32 bit and it must be in DX:AX. After division the 16-bit quotient is in AX and the 16-bit remainder is in DX. The divisor can't be a constant.
Problem Task: Task 07-08
VII. Home Tasks: Task 09 - 11
Experiment/Lab 2 Activity List
Task 01
Take input in the register AX, and then move it to BX using the MOV instruction.
Task 02
Swap two numbers, using a maximum of 3 registers.
Hint: Use the MOV instruction.
Task 03
Add two numbers using two registers.
Task 04
Subtract two numbers using two registers. Do you always get the correct answer? What happens when you subtract larger number from the smaller one?
Task 05
Swap two numbers using ADD/SUB instructions only.
Task 06
Perform the following arithmetic instructions. A, B, C are three variables to be declared beforehand
1. A = B - A
2. A = -(A + 1)
3. C = A + (B + 1); use inc
4. A = B – (A – 1); use dec
Task 07
Perform the following arithmetic operations
1. X * Y
2. X / Y
3. X * Y / Z
Task 08
Perform the following arithmetic operations
1. 236DF * AF
2. 8A32F4D5 / C9A5
3. CA92 * BAF9
4. C2A2 * ABCD / BED
Task 09 (Home Task)
Write two examples for each combination of registers possible for the 'mov' instruction.
Hint: See the table above to see all the possible combinations.
Task 10 (Home Task)
Write two examples for each combination of registers possible for the 'add' and 'sub' instructions.
Hint: See the table above to see all the possible combinations.
Task 11 (Home Task)
Perform the following arithmetic operation: (1 + 2) * (3 – 1) / 5 + 3 + 2 – (1 * 2)