170 likes | 269 Vues
Enhance your embedded systems skill set to outperform competitors with Prolific Systems and Technologies Pvt Ltd. Learn about MOVC, DPTR, and more. Program implementations include finding square of numbers and arithmetic operations.
E N D
Embedded Systems Imbibing skill sets to beat the competition Prolific Systems and Technologies Pvt Ltd
; MOVC A,@A+DPTR ;----------------------------------------------------------- MOV A,#06 MOV DPTR,#DISP_LUT MOVC A,@A+DPTR MOV P0,A JMP $ DISP_LUT: ; -abcdefgd- DB 11111100b ;0 DB 01100000b ;1 DB 11011010b ;2 DB 11110010b ;3 DB 01100110b ;4 DB 10110110b ;5 DB 10111110b ;6 DB 11100000b ;7 DB 11111110b ;8 DB 11100110b ;9 Seven Segment Display dp Po 0 a g Po 1 f f b Po 2 8 0 5 1 e g Po 3 d Po 4 c Po 5 e c b Po 6 d a Po 7
; PROGRAM TO FIND SQUARE OF NO. ; MOVC A,@A+PC ;---------------------------------------------------------------- ORG 0000h MOV A,#05 CALL SQR JMP $ SQR: INC A MOVC A,@A+PC RET DB 00 DB 01 DB 04 DB 09 DB 16 DB 25 DB 36 DB 49 DB 64 DB 81
CJNE CJNE A, #05, CHK_GT ;-------------------------------------- ; A=5 MOV P0,#0FH JMP $ ;-------------------------------------- CHK_GT: JC IS_LESS ;-------------------------------------- ;A>5 MOV P0,#0FFH JMP $ ;-------------------------------------- A<5 IS_LESS: MOV P0,#00H JMP $ ;--------------------------- N A>5 Y PRINT A>5 N A<5 Y RET PRINT A=5 PRINT A<5 RET RET
CJNE A>5 N Y PRINT A<=5 PRINT A>5 CJNE A,#05+1, $+3 JNC IS_GT ;----------------------------------------- ;A<=5 MOV P0,#0FH JMP $ ;---------------------------------------- ;A>5 IS_GT: MOV P0,#0FFH JMP $ ;----------------------------------------
CJNE A<5 N Y PRINT A>=5 PRINT A<5 CJNE A,#05, $+3 JC IS_LESS ;----------------------------------------- ;A>=5 MOV P0,#0FH JMP $ ;---------------------------------------- ;A<5 IS_LESS: MOV P0,#00H JMP $ ;----------------------------------------
DJNZ EX. 1 MOV COUNT, #10 MOV A,#00H ;-------------------------------- L2: CALL DISP_A INC A DJNZ COUNT,L2 JMP $
DJNZ EX.2 Copy data from memory location 30h – 34h to memory location 40h--44h . MOV COUNT,#05H MOV R0,#30 MOV R1,#40 L1: MOV A,@R0 MOV @R1,A INC R0 INC R1 DJNZ COUNT,L1
DJNZ EX.3 Wait_5ms: Machine Cycle MOV COUNT1,#100d 1 LAB1: MOV COUNT2,#23d 1 DJNZ COUNT2,$ 2 DJNZ COUNT1,LAB1 2 RET 2
The inner most instruction:(djnz count2 $) 2*23*1.085=49.91microsec. The lab1 loop: 100*49.91microsec=4999microsec~4.9millisec Now considering overhead: (mov count2,#23d and djnz count1$) 3*100*1.085=325.25microsec So 4999+325.25=5324.25microsec~5.3millisec Plus 3*1.085=3.255:(mov count1,#100d and ret) Thus 5324.25+3.255=5327.50~5.3millisec
Thank You Shashidhar kalluri