Escolar Documentos
Profissional Documentos
Cultura Documentos
Embedded Systems
Modes
Güray YILMAZ
Yrd.Doç.Dr.
İstanbul Kültür Üniversitesi
Can load information into any registers, including 16-bit DPTR register
DPTR can also be accessed as two 8-bit registers, the high byte DPH
ORG 200H
MYDATA: DB “Turkiye”
* Bit-addressable
Solution:
Solution:
CLR A ;A=0
MOV R1, #60H ;load pointer. R1=60H
MOV R7, #16 ;load counter, R7=16
AGAIN: MOV @R1, A ;clear RAM R1 points to
INC R1 ;increment R1 pointer
DJNZ R7, AGAIN ;loop until counter=zero
Solution:
MOV R0, #35H ;source pointer
MOV R1, #60H ;destination pointer
MOV R3, #10 ;counter
BACK: MOV A, @R0 ;get a byte from source
MOV @R1, A ;copy it to destination
INC R0 ;increment source pointer
INC R1 ;increment destination pointer
DJNZ R3, BACK ;keep doing for ten bytes
Example 5-8
Write a program to get the x value from P1
and send x2 to P2, continuously
(assume 0<x<9)
SETB P1.7
MOV C, P1.7
MOV 05, C ; MOV 05, P1.7 is illegal
Solution:
CLR PSW.3
SETB PSW.4
MOV R7, A
Solution:
JB PSW.2, TARGET ;jump if OV=1
Solution:
MOV A, 37H ;load RAM 37H into ACC
JNB A.0, YES ;if D0 of ACC 0? If so jump
INC A ;it’s odd, make it even
YES: MOV P2, A ;send it to P2
Solution:
CLR 06 ;clear bit addr. 06
CLR 07 ;clear bit addr. 07
JNB P1.2, OVER ;check P1.2, if 0 then jump
SETB 06 ;if P1.2=1,set bit 06 to 1
OVER: JNB P1.3,NEXT ;check P1.3, if 0 then jump
SETB 07 ;if P1.3=1,set bit 07 to 1
NEXT: ...
Example 5-22
A switch is connected to pin P1.7 and an LED to pin P2.0. Write a program
to get the status of the switch and send it to the LED.