/* Original constant-path sampled position-window controller.
 * GPIO4=below, GPIO5=above; GPIO2/3 request positive/negative correction.
 * RAM+0 records sampled flags, RAM+4 the commanded mask. Contradictory or
 * clear flags command zero. This is not a calibrated motion/safety controller. */
    .option norvc
    .option norelax
    .section .text.start,"ax",@progbits
    .globl _start
    .type _start,@function
_start:
    lui x5, 0x40000
    addi x6, zero, 12
    sw x6, 8(x5)
    lui x7, 0x20000
sample:
    lw x10, 0(x5)
    srli x10, x10, 4
    andi x10, x10, 3
    addi x11, x10, -1
    sltiu x11, x11, 1
    addi x12, x10, -2
    sltiu x12, x12, 1
    slli x11, x11, 2
    slli x12, x12, 3
    or x12, x12, x11
    sw x12, 4(x5)
    sw x10, 0(x7)
    sw x12, 4(x7)
    jal zero, sample
    .size _start, .-_start
    .section .note.GNU-stack,"",@progbits
