GROUP EVALUATION FORM Laboratory 3: Arithmetic, Bit Manipulation & Program Control Instructions Group No: Section: LAB SCHEDULE: Group Members: DATE PERFORMED: 1. DATE SUBMITTED: 2. Exercises 3. Prog’g Problems 4. Teamwork (+pts) 5 EVALUATION GRADE: EVALUATION: (for lab instructor use only) Exercises (50%): Prog’g Problems (50%): Lab Performance (10%): Attendance (10%): LABORATORY 3B 3A Bit Arithmetic Manipulation Instructions Instructions I. REQUIREMENTS: 1. 2. Do the following exercises using the different programming tools. Attach source code hard copy of programming problems solutions. II. COMPONENTS TO BE BORROWED PC power cords (2) Keyboard (1) Mouse (1) III. A PROCEDURE: 1. Run the DEBUG or Emu8086 program 2. Assemble the given program written on the table. 3. Run the above program in step mode (using TRACE commands) and examine the effects on the flag bits. Write your observation by completing the table below: Instruction AX Register Content CX DX Flag Register IP Prior to execution MOV AX, 1832H MOV CX, 342FH MOV DX, 56BAH ADD AX, CX SUB AX, DX MUL CL DIV DL IV. A PROGRAMMING PROBLEMS: 1. Write an assembly program will calculate the given arithmetic expression. The final result must be stored at AX. AX= (1234h + 1000h – 0FFFh)*000Ch/000Ah 2. Write an assembly program that will add the data located at DS:0000 to DS:0009 and DS:000A to DS:0013. Store the sum at location DS:0014 to DS:0022. Address DS:0000 01 02 03 04 05 06 07 08 09 0A DS:000A 0B 0C 0D 0E 0F 10 11 12 13 14 DS:0014 0C 0E 10 12 14 16 18 1A 1C 1E 3. Write an assembly program that will add two BCD numbers. Example: AL = BL = AL = jtio 15h 15h 30h 2 LABORATORY 3C Program Control Instructions III. B PROCEDURE: 1. Run the DEBUG or Emu8086 program 2. Assemble the given program MOV AX, 1832H MOV DX, 342FH MOV CX, 56BAH AND AX, CX XOR CX, DX MOV CL, 4H ROR DX, CL 3. Run the above program in step mode (using TRACE commands) and examine the effects on the flag bits. Write your observation by completing the table below: Instruction AX Register Content CX DX Flag Register IP Prior to execution 1. MOV AX, 1832H 2. MOV DX, 342FH 3. MOV CX, 56BAH 4. AND AX, CX 5. XOR CX, DX 6. MOV CL, 4H 7 ROR DX, CL IV. B PROGRAMMING PROBLEMS: 1. Write an assembly program that will clear the least significant nibble, set the most significant nibble and retain the values of the rest of the bits of AX. Example: Prior to execution: AX = ABCDh After execution: AX = FBC0h 2. Write an assembly program that will simulate the given Boolean expression using assembly programming. AL = (AL∙ BL + AH∙ BH)’ xor (CH+(CL∙ DL)’ ∙ DH)’ 3. Write an assembly program that will check if the P (Parity bit) will result to PO (Parity Odd) or PE(Parity Even) using bit manipulation instructions. III.C PROCEDURE: jtio 3 1. Run the DEBUG or Emu8086 program 2. Assemble the given program START: MOV AX, 1832H MOV DX, 342FH AGAIN: CMP AL, DL JE END XOR AX, AX XOR DX, DX JMP AGAIN END: INT 3 3. Run the above program in step mode (using TRACE commands) and examine the effects on the flag bits. Write your observation by completing the table below: Instruction AX Register Content DX CS Flag Register IP Prior to execution 1. MOV AX, 1832H 2. MOV DX, 342FH 3. CMP AL, DL 4. JE END 5. XOR AX, AX 6. XOR DX, DX 7. JMP AGAIN 8. INT 3 IV. C PROGRAMMING PROBLEMS: 1. Write an assembly program that will determine if a number is positive, negative or zero. Example: Enter a number : -5 Enter a number : 15 Enter a number : 0 2. NEGATIVE POSITIVE ZERO Write an assembly program that will determine if determine if a word is a palindrome or not. Example: Enter a word: DAD Enter a word: MOM Enter a word: SON 3. PALINDROME PALINDROME NOT A PALINDROME Write an assembly program that will convert the given C program to assembly. C program: k = 0; for (i=0; i<10; i++) for (j=0; j<5; j++){ k=i+j; printf(“k=%d”, k); }//end of for jtio 4