; FIRST METHOD
ORG 0000H
END
; SECOND METHOD
ORG 0000H
MOV A, #8DH
MOV 30H, A
MOV 31H, A
MOV 32H, A
MOV 33H, A
MOV 34H, A
END
; THIRD METHOD
ORG 0000H
MOV SP, #30H
MOV 30H, #8DH
PUSH 30H
PUSH 30H
PUSH 30H
PUSH 30H
END
WRITE A PROGRAM WHICH DOUBLE THE NUMBER IN R2 AND PUT THE RESULT IN
REGISTER R3 (LSB) AND R4 (MSB).
ORG 0000H
END
DIVIDE THE DATA IN RAM LOCATION 1FH BY THE NUMBER 09H AND PLACE THE
QUOTIENT IN R4 AND REMAINDER IN R5.
ORG 0000H
MOV 1FH, #04H ; STORE SAMPLE DATA IN 1FH
MOV A, 1FH
MOV B, #09H
DIV AB
MOV R4,A
MOV R5, B
END
ORG 0000H
END
ORG 0000H
MOV A, 25H
ADD A, 26H
JNC NEXT
INC 30H
NEXT:
ADD A, 27H
MOV 31H,A
JNC STOP
INC 30H
STOP:
AJMP STOP
ORG 0000H
MOV DPTR, #1234H ;STORE SAMPLE DATA IN DPTR
PUSH DPL
PUSH DPH
RET
END
ORG 0000H
END
WRITE A PROGRAM THAT SWAP THE NIBBLES OF R0 AND R1 SO THAT THE LOW
NIBBLES OF R0 SWAPS WITH THE HIGH NIBBLES OF R1 AND HIGH NIBBLE OF R0
SWAPS WITH THE LOW NIBBLE OF R1.
ORG 0000H
MOV A,30H
SWAP A
MOV R1, A
MOV A, 31H
SWAP A
MOV R0, A
END
ORG 0000H
MOV R0, #00H
MAIN:
MOV DPL, R0
MOV DPH, #40H
MOVX A, @DPTR
CPL A
MOV 40H, A
ANL A, 40H
CPL A
MOV DPH, #60H
MOVX @DPTR, A
INC R0
CJNE R0, #0AH, MAIN
END
ORG 0000H
MOV DPTR, #0300H
MOV R1,#40H
MOV A,R0
SWAP A
ANL A,#0FH
ADD A, #30H
INC R1
MOV @R1, A
INC R1
INC DPTR
END
MAKE PROGRAM WHERE LOOPS RUN SO LED L1 IS "ON", WHEN SWITCH S1 IS PRESS
AND LED L2 IS "ON" WHEN SWITCH S2 IS PRESS.
ORG 0000H
SETB P3.0
SETB P3.1
END
INTERFACE ONE COMMON CATHODE TYPE SEVEN SEGMENT DISPLAY WITH PORT 1
AND DRAW THE NECESSARY HARDWARE DIAGRAM. THEN WRITE A PROGRAM
THAT DISPLAYS PATTERN 'E' FOR 1 SECOND AND OFF FOR 1 SECOND ALSO,
CONTINUOUSLY.
ORG 0000H
MAIN:
AJMP MAIN
END
ORG 0000H
MAIN:
JNB TF0, MAIN
MOV TL0, #18H
MOV TH0, #0FCH
CLR TF0
INC DPTR
MOV A, DPH
CJNE A, #02H, MAIN
CPL P1.0
MOV DPTR, #000CH
AJMP MAIN
END
WRITE A PROGRAM USING INTERRUPTS TO GENERATE A SQUARE WAVE OF 2KHZ
ON PIN P1.5. USE TIMER 0 AND MODE 1.
ORG 0000H
MOV TMOD,#01H
SETB TR0
END
ORG 0000H
MAIN:
MOV TMOD,#10H
ACALL DELAY
DELAY:
;MC =3+3R1+2R1R2
MOV R1, #0C8H ;R1=200, R2=11
L2: MOV R2, #0BH
L1: DJNZ R2, L1
DJNZ R1, L2
RET
END
ORG 0000H
AJMP MAIN ; 2000/1.2=1667,65536-1667=63869 (F97DH)
ORG 001BH
MOV TL1,#7DH
MOV TH1, #0F9H
RETI
MAIN: MOV IE, #88H
MOV TMOD,#10H
MOV TL1, #7DH
MOV TH1, #0F9H
SETB TR1
END
ORG 0000H
AJMP MAIN
END
ORG 0000H
AJMP MAIN ;ASSUME 12MHZ CRYSTAL FR.
;1/5KHZ=0.2MS
; 256-100 =156 (9CH)
ORG 000BH
CPL P2.1
RETI
END
ORG 0000H
AJMP MAIN
ORG 000BH
CPL P2.0
RETI
ORG 0013H
AJMP IN_EXT
MAIN:
MOV IE, #86H
MOV IP, #04H
MOV TMOD,#0AH
MOV TH0, #83H
SETB TR0
ORG 0000H
MOV TMOD,#20H
MOV SCON,#50H
MOV TH1,#0F4H
SETB TR1
MOV A, #'N'
ACALL SEND_PC
MOV A, #'G'
ACALL SEND_PC
MOV A, #'U'
ACALL SEND_PC
END
WRITE A PROGRAM WITH TWO ISRS FOR INT0 AND INT1 RESPECTIVELY
SATISFYING FOLLOWING CONDITIONS. WHEN THERE IS NO INTERRUPT, MAINLINE
PROGRAM SHOULD BLINK GREEN LED THROUGH PORT PIN P1.0 FOR 1 SECOND ON
AND 1 SCOND OFF CONTINUOUSLY. WHEN EDGE TRIGGER INTERRUPT WILL COME
AT INT0, GLOW RED LED THROUGH PORT PIN P1.1 FOR 1 SECOND, THEN TURN IT
OFF AND RETURN TO MAINLINE. WHEN EDGE TRIGGER INTERRUPT WILL COME AT
INT1, GLOW YELLOW LED THORUGH PORT PIN P1.2 FOR 1 SECOND, THEN TURN IT
OFF AND RETURN TO MAINLINE PROGRAM. DRAW NECESSARY HARDWARE.
ORG 0000H
AJMP MAIN
ORG 0013H
AJMP ISR_IN1
ISR_IN0:
SETB RED
ACALL DELAY
CLR RED
RETI
ISR_IN1:
SETB YELLOW
ACALL DELAY
CLR YELLOW
RETI
END
ORG 0000H
FIND_ROW:
MOV R0,#00H
JNB P3.0, FIND_COLUMN
MOV R0,#01H
JNB P3.1, FIND_COLUMN
MOV R0,#02H
JNB P3.2, FIND_COLUMN
MOV R0,#03H
JNB P3.3, FIND_COLUMN
AJMP FIND_ROW
FIND_COLUMN:
MOV P3, #0F0H
MOV R1,#00H
JNB P3.4, CALULATE_KEY
MOV R1,#01H
JNB P3.5, CALULATE_KEY
MOV R1,#02H
JNB P3.6, CALULATE_KEY
MOV R1,#03H
JNB P3.7, CALULATE_KEY
AJMP FIND_ROW
CALULATE_KEY:
MOV A, R0
RL A
RL A
ADD A, R1
ACALL CONVERT
MOV P2, A
AJMP FIND_ROW
CONVERT:
INC A
MOVC A, @A+PC
RET
DB 00111111B
DB 00000110B
DB 01011011B
DB 01001111B
DB 01100110B
DB 01101101B
DB 01111101B
DB 00000111B
DB 01111111B
DB 01101111B
DB 01110111B
DB 01111100B
DB 00111001B
DB 01011110B
DB 01111001B
DB 01110001B
END
ORG 0000H
MOV A, #3CH
ACALL COMNWRT
MOV A, #01H
ACALL COMNWRT
MOV A, #0EH
ACALL COMNWRT
MOV A, #06H
ACALL COMNWRT
MOV A, #84H
ACALL COMNWRT
MOV A, #'H'
ACALL DATAWRT
MOV A, #'E'
ACALL DATAWRT
MOV A, #'L'
ACALL DATAWRT
MOV A, #'L'
ACALL DATAWRT
MOV A, #'O'
ACALL DATAWRT
MOV A, #0C4H
ACALL COMNWRT
MOV A, #'I'
ACALL DATAWRT
MOV A, #'N'
ACALL DATAWRT
MOV A, #'D'
ACALL DATAWRT
MOV A, #'I'
ACALL DATAWRT
MOV A, #'A'
ACALL DATAWRT
MAIN:AJMP MAIN
COMNWRT:
ACALL READY
MOV P2, A
CLR P1.5 ;RS
CLR P1.6 ;R/W
SETB P1.7 ;E
NOP
NOP
NOP
NOP
CLR P1.7 ;E
RET
DATAWRT:
ACALL READY
MOV P2, A
SETB P1.5 ;RS
CLR P1.6 ;R/W
SETB P1.7 ;E
NOP
NOP
NOP
NOP
CLR P1.7 ;E
RET
READY:
SETB P2.7
CLR P1.5 ;RS
SETB P1.6 ;R/W
REPEAT: CLR P1.7 ;E
NOP
NOP
NOP
NOP
SETB P1.7 ;E
JB P2.7, REPEAT
CLR P1.7 ;E
RET
END