Year 12

AQA A level Computer Science [P1] Monitoring Control BitManipulation Notes

Monitoring & Control Systems
+ Bit Manipulation

— Computer Science · AS Level (9618) · Paper 1 · Hardware & Topic 4.3 —
★ Exam Tip: This used to be an A2 / Paper 3 chapter in the old 9608 code. In 9618 the examiner moved it into Paper 1 — so expect questions! Paper 1 versions are easy; the Paper 3 ones are harder (good practice). Syllabus line: “show understanding of how bit manipulation can be used to monitor / control a device”. The two topics get mixed together in one question (sensor bytes, flags, set / test / clear bits).
Map of this chapter: ① Monitoring vs Control → ② Sensors & Actuators → ③ Sensor types → ④ Hardware devices → ⑤ “How will the system help achieve…?” answer → ⑥ Feedback → ⑦ Byte / flag question → ⑧ Binary shifting (logical, cyclic, arithmetic) → ⑨ Bitwise OR · AND · XOR → ⑩ Past-paper practice → ⑪ Cheat-sheet (sections 1–14 below)

1. Monitoring vs Control System

Q: What is the difference between a monitoring and a control system? (learn these 3 points — they are the mark scheme)

  1. Monitoring only gathers information, but a control system also performs action.
  2. Output in a control system can affect the input.
  3. There is no feedback in a monitoring system, but a control system relies on feedback.

Why automate? Old way: the farmer walked out and checked soil quality & water level himself. Now sensors do it and the system can even act by itself — no human needs to be physically present.

Sir’s analogy (babysitter):
Monitoring = a sitter who only reports “he ate… he’s crying… he fell” (like a camera). Control = a sitter you told “if he cries, do this; at this time, give that” → reports and acts.
Farm: water-level sensor only tells you the level, you walk over and add water = monitoring. If level < 50 L the sprinkler switches on automatically = control. Dam: level too high → gates open automatically = control; only telling you the level = monitoring.
MONITORING systemSensorADCProcessorDisplay / record(or warning light)only gathers & shows data — nothing is changed, NO feedbackCONTROL systemSensorADCProcessorDAC*ActuatorFEEDBACK: output changes the environment → sensor reads the new value*DAC only when the actuator needs an analogue signal (e.g. alarm) — not always
control = monitoring + actuator + feedback loop

Matching exercise from class (Control or Monitoring?)

Car speed displayAeroplane autopilotRoller coasterRecording the rainfallRobot loadingControlMonitoring
lines drawn as on the board: car speed + rainfall → Monitoring; autopilot, roller coaster, robot → Control
SystemTypeReason (sir’s words)
Car speed displayMonitoringonly displays / shows the speed
Aeroplane autopilotControlan action is being performed (steers) based on readings
Roller coasterControlspeed, weight etc. checked and then acted on (brakes / speed)
Recording the rainfallMonitoringonly recording / measuring — nothing done with it
Robot loadingControl“loading” is an action (a verb) caused by the readings
Common mistake: Don’t just hunt for a verb! “Recording the rainfall” has a verb but no action on the environment → monitoring. Real test: after taking readings, is an action performed that changes things? Yes → control. Only record / measure / display → monitoring.
Trap — alarms & lights are still MONITORING: Water level drops below 50 and an alarm sounds / a red light comes on when oxygen falls → that is only an indication (like a display). The environment is not being controlled. If a human then walks over and opens the dam gate, the human is doing the controlling. So alarm / light / screen = monitoring system.

2. Sensors & Actuators

Sensors

  • A physical quantity (temperature, speed, moisture, oxygen level, pH, pressure…) is measured by sensors.
  • Sensor = hardware that measures; the name tells you the job (sound sensor → sound).
  • Sensors give analogue data (physical waves / values) and only act like an input — on their own they do nothing.
  • They use an ADC = Analogue to Digital Converter.

Actuators

  • An actuator is a component of a machine that is responsible for moving and controlling a mechanism.
  • It receives a signal from the processor and adjusts a controlling device (switches it on / off, like a motor).
  • Sometimes uses a DAC = Digital to Analogue Converter (e.g. to sound an alarm) — not always; a motor can run on the digital signal.
Processor(0s and 1s)ACTUATOR(motor / switch)DEVICE(sprinkler / door)signalon / off✓ the actuator DOES the switching✗ the sprinkler / gates / button is NOT the actuator
actuator = the motor that opens the gates, not the gates
Sir’s point (very exam-relevant): Switching an AC on? The button is a separate hardware device. The actuator is whatever turns the button on/off. Dam: the doors ≠ actuator; the motor that opens them = actuator. Think “the machine doing the work”. Sensor = monitors values, actuator = controls hardware. Actuators have no job in a monitoring system.
Why ADC? Computers only understand digital (0 and 1). So the sensor never sends data straight to the processor — it sends it to the ADC first, then ADC → processor. Sensors only read; the processor does the comparing against the range.

3. Types of Sensors & Their Uses

★ Exam Tip: The syllabus lists only 4 sensors — don’t trust that. The examiner’s mark schemes (esp. Paper 3) use many more. Learn all of these, and always add an example use. Examiners also give a scenario (cake factory, milk plant, swimming pool, lift, greenhouse…) and ask which sensors fit.
SensorWhat it doesExample use
Temperaturemeasures & records temperature in a particular surroundinggreenhouse, zoo, storage, homes
Pressuredetects pressure and measures it (force on a particular area)lifts; factories (filling packages) — not pressure cooker!
Infra-reddetects motionalarm / security system, automatic doors
Sounddetects soundhotels — footsteps turn lights on; new-born baby’s room
pHmeasures the pH value (acidity of soil)farming / greenhouse
Moisturemeasures the level of moisturein soil
Humiditymeasures the level of moisture in airgreenhouse air, weather
Precipitationmeasures the amount of rainfall (in mm, not counting drops)weather station

Also mentioned: water-level sensor (dam, farm tank), oxygen-level sensor, speed, TV-remote receiver (the little red window = infra-red). Moisture ≠ humidity: moisture → soil, humidity → air.

4. Hardware Devices in a Monitoring / Control System

Question style: “Name and describe the hardware devices used…”. Write the device + its job (+ example).

DeviceJob
ADCto convert analogue signals from a sensor to a digital value that can be recorded / understood (0s and 1s)
Actuatore.g. turns the sprinkler on or off
Sensorsmeasure a physical quantity
Processorprocesses the value recorded by the sensor — e.g. checks whether the water level has reached the range; also stores values, drives a warning or display
Cableto transfer signals between the devices
Visible warning device(lights, alarm) to give warnings to humans
Remember: Sensor, mouse, keyboard or monitor alone are useless — they only work once connected to a processor.

Is the processor control or monitoring? Both! It measures, stores, compares, runs warning systems or displays. You may add extra detail with an example (water-level range reached or not) — examiners accept it.

5. “How will a monitoring & control system help achieve …?”

The examiner gives any scenario (soil management, water level, cake / milk factory, swimming pool, lift…) and there is no fixed mark scheme — you must construct your own answer by judging the scenario. Sir gave a template of points; don’t copy it word-for-word or memorise it — adapt it to the scenario, with as much detail as you can.

  1. Name of sensors used — list all the sensors needed (e.g. lift → pressure sensor).
  2. What will those sensors do — say what each one measures, for every sensor you listed.
  3. These sensors will read the value and send it to the ADC (not the processor).
  4. ADC will convert the analogue signal into digital signals (so the computer understands).
  5. ADC sends the data to the microprocessor (processor also fine).
  6. If monitoring system: add one line — readings will be displayed. Done!
  7. If control system: microprocessor compares the values with the range provided (e.g. water must not go below 50 L).
  8. Microprocessor sends signal to actuator.
  9. Purpose of the actuator (e.g. switches on the sprinkler / opens the gate to lower the water level).
  10. If more tasks needed → send signal to another actuator and give its purpose too (repeat for every actuator).
Name thesensorsWhat eachsensor doesSensors read→ send to ADCADC convertsanalogue→digitalADC → micro-processorMONITORING → readings are displayedCONTROL → compare with rangesignal to ACTUATOR → purposemore tasks? → another actuator + purpose
the answer skeleton — same first 5 steps for every scenario
Example (illustration only — a greenhouse, my own wording):
Sensors: temperature, moisture, pH. Temperature sensor measures air temperature, moisture sensor measures soil moisture, pH sensor measures soil acidity. They read the values and send them to the ADC, which converts the analogue signals to digital and sends them to the microprocessor. (Control) The microprocessor compares each value with the stored range; if temperature is too high it signals the heater/vent actuator to switch the fan on to cool the greenhouse; if the soil is too dry it signals the sprinkler actuator to switch on the water. (Monitoring) instead: “values are displayed on screen”.

6. Concept of Feedback

Feedback is the data which is collected from sensors and is analysed or used as input.

Don’t be confused by the everyday word (a customer review). Feedback is given so you can improve: if I only wanted to be told and never change anything, that isn’t feedback. That’s exactly why there is no feedback in a monitoring system — it only watches; a control system relies on it because its output alters the next input.

Q: What is the importance of feedback?

  • To ensure that the system operates within the given criteria (e.g. water level must stay ≤ 50 L — sensor data tells it if it’s OK or an action is needed).
  • By enabling system output to affect subsequent system inputs — i.e. the upcoming instructions depend on feedback (sir: if you tell me “don’t use pink”, my next slide changes).
  • Thus enabling the system to automatically adjust conditions.

Q: What is the use of feedback?

Careful: “Importance” and “use” are two different questions. Use depends on the scenario — fill in the blanks for the one given.
  1. Sensor will continually measure ____ (the quantity in the scenario, e.g. temperature).
  2. Readings are sent to the processor and it compares the reading with the preset value (a value already stored in the processor, e.g. 50 L).
  3. If readings are out of range then the actuator will do ____ (e.g. switch on the AC / a heater to maintain temperature).
  4. Feedback will ensure that the readings remain in range.
SensorProcessorActuatorEnvironment(temp, level…)FEEDBACK: new reading goes back in as the next inputcompare with preset range
control loop — the output (actuator) changes what the sensor reads next

7. Bytes & Flags — the Museum Question

Paper 3 style question that shows how each bit of a byte can act as a flag. Sir’s warning: make sure data-representation (denary ↔ binary) is solid — then it is easy.

Paper 3 (museum) · (c)sensor bytes

Temperature recorded in 7 rooms. Each recording = two successive bytes:

  • Byte 1 = temperature reading as an unsigned integer (do NOT use 2’s complement) — “unsigned” = positive number only.
  • Byte 2: room shown by setting one bit to 1 (bits 7→1 ↔ room 7→1; e.g. room 7 = bit 7 set). Bit 0 = flag: starts at 0, becomes 1 when the reading has been processed.

Words: set = make the bit 1; clear = make it 0. A flag has two states (on/off, red/green, true/false). “Processed” isn’t defined (stored? displayed? alarm?) — you only need: flag = 1 ⇒ processed.

Byte 1 — temperatureByte 2 — room (bits 7…1) + flag (bit 0)1011001112864321684210010000176543210128 + 32 + 16 + 2 + 1 = 179bit 5 = 1 ⇒ room 5bit 0 = 1 ⇒ processed
part (i): 10110011 and 00100001 (weights written under each bit)
Paper 3 (museum) · (c)(i)[3 marks]

Analyse the data in the two bytes. One mark each:

  • The temperature reading is 179
  • The reading is of room number 5 (only bit 5 is 1)
  • and the reading has been processed (flag, bit 0 = 1)
1110111012864321684210001000076543210room 4 ⇒ bit 4 = 1; not processed ⇒ bit 0 = 0238 = 128+64+32+8+4+2
Paper 3 (museum) · (c)(ii)[2 marks]

Reading 238 from room 4, not yet processed — fill both bytes.

238 − 128 = 110 → 128 ✓110 − 64 = 46 → 64 ✓, 46 − 32 = 14 → 32 ✓14 − 8 = 6 → 8 ✓, 6 = 4 + 2 → 4 ✓ 2 ✓ (16 would overshoot ✗, 1 ✗)Byte 1 = 11101110Byte 2 = 00010000 (flag 0 as “not processed”)
Exam Tip: Re-read the wording each time (“has not yet been processed”) — the flag value depends on the question’s story. Bit 0 is the right-most bit; numbering runs 0 1 2 … 7 from the right.

8. Binary Shifting

Binary = the bits in a byte. Shifting = moving all the bits left or right inside the register (we work on one byte). Three types — all on the syllabus:

Logical
Cyclic
Arithmetic
Different from bitwise ops! Shifting moves the whole byte left/right. Bitwise OR/AND/XOR (section 9) apply a logic gate bit by bit. Not the same concept — shifting is related to assembly language (that’s why it’s not in Chapter 1).

① Logical shifting

LOGICAL: bits shifted out of the register are dropped (“bit drop”) and the empty places are replaced by zeros.

logical shift LEFT once1011011001101100↖ dropped← 0 addedLSL #1
1011 0110 → 0110 1100
logical shift RIGHT twice1011011000101101bit drop ✗✗LSR #200 added
1011 0110 → 0010 1101
Remember: Bits fall off the end you are moving towards; the empty places appear on the opposite end. Start moving from the end the question names (left → start at the left corner).

Method (fast): shift n places = chop n bits off that side, copy the rest as it is, then add n zeros on the other side.

Assembly language: LSL and LSR

OpcodeOperandExplanation
LSL#nBits in ACC are shifted logically n places to the left (zeros enter on the right).
LSR#nBits in ACC are shifted logically n places to the right (zeros enter on the left).

“Once” → #1, “twice” → #2, “thrice” → #3. e.g. logical shift left once = LSL #1, right twice = LSR #2.

9618 recent · (c)(i)[1 mark] LSL

ACC = 00110101. Contents after LSL #2?

Drop the 2 left bits (00), copy 110101, add 00 on the right.

Answer: 1 1 0 1 0 1 0 0

9618 recent · (c)(ii)[1 mark] “identify the mathematical operation”

ACC = 00110101. What does LSR #3 do mathematically?

Sir skipped this part (board left blank) and said to learn it: shifting left = multiplication, shifting right = division (values get bigger / smaller).

LSR #3 = integer division by 2³ = 8  (LSL #n = ×2n, LSR #n = ÷2n)

② Cyclic shifting

Cyclic: no bits are lost during a shift. Bits shifted out of one end of the register are inserted at the other end of the register.

Syllabus note: the syllabus doesn’t print the assembly codes, but you must know what cyclic and arithmetic shifts are — so learn them (codes CSL #n, CSR #n, ASL #n, ASR #n).

cyclic shift LEFT twice — CSL #21011011011011010take the first 2 bits out → shift rest left → put them in at the right
1011 0110 → 1101 1010
cyclic shift RIGHT 3 times — CSR #31011011011010110last 3 bits (110) go to the front
1011 0110 → 1101 0110
Sir’s box trick: Draw a box around the n bits that will leave → lift the box out → shift all other bits → drop the box into the empty places (for left: the 2 removed bits go in in the same order: 1 then 0). Bits are never lost.

③ Arithmetic shifting

Arithmetic: the sign bit stays the same and the rest is shifted same as logical shifting (bits dropped, zeros come in). Sign bit = the first (left-most) bit: 1 = negative, 0 = positive (Chapter 1, 2’s complement).

arithmetic shift LEFT once — ASL #11011011011101100signsign stays • next bit (0) drops • rest moves left • 0 enters
1011 0110 → 1110 1100
arithmetic shift RIGHT once — ASR #11011011010011011signsign stays • last bit (0) drops • 0 enters beside sign
1011 0110 → 1001 1011
Note: Sir’s rule (and the board): ignore the sign bit, shift the other 7 bits logically, zero fills the gap — so ASR #1 of 10110110 = 10011011. Some textbooks copy the sign bit into the gap instead (→ 11011011). Follow the rule you were taught / the mark scheme. Exam may ask ASR #2 etc.; sir expects at most 2–3 shifts (more and no bits survive!).
ShiftBits shifted outEmpty placesSign bit
Logical (LSL / LSR)lost (dropped)zerosnot special
Cyclic (CSL / CSR)re-inserted at other endthe bits that leftnot special
Arithmetic (ASL / ASR)lost (dropped)zerosstays as it is

9. Bit Manipulation in a Monitoring / Control System

In a monitoring and control system, each bit in a register or memory location can be used as a flag and would need to be tested (compared), set (made 1) or cleared (made 0) separately.

I want to…usewhy (sir’s basic guide — not a rigid rule)
check / test if a bit has been setANDAND with a mask, then compare (CMP)
set a bit (make it 1)OROR can only ever push a bit towards 1
clear a bit that has been set (make 0)XORsame bits → 0 (also inverts)

Assembly language notation

  • Binary: capital B then the bits — e.g. B10000001
  • Denary: hash # — e.g. #32
  • Hexadecimal: ampersand & — e.g. &F8 = 1111 1000 (two groups of 4 bits: F = 1111, 8 = 1000)
  • No # before a number = it’s an address (memory location), e.g. OR 101 uses the byte stored at address 101.

Bit numbers: 0 1 2 … 7 from the right. Weights: bit 0 = 1, bit 1 = 2, bit 2 = 4, bit 3 = 8, bit 4 = 16, bit 5 = 32, bit 6 = 64, bit 7 = 128. Byte = 8 bits (don’t mix up byte and bit — “byte 2” vs “bit 2”).

10110110765432101286432168421← bit numbers on top, weights below

10. Bitwise OR — used to SET a bit

ABA OR B
000
011
101
111

logic: any 1 → 1

OpcodeOperandExplanation
ORnBitwise OR operation of the contents of ACC with the operand

operand n can be B… binary, # denary, & hex, or an address.

How it works: “OR #64” means: change 64 to binary (put 1 under the 64-place, rest 0 → 01000000), then OR it bit by bit with ACC.

10110110ACC01000000OR #6411110110=← 64 = 01000000← bit 6 was 0 → now 1 (SET)
10110110 OR 01000000 = 11110110
Note: Whenever you want to set a bit (a single bit), use OR. Why? If that bit is already 1 and you OR it with 1 it stays 1 (nothing breaks); if it was 0 it becomes 1; and OR with 0 leaves any bit unchanged — so all the other bits are safe. Understand it, don’t memorise it — tricky questions follow.

Set “alarm 3” without changing other bits

Byte stored at memory location 200: bit 0 = flag, bit 1 = A1 (alarm 1), bit 2 = A2, bit 3 = A3. Question: set Alarm 3 to ON without changing the other bits.

  1. Write 1 below alarm 3 and the rest should be 0 → new binary value 00001000 = #8 (1,2,4,8).
  2. OR that new binary value with the byte.
10110110A3A2A1flag200 (mem. loc.)00001000OR #810111110new value← new binary value
bit 3 (A3) goes 0 → 1; every other bit stays exactly as it was

Q: write it in assembly language (load → change → store back):

LDD 200  // direct addressing: go to address 200, load that byte into ACCOR #8  // sets bit 3 (A3)STO 200  // store the updated value back at 200

Both A3 and A2 on? Put 1 under both → 00001100 = OR #12. If one of them is already 1 that’s fine — it simply stays 1. (Careful: bit 4 is #16, not #8 — count 1, 2, 4, 8, 16.)

Paper 3 · (d) fish tanks[3 marks] set a bit

A hardware device in each tank is on/off depending on a bit in memory location 6753. If bit 4 = 1 the device in fish tank 4 is on. Write assembly instructions to set bit 4 of location 6753 to 1 without changing any other bits.

Bit 4 → 1,2,4,8,16 → mask 00010000. “Set” ⇒ OR (whenever you want to set a bit we use OR).

LDD 6753OR #16STO 6753
Paper 3 · (c)(ii) fish tank (−2)[2 marks] — teacher only wrote the mask

Reading of −2 from fish tank 4; “complete the bytes to show the values after it has been processed”.

On the board sir only wrote the bit-4 mask 00010000 → OR #16 and left the boxes empty. Working (mine, assuming the same two-byte layout as the museum question): negative number ⇒ 2’s complement (2 = 00000010 → flip 11111101 → +1 → 11111110); tank 4 ⇒ bit 4 = 1; processed ⇒ flag bit 0 = 1 ⇒ Byte 2 = 00010001.

11. Bitwise AND — used to CHECK (test) a bit

ABA AND B
000
010
100
111

logic: any 0 → 0

OpcodeOperandExplanation
ANDnBitwise AND operation of the contents of ACC with the operand
10110110ACC00100000AND #3200100000=← 32 = 00100000← result = 00100000 = the operand!
10110110 AND 00100000 = 00100000
Note: If there was a 1 in the place of 32 (bit 5 of ACC), the answer after AND would be the same as the operand. If that bit were 0 the answer would be all zeros. AND with 1 keeps a bit; AND with 0 forces it to 0.
Why this lets you test an unknown byte: The computer cannot “see” the bits (think with the computer’s brain, not yours — give it every step). Put a 1 under the bit you want to check and AND: if the result equals the mask that bit was 1, otherwise it was 0. Always put 1 under the bit when checking.

Checking a bit — 3 steps

  1. Put 1 below the bit you want to check (rest 0) → new binary value.
  2. AND that new value with the value in ACC.
  3. Compare (CMP) with the new value you created.

Use of AND in monitoring & control: AND is used to check if the bit was set (1) or 0; if you want to check, the AND is followed by a CMP instruction (usually, not always).

Location 423, check: does bit 4 contain 1? → AND #16 then CMP #160001000076543210IF 1 : 42300010000AND #1600010000result= #16 exact same → CMP #16 TRUE ⇒ bit was 10000000076543210IF 0 : 42300010000AND #1600000000result≠ #16 → CMP #16 FALSE ⇒ bit was 0
both cases: the bit is 1 → result = mask; the bit is 0 → result = 0

Q: Write this in assembly language code:

LDD 423  // load the byte at 423 into ACCAND #16  // keep only bit 4CMP #16  // TRUE ⇒ bit 4 was 1 ; FALSE ⇒ it was 0

Q: “but I can see it’s 1 — why check?” You can, the computer can’t. When the byte is given empty / unknown you test it this way.

Paper 3 · (d)(i)(ii) museum[4] + [2]

(i) ACC holds byte 1 from location 106 (LDD 106). Write the instruction to check whether the reading in byte 2 came from location 4.

Location 4 ⇒ bit 4 ⇒ 16. “Check” ⇒ AND. Only one line was asked so one instruction is enough; if the question gave another line you would also compare (CMP #16). Marks: opcode AND, the #, the number 16, whole instruction correct.

(i) AND #16

(ii) Set the flag (bit 0) of the byte in the accumulator to 1. Bit 0 → 1 (weight 1); “set” ⇒ OR.

(ii) OR #1

9618 recent · memory address 300[1] + [1] + [2]

Address 300 holds an unsigned binary integer (bits 7→0) = 0 1 1 0 0 1 1 0.

(i) Denary value: add the weights where there is a 1:

64 + 32 + 4 + 2 = 102

(ii) Test if bit number 2 in address 300 is 1 → bit 2 = 4 → AND #4 (then compare for the result).

9618 recent · address 300 (iii)[2 marks] — the tricky one

Set bits 4, 5, 6, 7 to 0, but keep bits 0–3 with their existing values.

Think as if you don’t know any value — your instruction must work whether each bit is 0 or 1.

  • OR ✗ — OR can never make a 1 into a 0 (even OR with 0 keeps a 1).
  • XOR ✗ — it flips bits: XOR with 1 turns a 0 into a 1; XOR with 0 leaves a 1 as 1. Doesn’t always give 0.
  • AND ✓ — AND with 0 always gives 0 (whatever the bit was); AND with 1 leaves a bit unchanged.
xxxxxxxx76543210unknown byte00001111mask: AND #150000xxxxresultupper 4 bits → 0 ; lower 4 bits (0–3) unchanged
00001111 = 8+4+2+1 = 15 ⇒ AND #15

Answer: AND #15  (1,1,1,1 under bits 0–3 keeps them; 0,0,0,0 under bits 4–7 clears them; 1+2+4+8 = 15.)

12. Bitwise XOR — used to CLEAR (or invert) bits

ABA XOR B
000
011
101
110

logic: same → 0, different → 1 (not binary addition!)

OpcodeOperandExplanation
XORnBitwise XOR operation of the contents of ACC with the operand

Note: used to clear or inverse the values (clear = make 0, set = make 1).

10110110ACC00010000XOR #1610100110=← only bit 4 flipped (1 → 0)
10110110 XOR 00010000 = 10100110

Clearing a bit — “Clear bit 5”

  1. Put 1 below the bit you want to clear (rest 0) → 00100000 = #32.
  2. Apply XOR with that new value.
1011011076543210ACC00100000XOR #3210010110=← bit 5 cleared; others same
10110110 XOR 00100000 = 10010110
Remember / caution: XOR with 1 flips a bit, so it clears bit 5 here only because bit 5 was already 1 (“clear a bit that has been set”). If it were 0 it would become 1! Sir: the same job can be done with AND (AND with a 0 under that bit, 1s elsewhere — e.g. AND #223 for bit 5), and XOR #255 (all 1s) inverts every bit of the byte.

Sir’s guide (OR set · AND check · XOR clear) is a helping rule when you’re stuck — think about each question’s logic.

13. Past-Paper Practice

Instruction set used in these questions (from the paper): LDM #n · LDD addr · STO addr · INC · CMP · JPN · JMP · IN · OUT · END · AND / OR / XOR #n or address · LSL / LSR #n — # = denary number, B = binary, no # = an address.

AddressData (main memory)
10000001111
10111110000
10201010101
10311111111
10400000000
9618 recent · table question[4 marks] new contents of ACC after each instruction

Write answers with a capital B (it’s a binary value).

Current ACCInstructionWorkingNew ACC
11111111OR 101101 is an address (no #): value 11110000; OR → any 1 gives 1B11111111
00000000XOR #1515 = 00001111 (8+4+2+1); different → 1, same → 0B00001111
10101010LSR #2drop last 2 bits (10), add 00 on the left: 00 101010B00101010
01010101AND 104104 is an address: all 0s; AND with 0 → 0B00000000

(Row 3: last digit of ACC is smudged on the board; 10101010 matches the answer.)

Full marks 4/4.

Paper 1 style · (a) & (b)[2] + [2] opcode 1 mark + operand 1 mark

ACC = 01100101. Write the bit-manipulation instruction (opcode + operand) that changes it to:

(a) 11111111  → every bit must become 1 ⇒ use OR with all 1s: OR #255 (also accepted: OR #154 or XOR #154 — 154 = 10011010 fills in exactly the 0-bits)

(b) 10011010  → this is every bit flipped (01100101 → 10011010) ⇒ XOR #255 (XOR with all 1s inverts the byte)

(a) check01100101OR 1111111111111111
(b) check01100101XOR 1111111110011010
Paper 1 style · (c)(i)–(iii)practice — sir left these for you to attempt

Register before = 01101101 each time. Table of instructions: AND #n, XOR #n, OR #n, LSL #n, LSR #n.

InstructionWorkingRegister after
AND #22 = 00000010; only bit 1 can survive and bit 1 of the register is 000000000
OR #88 = 00001000; bit 3 is already 1 so nothing changes01101101
LSL #4drop 0110, keep 1101, add 0000 on the right11010000

Answers worked by me (not on the board) — please check by doing them yourself first.

Next steps from sir: Revise AND, OR, XOR logic gates and do the assembly-language topical past papers first. Practise the compiled topical papers (Paper 3 ones are A2-level difficult — go through them once with logical thinking) plus the recent 9618 Paper 1 questions. Revise 2 minutes daily so it doesn’t fade.

14. Quick Recap — Full Chapter Cheat-Sheet

✓ Monitoring & Control
  • Monitoring: only gathers/shows info, no action, no feedback. Control: also performs action, output affects input, relies on feedback.
  • Alarm / light / display / recording = monitoring. Action that changes the environment (sprinkler, gates, autopilot, robot loading) = control.
  • Chain: Sensor → ADC → Processor (compare with range) → (DAC) → Actuator; sensor sends to ADC, not straight to the processor.
  • Actuator = the thing that switches the device (motor), not the device. ADC analogue→digital, DAC digital→analogue.
  • Sensors: temperature · pressure · infra-red (motion) · sound · pH · moisture (soil) · humidity (air) · precipitation (rainfall). Always give an example.
  • Hardware: ADC, actuator, sensors, processor, cable (transfer signals), visible warning device (warn humans).
  • Feedback = sensor data analysed / used as input. Importance: operate within criteria · output affects next input (“upcoming instruction”) · auto-adjust. Use: sensor measures ___ → processor compares with preset → actuator does ___ if out of range → readings stay in range.
✓ Bits & Bytes
  • Bit numbers 0–7 from the right; weights 1·2·4·8·16·32·64·128. Set = 1, clear = 0. Flag bit = on/off (bit 0 = “processed”). “Unsigned” ⇒ no 2’s complement.
  • Shifts: logical (drop, zeros in) · cyclic (nothing lost, wraps round) · arithmetic (sign bit stays, rest like logical). LSL #n = ×2n, LSR #n = ÷2n.
  • Notation: B10000001 binary · #32 denary · &F8 hex · no symbol = address.
JobGateRecipe (one 1 under the bit, rest 0 → mask)Code example
SET a bit (→1)OROR with mask; other bits untouchedLDD 200 · OR #8 · STO 200
TEST a bitANDAND with mask, then CMP with the mask: equal ⇒ bit was 1LDD 423 · AND #16 · CMP #16
CLEAR bits (→0)ANDAND with 0s under bits to clear, 1s elsewhereAND #15 (clear bits 4–7)
CLEAR a set bit / INVERTXORXOR with mask flips that bit; XOR #255 inverts allXOR #32 · XOR #255
ABORANDXOR
00000
01101
10101
11110
★ Exam checklist: Name every sensor + what it measures + an example · sensors → ADC → processor · compare with range → actuator → purpose · check the byte numbering (0 on the right) · # = denary, B = binary · load–change–store: LDD → OR/AND/XOR → STO · imagine you don’t know the byte’s values and make the instruction work for 0 and 1.