User’s Manual
47
The privileged instructions to manipulate the IP register are listed below.
IPSET 0 ; shift IP left and set priority 00 in bits 1,0
IPSET 1
IPSET 2
IPSET 3
IPRES ; rotate IP right 2 bits, restoring previous priority
RETI ; pops IP from stack and then pops return address
POP IP ; pop IP register from stack
3.5.4 Critical Sections
Certain library routines may need to disable interrupts during a critical section of code.
Generally these routines are only legal to call if the processor priority is either 0 or 1. A
priority higher than this implies custom hand-coded assembly routines that do not call
general-purpose libraries. The following code can be used to disable priority 1 interrupts.
IPSET 1 ; save previous priority and set priority to 1
....critical section...
IPRES ; restore previous priority
This code is safe if it is known that the code in the critical section does not have an embed-
ded critical section. If this code is nested, there is the danger of overflowing the IP register.
A different version that can be nested is the following.
PUSH IP
IPSET 1 ; save previous priority and set priority to 1
....critical section...
POP IP ; restore previous priority
The following instructions are also privileged.
LD A,xpc
LD xpc,a
BIT B,(HL)
3.5.5 Semaphores Using Bit B,(HL)
The
bit B,(HL)
instruction is privileged to allow the construction of a semaphore by the
following code.
BIT B,(HL) ; test a bit in the byte at (HL)
SET B,(HL) ; make sure bit set, does not affect flag
; if zero flag set the semaphore belongs to us;
; otherwise someone else has it
A semaphore is used to gain control of a resource that can only belong to one task or pro-
gram at a time. This is done by testing a bit to see if it is on, in which case someone else is
using the resource, otherwise setting the bit to indicate ownership of the resource. No
interrupt can be allowed between the test of the bit and the setting of the bit as this might
allow two different program to both think they own the resource.
Содержание Rabbit 2000
Страница 2: ...Rabbit 3000 Microprocessor User s Manual 019 0108 040731 O ...
Страница 9: ...Rabbit 3000 Microprocessor ...
Страница 29: ...20 Rabbit 3000 Microprocessor ...
Страница 64: ...User s Manual 55 5 PIN ASSIGNMENTS AND FUNCTIONS ...
Страница 79: ...70 Rabbit 3000 Microprocessor ...
Страница 80: ...User s Manual 71 6 RABBIT INTERNAL I O REGISTERS ...
Страница 123: ...114 Rabbit 3000 Microprocessor ...
Страница 137: ...128 Rabbit 3000 Microprocessor ...
Страница 157: ...148 Rabbit 3000 Microprocessor ...
Страница 207: ...198 Rabbit 3000 Microprocessor ...
Страница 249: ...240 Rabbit 3000 Microprocessor ...
Страница 255: ...246 Rabbit 3000 Microprocessor ...
Страница 277: ...268 Rabbit 3000 Microprocessor ...
Страница 343: ...334 Rabbit 3000 Microprocessor ...
Страница 345: ......