13911521 Micro Controller Programs

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View 13911521 Micro Controller Programs as PDF for free.

More details

  • Words: 329
  • Pages: 3
PROGRAMS OF MICROCONTROLLER 8051

1. BINARY IMAGE OF A 8-BIT NUMBER MOV R0,#2CH MOV Rl ,#08H MOV R3,#00H XRL A,A HERE: MOV A,R0 RLC A MOV R0,A MOV A,R3 RRC A MOV R3 ,A DJNZ R1 ,HERE END RESULT=R3

2. BINARY SEARCH MOV DPTR,#1OOOH MOV R0,#08H MOV Rl ,#00H XRL A,A THERE: MOVX A,@DPTR CJNE A,#2CH,HERE INC Rl HERE: INC DPTR DJNZ R0,THERE END OUTPUT : Rl

3. MAXIMA AND MINIMA MOV DPTR,#1000H MOV R1 ,#07H ACALL STORE INC DPTR BACK: XRLA,A MOVX A,@DPTR SUBB A,R0 JNC NMlN / JC NMAX ACALL STORE NMIN: INC DPTR / NMAX: INC DPTR DJNZ R1,BACK JMP ENDL ORG 18H STORE:MOVX A,@DPTR MOV R0,A RET ENDL: END

OUTPUT: R0 INPUT STARTING ADDRESS : 1000H

4. FINDING SQUARE ROOT MOV R0,#90H MOV R1,#00H LOOP: XRL A,A MOV A,R1 MOV B,R1 MUL AB SUBB A,R0 JZ ANS INC R1 AJMP LOOP ANS:END OUTPUT: R1 5. ADDITION OF FIRST 10 NATURAL NUMBERS MOV R0,#0AH XRL A,A LOOP:ADDC A,R0 DJNZ R0,LOOP MOV R1,A END OUTPUT :R1 6. ADDITION OF TWO 8-BIT NUMBERS: SUM CAN BE 8-BIT OR 16-BIT MOV DPTR,#0100H XRL A,A MOVX A,@DPTR MOV R0,A INC DPTR MOVX A,@DPTR ADDC A,R0 INC DPTR MOVX @DPTR,A JNC OK MOV A,#01H INC DPTR MOVX @DPTR,A SJMP ENDL OK: MOV A,#00H INC DPTR MOVX @DPTR,A ENDL:END OUTPUT: 0100H: 1ST NO. ADDRESS 0101H: 2ND NO. ADDRESS

7. DEMO OF PUSH AND POP OPERATIONS MOV SP, #5FH MOV R2, #25H MOV R1, #12H MOV R4, #0F3H PUSH 2 PUSH 1 PUSH 4 MOV R2, #00H MOV R1, #00H MOV R4, #00H POP 4 POP2 POP1 END

;make RAM location 60H,first stack location

8. TO FIND SQUARE OF A NUMBER TAKING INPUT AT P1 AND OUTPUT AT P2 ORG 0000H MOV DPTR,#300H MOV A,#0FFH MOV P1,A BACK:MOV A,P1 MOV A,@A+DPTR MOV P2,A SJMP BACK

;LOAD TABLE ADDRESS ;A=FF ;CONFIGURE P1 INPUT PORT ;GET X ;GET X SQAURE FROM TABLE ;ISSUE IT TO P2 ;KEEP DOING IT

ORG 300H XSQR_TABLE: DB 0,1,4,9,16,25,36,49,64,81 END

Related Documents