SEB
Set Bit
Bit Operations 740-specific

Sets a specified bit (0–7) of the Accumulator or a memory location to 1. No flags are affected. This is one of the 740-Series unique instructions not found in the standard 6502.

⚙️

Operation

M[bit] ← 1      ; Set the specified bit of M (or A) to 1
                 ; All other bits of M are unaffected

Where bit is a constant 0–7 specified in the instruction. Bit 0 is the least significant bit, bit 7 is the most significant.

🚩

Processor Status Flags

N Unaffected
V Unaffected
T Unaffected
B Unaffected
D Unaffected
I Unaffected
Z Unaffected
C Unaffected

SEB does not modify any processor status flags — unlike arithmetic instructions, it is purely a bit-manipulation operation.

📋

Addressing Modes & Opcodes

Addressing ModeSyntaxOpcodeBytesCyclesNotes
Accumulator SEB b,A $0A + (b×16) 1 2 b = 0..7; sets bit b of A
Zero Page SEB b,zp $0B + (b×16) 2 5 b = 0..7; sets bit b of memory[$zp]
Opcode encoding: The bit number (0–7) is encoded into the high nibble of the opcode. For example, SEB 0,A = $0A, SEB 1,A = $1A, SEB 6,P0FR = $6B, etc.
💡

Examples

Example 1 — UART initialisation (from UART.txt sample)

; Configure P0 bit 6 as UART TXD output (from UART sample program)
P0    = $F6    ; Port 0 data register
P0FR  = $F5    ; Port 0 function register
UACON = $E6    ; UART control register

SEB 6,P0          ; Set P0-6 high (MARKING state on TXD line)
SEB 6,P0FR        ; Set P0-6 function = TXD mode (UART output)
SEB 7,UACON       ; Enable RXD
SEB 6,UACON       ; Enable TXD

Example 2 — Set a flag byte in zero page

; Set bit 7 of the system flags byte to indicate a BREAK condition
SYS_FLAGS = $0A
        SEB 7,SYS_FLAGS  ; SYS_FLAGS bit 7 = 1 (break set)

Example 3 — Set bit in Accumulator

; Ensure bit 0 of A is set before writing to UART control
        LDA UACON         ; Read current UART control register
        SEB 0,A           ; Set bit 0 (8-bit character mode)
        STA UACON         ; Write back
📝

Notes & Tips

  • SEB is a read-modify-write operation on memory: it reads the byte, ORs in the bit mask, and writes it back. On I/O registers this may trigger read-side effects — check the peripheral's datasheet.
  • The companion instruction to SEB is CLB (Clear Bit). Together they allow efficient manipulation of individual bits in I/O ports without needing AND/ORA sequences.
  • SEB and CLB replace the common 6502 pattern of LDA port / ORA #mask / STA port with a single instruction, saving 4–5 bytes and several cycles.
  • The 740 monitor program uses CLB / SEB pairs extensively to configure the UART, port directions, and function registers at startup. See Monitor Disassembly.
  • Unlike TSB (Test and Set Bit), SEB does not modify any flags.
← ROR (Rotate Right) Instruction Index CLB (Clear Bit) →