Task - 1 Basic Assembly Language Programs
Task - 1 Basic Assembly Language Programs
TASK -1
BASIC ASSEMBLY LANGUAGE PROGRAMS
Name: Prajjwal RT
Reg No: 19BEC0470
SLOT: L41-42
10/8/21 19BEC0470
QUESTION: Write and assemble a program to add the following data and then
use the simulator to examine the CY flag.
92H, 23H, 66H, 87H, F5H
PROGRAM:
ORG 0000H
MOV A,#92H
MOV B,#23H
ADD A,B
JNC L1
INC R0
L1: MOV B,A
MOV A,#66H
ADD A,B
JNC L3
INC R0
L2: MOV B,A
MOV A,#87H
ADD A,B
JNC L3
INC R0
L3: MOV B,A
MOV A,#0F5H
ADD A,B
JNC L4
INC R0
L4:
END
2
10/8/21 19BEC0470
RESULT:
3
10/8/21 19BEC0470
INFERENCE: The following program is executed successfully and the final output
displays the sum of all the data, which is equal to 297. 2 is stored in R0 while 97 is in A
register.
4
10/8/21 19BEC0470
RESULT:
5
10/8/21 19BEC0470
INFERENCE: The following program perform the push operation on the given data stack
successfully with location starting from 08H.
PROGRAM:
ORG 0000H
MOV SP,#0DH
MOV 0DH, #10H
MOV 0CH, #11H
MOV 0BH, #12H
MOV 0AH, #13H
MOV 09H,#14H
MOV 08,#16H
POP 0
POP 1
POP 2
POP 3
POP 4
END
6
10/8/21 19BEC0470
RESULT:
7
10/8/21 19BEC0470
INFERENCE: The following program perform the pop operation on the given data
successfully with location starting from 60H.
8
17/8/21 19BEC0470
QUESTION: Write a program to transfer a string of data from code space starting at address
200H to RAM locations inside the CPU starting at 40H. The data is as shown below:
MYDATA: DB VIT University
Using the simulator, single-step through the program and examine the data transfer and
registers.
PROGRAM:
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 'VIT UNIVERSITY'
END
RESULT:
17/8/21 19BEC0470
INFERENCE:
The given program is executed successfully with VIT University printed from the 40H location
of RAM
QUESTION: Add the following subroutine to the program 1, single-step through the
subroutine and examine the RAM locations. After data has been transferred from ROM space
into RAM, the subroutine should copy the data from RAM locations starting at 40H to RAM
locations starting at 60H.
PROGRAM:
ORG 000H
MOV DPTR,#200H
MOV R0,#40H
MOV R1,#0EH
LOOP:CLR A
MOVC A,@A+DPTR
MOV @R0,A
INC R0
INC DPTR
DJNZ R1,LOOP
MOV R0,#40H
MOV R1,#60H
MOV R3,#0EH
LOOP2:CLR A
MOV A,@R0
MOV @R1,A
INC R0
INC R1
DJNZ R3,LOOP2
17/8/21 19BEC0470
HERE:SJMP HERE
ORG 200H
DB 'VIT UNIVERSITY'
END
RESULT:
17/8/21 19BEC0470
INFERENCE: The given data- VIT University is successfully printed from the RAM
location starting at 60H.
24/8/21 19BEC0470
QUETSION: Write a program to add two multi-byte u numbers together and store
the result in RAM locations 40H - 44H. The two multi-byte items are stored in the ROM space
starting at 120H and 150H. See the following example data.
ORG 120H
DATA_1: DB 54H,76H,65H,98H ;number 98657654H
ORG 150H
DATA_2: DB 93H,56H,77H,38H ;number 38775693H
PROGRAM CODE:
ORG 0000H
MOV DPTR,#120H
MOV R4,#05H;count
MOV R0,#40H;to store the result
MOV R3,#00H
LOOP: CLR A
MOVC A,@A+DPTR
MOV R3,A ; R3=54h
MOV A,#30H
MOVC A,@A+DPTR ; A=93H
ADD A,R3
DA A
MOV @R0,A
INC R0
INC DPTR
DJNZ R4,LOOP
HERE:SJMP HERE
ORG 120H
DB 54H,76H,65H,98H
ORG 150H
DB 93H,56H,97H,38H
24/8/21 19BEC0470
END
RESULT:
24/8/21 19BEC0470
PROGRAM CODE:
ORG 000H
MOV DPTR,#200H
MOV A,#03H;x=3
MOV R1,A ;R1=03
MOV R0,A;R0=03
ADDC A,R1; 2x
MOV R1,A ; R1<=2X
MOV A,R0 ;A=03
MOVC A,@A+DPTR;A=09
24/8/21 19BEC0470
ADDC A,#09H;X2+9
ADDC A,R1; X2+9+2X
MOV R2,A ; R2=Result
HERE: SJMP HERE
ORG 200H
DB 00H,01H,04H,09H,10H,19H,24H,31H,40H,51H
END
RESULT:
24/8/21 19BEC0470
QUETSION: Write a program to convert Hex to Decimal, and then to ASCII. For
example, if the hex data is FBH, which is equal to 251 in decimal, after conversion we will
have 32H, 35H, and 31H. Place the ASCII result in RAM locations starting at 40H. Using a
simulator, single-step the program and examine the data.
PROGRAM CODE:
ORG 0000H
MOV A,#0FBH
MOV R0,#40H
LOOP:MOV B,#10
DIV AB
XCH A,B; we are collecting the reminder
ADD A,#30H; For ASCII Conversion we have to add 30
MOV @R0,A
XCH A,B ; Taking the quo in A reg
INC R0
JNZ LOOP
END
24/8/21 19BEC0470
RESULT:
5/9/21 19BEC0470
PROGRAM CODE:
ORG 0300h
Num1: DB 93
Num2: DB 53
Num3: DB 47
Num4: DB 83
Num5: DB 50
ORG 00h
MOV A,#00h
MOV R1,#05h
MOV DPTR,#300h
LOOP: MOVC A,@A+DPTR
ADD A,R0
MOV R0,A
MOV A,PSW
ANL A,#60H
MOV R2,#07H
Rotate: RR A
DJNZ R2,Rotate
MOV 60H,A
MOV A,#00H
INC DPTR
DJNZ R1,LOOP
MOV 50H,R0
5/9/21 19BEC0470
END
RESULT:
5/9/21 19BEC0470
INFERENCE: The program is executed successfully with the sum of 5 bytes of data
stored in 50H while the carry part stored in 60H