You are on page 1of 7

Q.

1 A)

MOV DPTR,#0100H ; for using external memory using dptr (ADDRESS IS


X:0X1000H)
MOVX A,@DPTR ; moving first number to accumalator
MOV R0,A ; moving first number to register r0 of bank 0
INC DPTR ; increasing dptr
MOVX A,@DPTR ; moving second number to accumalator
ADD A,R0 ; adding both numbers
INC DPTR ; increasing dptr
MOVX @DPTR,A ; storing result to next memory location
MOV A,#00H ; clearing the accumalator
ADDC A,#00H ;adding carry to accumalator
INC DPTR ; increasing dptr
MOVX @DPTR,A ; storing carry to next locagtion
END
Q.1 B)

MOV DPTR,#0100H ; for using external memory using dptr (ADDRESS IS


X:0X1000H)
MOVX A,@DPTR ; moving first number to accumalator
MOV B,A ; moving first number to register B
INC DPTR ; increasing dptr
MOVX A,@DPTR ; moving second number to accumalator
MUL AB ; multiplying both numbers
INC DPTR ; increasing dptr
MOVX @DPTR,A ; storing result to next memory location
MOV A,#00H ; clearing the accumalator
ADDC A,#00H ;adding carry to accumalator
INC DPTR ; increasing dptr
MOVX @DPTR,A ; storing carry to next locagtion
END
Q.2

MOV DPTR,#0100H ; for using external memory using dptr (ADDRESS IS


X:0X1000H)
MOVX A,@DPTR ; moving first number to accumalator
MOV B,A ; moving first number to register B
DEC B ; decreasing B
INC DPTR ; increasing dptr
MOVX A,@DPTR ; moving second number to accumalator
MOV R0,A ; moving second number to register r0
SKIP: ADD A,R0 ; adding accumalator and r0 content
DJNZ B, SKIP ; going out of loop if b becomes zero
END
Q.3

MOV DPTR,#0100H ; for using external memory using dptr (ADDRESS IS


X:0X1000H)
MOVX A,@DPTR ; moving first number to accumalator
MOV R0,A ; moving second number to register r0
DEC R0 ; decreasing r0
SKIP: ADD A,R0 ; adding accumalator and r0 content
DJNZ R0,SKIP ; going out of loop if r0 becomes zero
END
Q.4

ORG 0000H
CLR A
loop: MOV DPTR,#SINE ; moving dptr to where my data table content is
MOV R1,#24 ; moving 24 to r1
LAB1:MOVC A,@A+DPTR ; takes value from look up table in the
accumalator
MOV P1,A ; output value in pin 1
CLR A ; Reseting the accumalator
INC DPTR ; increasing dptr
DJNZ R1,LAB1 ; jump to LAB1 if r1 is not zero
SJMP loop ; doing this task repeatadely

ORG 0300H
SINE:
DB
255,250,237,217,191,160,127,94,63,37,17,4,0,17,37,63,94,127,127,160,
191, 217,237,250,255
END
4 b)

ORG 0000H
CLR A
loop: MOV DPTR,#SQUARE ; moving dptr to where my data table content
is
MOV R1,#2 ; moving 2 to r1
LAB1:MOVC A,@A+DPTR ; takes value from look up table in the
accumalator
MOV P1,A ; output value in pin 1
CLR A ; Reseting the accumalator
INC DPTR ; increasing dptr
DJNZ R1,LAB1 ; jump to LAB1 if r1 is not zero
SJMP loop ; doing this task repeatadely

ORG 0300H
SQUARE:
DB 255,0,255
END

You might also like