In: Electrical Engineering
Answer :- Assembler directives in MCS_51 is also known as Pseudo Instructions. These instructions are used for giving direction to the assembler.
Example :- DB, EQU, ORG, END etc. These directives does not take machine cycles. This is same as #define macros in C programming.
/*****************************************************************************/
MOV R0, #00h ;R0 = 00
MOV DPTR, #0000h ;DPTR = 0000h
Loop1:
MOV DPH, #10h ;lower byte of DPTR i.e. DPL = 10h
MOVX A, @DPTR ;read the value from address in DPTR, keep it in A
MOV DPH, #25h ;higher byte of DPTR i.e. DPH = 25h
MOVX @DPTR, A ;write value in A to address in DPTR
INC DPTR ;DPTR = DPTR + 1
INC R0 ;R0 = R0 + 1
JNZ R0, Loop1 ;goto label Loop1 if R0 not zero
END
/********************************************************************************/
Frequency = 12 Mhz, T = 1/12 us .
Count value = delay / T = 0.05*12*1000000 = 600000 = 84 x 84 x 85,
nearly same as 600000, so the subroutine is-
Delay50ms: ;subroutine name
MOV R0, #84 ;R0 = 84
LoopOut:
MOV R1, #84 ;R1 = 84
MOV R2, #85 ;R2 = 85
AJMP LoopIn ;goto LoopIn
Redo:
DJNZ R0, LoopOut ;R0 = R0 – 1
AJMP SubEnd
LoopMid:
MOV R2, #85 ;R2 = 85
DJNZ R1, LoopIn ;R1 = R1 – 1 and if not zero goto LoopIn
AJMP Redo ;if R1 = 0, goto label LoopOut
LoopIn:
DJNZ R2, LoopIn
AJMP LooMid
SubEnd :
END