0% found this document useful (0 votes)
183 views21 pages

Task - 1 Basic Assembly Language Programs

The document describes a program that: 1. Loads 5 bytes of data from code space starting at address 300H, which contains the author's mobile number. 2. Adds the bytes together and stores the sum in RAM location 50H. 3. Stores the carry bit from the addition in RAM location 60H. 4. The program is executed successfully, with the sum stored at 50H and carry bit at 60H.

Uploaded by

prajjwal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
183 views21 pages

Task - 1 Basic Assembly Language Programs

The document describes a program that: 1. Loads 5 bytes of data from code space starting at address 300H, which contains the author's mobile number. 2. Adds the bytes together and stores the sum in RAM location 50H. 3. Stores the carry bit from the addition in RAM location 60H. 4. The program is executed successfully, with the sum stored at 50H and carry bit at 60H.

Uploaded by

prajjwal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

5/9/21 19BEC0470

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.

QUESTION: 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.
PROGRAM:
ORG 000H
MOV R0,#01H
MOV R1,#07H
MOV R2,#09H
MOV R3,#05H
MOV R4,#03H
PUSH 0
PUSH 1
PUSH 2
PUSH 3
PUSH 4
END

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.

QUESTION: Write and assemble a program to:


(a) Set SP = 0D
(b) Put a different value in each of RAM locations 0D, 0C, 0B, 0A, 09, and 08, (c) POP each
stack location into registers R0 - R4.
Use the simulator to single-step and examine the registers, the stack, and the stack pointer.

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

QUETSION: Write a program to calculate y where y = x2 + 2x + 9. x is between 0 and 9 and


the look-up table for x2 is located at the address (code space) of 200H. Register R0 has the x,
and at the end of the program R2 should have y. Use the simulator to change the x value and
single-step through the program, examining the registers as you go.

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

LAB TASK QUESTION


L41-42: Write a program to find the Decimal sum of the 5 bytes of data from code space
starting at address 300H and store the Sum part of the result in to RAM Space of 50H and
Carry part of the results in to 60H. The data must be your Mobile number
Mobile number: 9353478350

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

You might also like