2 Addition
2 Addition
rogram: (a) Set SP = 0D, (b) //9 Write a program to add 10 bytes of data and store the result in
ORG 0000H MOV A,#05H MOV B,#05H ADD A,B H: SJMP H END Put a different value in each of RAM locations 0D, 0C, 0B, 0A, 09 registers R2 and R3. The bytes are stored in the ROM space
and 08 (c) POP each stack location into registers R0 - R4. starting at 200H. The data would look as follows: MYDATA: DB 92,
34, 84, 129, ... Pick your own data. Notice that you must first bring
ORG 000H MOV SP,#0DH MOV 0DH,#10H MOV 0CH,#20H MOV
//2 SUBTRACTION the data from ROM space into the CPU's RAM, and then add them
0BH,#30H MOV 0AH,#40H MOV 09H,#50H MOV 08H,#60H POP 0
POP 1 POP 2 POP 3 POP 4 POP 5 HERE: SJMP HERE END together. Use a simulator to single step the program and examine
ORG 0000H MOV A,#05H MOV B,#04H SUB A,B H: SJMP H END
the data.
ORG 000H MOV DPTR, #200H MOV R0, #10H MOV R2, #00H MOV
//DIVISION //7 Write and assemble a program to load valuesinto each of R3, #00H LOOP: CLR A MOVC A, @A+DPTR ADD A, R2 JNC NEXT
registers R0 - R4 and then push each of these registers onto the INC R3 NEXT: INC DPTR MOV R2, A DJNZ R0, LOOP HERE: SJMP
ORG 0000H MOV A,#05H MOV B,#05H MUL AB H: SJMP H END
stack and pop them back. Single step the program, and examine HERE ORG 200H DB 22H, 43H, 23H, 34H, 31H, 77H, 91H, 33H,
the stack and the SP register after the execution of each 43H, 07H END
//4 Write and assemble a program to add the following data and instruction.
then use the simulator to examine the CY flag. 92H, 23H, 66H, ORG 0000H MOV R0, #10H MOV R1, #20H MOV R2, #30H MOV
87H, FSH R3, #40H MOV R4, #50H PUSH 0 PUSH 1 PUSH 2 PUSH 3 PUSH 4 //10 Write and assemble a program to toggle all the bits of P0, P1,
POP 4 POP 3 POP 2 POP 1 POP 0 END and P2 continuously by sending 55H and AAH to these ports. Put
ORG 0000H MOV A, #92H MOV R0, #23H ADD A, R0 JNC L1 INC a time delay between the "on" and "off" states. Then using the
R3 L1: ADD A, #66H JNC L2 INC R3 L2: ADD A, #87H JNC L3 INC simulator, single step through the program and examine the ports.
R3 L3: ADD A, #0F5H JNC L4 INC R3 L4: SJMP L4 END Do not single-step through the time delay calL
//8 Write a program to transfer a string of data from code space
starting at address 200H to RAM locations starting at 40H. The CODE ORG 0000H HERE: MOV P0, #55H MOV P1, #55H MOV P2,
//5 Write and assemble a program to load values into each of data is as shown below: 0200H: DB "VIT UNIVERSITY" Using the #55H ACALL DELAY MOV P0, #0AAH. MOV P1, #0AAH MOV P2,
registers R0 - R4 and then push each of these registers onto the simulator, single step through the program and examine the data #0AAH ACALL DELAY SJMP HERE DELAY: MOV R1, #04H BACK:
stack. Single step the program and examine the stack and the SP transfer and registers. MOV R2, #20H AGAIN: DJNZ R2, AGAIN DJNZ R1, BACK RET END
register after the execution of each instruction. ORG 0000H MOV DPTR, #0200H MOV R1, #0EH MOV R0, #40H
ORG 000H MOV R0,#30H MOV R1,#40H MOV R2,#50H MOV LOOP: CLR A MOVC A, @A+DPTR MOV @R0, A INC DPTR INC R0
DJNZ R1, LOOP HERE: SJMP HERE ORG 0200H DB "VIT //11 Get the Data from Port P1 and Send it to Port P2, Note: P1 as
R3,#60H MOV R4,#70H PUSH 0 PUSH 1 PUSH 2 PUSH 3 PUSH 4 input Port and P2 as Output Port
HERE: SJMP HERE END UNIVERSITY" END
MOV A, #0FFh MOV P1, A HERE: MOV A, P1 MOV P2, A SJMP HERE
END