Professional Documents
Culture Documents
Example
Pentium I/O port byte addressable bit addressable
Change one bit, you must access the entire 8 bits.
128B RAM, registers, I/O ports, etc. in SFR. SETB bit CLR bit CPL bit (1s complement) JB bit, target (Jump if bit =1) JNB bit, target (Jump if bit=0) JBC bit, target (Jump if bit =1, then clear)
Example
Q1: Create a square wave of 50% duty cycle on bit 0 of port 1.
x
JNB and JB
JNB and JB
Used to monitor a bit and make a decision depending on whether it is 0 or 1.
Q2: Assume bit P2.3 is an input and represents the condition of an oven. If it goes high, it means that the oven is hot. Monitor the bit continuously, whenever it goes high, send a high-to-low pulse to port P1.5 to turn on a buzzer.
Bit Addressable
Bit Addressable
Registers B, PSW, IP, IE, ACC, SCON, TCON, and etc
Q3: Write a program to see if the ACC contains an even number. If so, divide it by 2. If not, make it even and then divide by 2. Q4: Write a program to see if bits 0 and 5 of B are 1. If they are not, make them so and save it in R0. Q5: Write a program to save the ACC in R7 of Bank 2. Q6: There are no such instructions for OV. How would you write code to check OV? Q7: The status of bits P1.2 and P1.3 of port P1 must be saved before they are changed. Write a program to save the status of P1.2 in bit location 06 and the status of P1.3 in bit location 07.
5