21bce3724 Da1
21bce3724 Da1
Code:
MOV A,#37H
MOV B,#24H
ADD A,B
MOV 40H,A
MOV A,#37H
MOV B,#24H
SUBB A,B
MOV 41H,A
MOV A,#37H
MOV B,#24H
MUL AB
MOV 42H,A
MOV 43H,B
MOV A,#37H
MOV B,#24H
DIV AB
MOV 44H,A
MOV 45H,B
END
Output:
AIM:
Write and assemble a program to add the following data and then use the
simulator to examine the PSW flags. 29H, 32H, 56H, 78H, 5FH.
o Add 32H to A.
o Add 56H to A.
o Add 78H to A.
o Add 5FH to A.
4. End Program:
o Enter an infinite loop to halt the program and allow examination of the PSW flags.
Code:
ORG 0000H
MOV A, #29H
ADD A, #32H
ADD A, #56H
ADD A, #78H
ADD A, #5FH
MOV 40H, A
SJMP $
END
Output
Verification:
AIM:
Write and assemble a program to load values into each of registers R0 - R4 and then push each of
these registers onto the stack. Single-step the program, and examine the stack and the SP register
after the execution of each instruction.
Code:
ORG 0000H
MOV R0,#25H
MOV R1,#35H
MOV R2,#45H
MOV R3,#55H
MOV R4,#65H
PUSH 0
PUSH 1
PUSH 2
PUSH 3
PUSH 4
END
Output:
AIM:
(b) Put a different value in each of RAM locations 0D, 0C, 0B, 0A, 09 and 08
• Pop the top value from the stack and store it in memory location 1.
• Pop the top value from the stack and store it in memory location 2.
• Pop the top value from the stack and store it in memory location 3.
• Pop the top value from the stack and store it in memory location 4.
Code:
ORG 0000H
MOV SP,#0DH
MOV 09H,#14H
MOV 08,#16H
POP 0
POP 1
POP 2
POP 3
POP 4
END
OUTPUT:
AIM:
Write a program to transfer a string of data from code space starting at address 300H to RAM
locations starting at 30H. The data is as shown below:
Algorithm:
Initialize:
• Set Data Pointer DPTR to the address 200H where the string is stored.
• Clear accumulator A.
• Read a byte of data from the code space (address pointed by DPTR), using MOVC, and store
it in A.
Code:
ORG 0000H
MOV A,#00H
MOV DPTR,#200H
MOV R1,#0EH
MOV R0,#40H
LOOP:CLR A
MOVC A,@A+DPTR
MOV @R0,A
INC DPTR
INC R0
DJNZ R1,LOOP
HERE:SJMP HERE
ORG 200H
DB "Dharansh Neema"
END
OUTPUT:
Verification:
AIM:
Write a program to add 10 bytes of data and store the result in registers R2 and R3. The bytes are
stored in the ROM space 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 the data from ROM space into the CPU's
RAM, and then add them together. Use a simulator to single-step the program and examine the data.
Algorithm:
Initialize:
• Clear accumulator A.
• Load data from the address pointed to by DPTR into A using MOVC.
Code:
ORG 000H
LOOP: CLR A
MOVC A,@A+DPTR
ADD A, R2
JNC NEXT
INC R3
ORG 200H
DB 22H,43H,23H,34H,31H,77H,91H,33H,43H,7H END
Output:
AIM:
Write a program to add 10 bytes of BCD data and store the result in R2 and R3. The bytes are stored
in ROM space starting at 300H. The data would look as follows: MYDATA: DB 92H, 34H, 84H, 29H ,... ;
pick your own data. Notice that you must first bring the data from ROM space into the CPU's RAM,
and then add them together. Use a simulator to single-step the program and examine the data.
Algorithm:
Initialize:
• Set Data Pointer DPTR to 300H (starting address of the data array).
• MOVC A, @A+DPTR: Load the byte of data from the address pointed to by DPTR into A.
• INC DPTR: Increment DPTR to point to the next byte in the data array.
• DJNZ R0, LOOP: Decrement R0 and repeat the loop until it reaches zero.
Data Storage:
LOOP: CLR A
MOVC A,@A+DPTR
ADD A, R2
DA A
JNC NEXT
INC R3
MOV R2, A
ORG 300H
DB 22H,43H,23H,34H,31H,18H,26H,13H,48H,10H
END
Output:
Verification: