ScoopexUs
Testing bit 6 of the Amiga CIA port register traps execution in a continuous loop until active-low mouse input clears the signal and returns control to the assembler.
AI-assisted summary of Amiga Hardware Programming 1 - Use the Assembler and wait for left click — original source. Check the original for full context.
Source published:
Key ideas
- ASM-One provides an integrated Amiga development suite combining a source editor, debugger, and machine-code monitor driven primarily through rapid one- and two-letter commands. (0:01)
- Amiga left mouse button detection operates on active-low logic polled via bit 6 of the CIA-A port register. (1:04)
- A standard assemble-and-jump command executes the routine, returning directly to ASM-One with a full 68000 CPU register readout upon left-click detection. (1:04)
Detailed notes
## Background Published on YouTube by ScoopexUs on June 19, 2013, this tutorial is presented by Photon of the demo group Scoopex as an entry point into Amiga hardware programming. The video description provides download links on coppershade.org, advises viewers to configure WinUAE with cycle-exact chipset settings to accurately mimic real Amiga hardware, and mentions AsmTwo as a lightweight, compatible environment.
## TL;DR Photon introduces the ASM-One development suite, explaining its integrated source editor, machine monitor, and streamlined command-line interface. He guides viewers through writing a minimal assembly language program that polls the Amiga's CIA port register using a busy-wait loop. By explaining the active-low logic of bit 6, he demonstrates how the system continuously loops until the left mouse button is pressed. Upon execution and click detection, the program cleanly exits back to the environment, displaying a full diagnostic readout of the 68000 CPU registers.
## Atmosphere & style The presentation carries a calm, direct, and pragmatic demoscene aesthetic, favoring brisk command-line efficiency over complex graphical menus. Photon's delivery is composed and technical, giving the tutorial an authentic retro-computing feel rooted in low-level craftsmanship. Watching the video feels like looking over the shoulder of a seasoned hacker unlocking the fundamentals of bare-metal Amiga hardware in real time.
## Bulletin - [00:01](https://www.youtube.com/watch?v=p83QUZ1-P10&t=1s) ASM-One provides an integrated Amiga development suite combining a source editor, debugger, and machine-code monitor driven primarily through rapid one- and two-letter commands. - [01:04](https://www.youtube.com/watch?v=p83QUZ1-P10&t=64s) Amiga left mouse button detection operates on active-low logic polled via bit 6 of the CIA-A port register. - [01:04](https://www.youtube.com/watch?v=p83QUZ1-P10&t=64s) A standard assemble-and-jump command executes the routine, returning directly to ASM-One with a full 68000 CPU register readout upon left-click detection.
## Key takeaways - [00:01](https://www.youtube.com/watch?v=p83QUZ1-P10&t=1s) Photon introduces ASM-One as a self-contained and complete environment for Amiga hardware programming. - [00:01](https://www.youtube.com/watch?v=p83QUZ1-P10&t=1s) On startup, ASM-One prompts the user to allocate working memory for source code, project files, and included binary assets. - [00:01](https://www.youtube.com/watch?v=p83QUZ1-P10&t=1s) While top-level drop-down menus exist, keyboard-driven one- and two-letter commands provide faster navigation. - [00:01](https://www.youtube.com/watch?v=p83QUZ1-P10&t=1s) Pressing the Escape key toggles between the command-line prompt and the full-screen source code editor. - [01:04](https://www.youtube.com/watch?v=p83QUZ1-P10&t=64s) Reading the left mouse button requires polling bit 6 of the Amiga's CIA-A input/output port register. - [01:04](https://www.youtube.com/watch?v=p83QUZ1-P10&t=64s) The left mouse button operates on active-low logic: bit 6 is 1 when released and drops to 0 when pressed. - [01:04](https://www.youtube.com/watch?v=p83QUZ1-P10&t=64s) A minimal busy-wait loop continuously checks the bit and loops until a press drops execution down to a return instruction. - [01:04](https://www.youtube.com/watch?v=p83QUZ1-P10&t=64s) Executing the routine using the assemble-and-jump command locks execution in the loop until a mouse click occurs. - [01:04](https://www.youtube.com/watch?v=p83QUZ1-P10&t=64s) Returning from the user program dumps the full state of the 68000 CPU, including data registers D0–D7, address registers A0–A6, and the stack pointer A7.
## Detailed walkthrough ### [00:01](https://www.youtube.com/watch?v=p83QUZ1-P10&t=1s) Introduction to ASM-One and the Command Environment
Photon of the demo group Scoopex introduces a foundational Amiga hardware assembler programming tutorial using ASM-One. He highlights ASM-One as a self-contained and powerful suite for Amiga development, explaining, “What you see on the screen is ASM-One, which I find a very nice and complete development environment.” Upon launching, the software prompts the user to specify how much memory to allocate for working source code, included binary assets, and project files.
Once the memory size is entered, ASM-One presents a text command prompt. Although the software includes drop-down menus across the top, Photon opts to focus exclusively on the command-line interface, noting that the menus are self-explanatory and that the same operations can be executed faster using one- and two-letter commands. The integrated environment bundles together an editor, a debugger, and a machine-code monitor. Pressing the Escape key switches the display directly from the command prompt into the full-screen editor window where the assembly code is typed.
- **Environment components**: ASM-One integrates a source editor, interactive debugger, and machine monitor. - **Navigation**: Pressing the `Escape` key toggles entry into the code editor. - **Command structure**: All menu operations are mirrored at the command prompt by compact one- or two-letter commands.
---
[01:04](https://www.youtube.com/watch?v=p83QUZ1-P10&t=64s) Writing a Busy-Wait Loop for the Left Mouse Button
Inside the editor, Photon demonstrates how to construct a minimal busy-wait loop that continuously polls the left mouse button before exiting cleanly back to the assembler environment. Amiga hardware detects mouse clicks via its Complex Interface Adapter (CIA) input/output ports. Specifically, reading the left mouse button requires testing bit 6 of the CIA-A port register. Photon points out the inverted logic common to hardware signaling, explaining, “Like most input-output ports, the left mouse button input is active low.”
```mermaid flowchart TD accTitle: Left Mouse Button Polling Loop accDescr: Flowchart illustrating the active-low polling logic testing bit 6 of the CIA port register until a click is detected.
subgraph HardwareLoop ["Polling Sequence"] Start(["Label: Loop Start"]) --> TestBit["Test Bit 6 of CIA Port Register"] TestBit --> CheckState{"Bit 6 Low (0)?"} CheckState -- "No (Non-Zero / Released)" --> Start end CheckState -- "Yes (Zero / Pressed)" --> Return["RTS: Return to Assembler"] Return --> RegisterDump(["Display CPU Register Dump (D0-D7, A0-A7)"]) ```
Because bit 6 is active low, the bit remains high (non-zero) as long as the button remains unpressed; the code continually branches back to the start label. The moment the button is clicked, bit 6 clears to zero, allowing the execution to drop through the branch instruction and hit the return statement to exit back to the assembler.
To run the program, Photon issues the assemble-and-jump command targeting the first line of the source. The system appears to do nothing while trapped in the loop until the user clicks the left mouse button. Instantly upon clicking, the program terminates and ASM-One displays a diagnostic readout of the CPU state, including all data registers and address registers, specifically highlighting address register 7 (A7) as the user stack pointer. Photon concludes the lesson by previewing the following tutorial, where the loop will be expanded to manipulate a scan line across the display until the mouse button is clicked.
- **Hardware register target**: Bit 6 in the CIA input/output port register handles the primary mouse button. - **Active-low logic**: A non-zero value signifies an unpressed button, while zero indicates an active click. - **Debugger output**: Terminating back into ASM-One produces an immediate dump of the 68000 registers, including data registers (`D0`–`D7`), address registers (`A0`–`A6`), and the stack pointer / user stack pointer (`A7`).
## Notable quotes > [01:04](https://www.youtube.com/watch?v=p83QUZ1-P10&t=64s) Like most input-output ports, the left mouse button input is active low. — Photon
## Mentioned Amiga, ASM-One, AsmTwo, Complex Interface Adapter (CIA), Motorola 68000, Photon, Scoopex, WinUAE
## Video description These are the first steps - all you need to get (re?)started is at the dedicated site: http://coppershade.org/articles/More!/Downloads/ *NOTE* the Get Started with WinUAE link in the WinUAE box! Use the default Quickstart Config and check Chipset - Cycle-Exact to make the emulator behave like a real Amiga.
If you have a favorite Assembler, you should have no trouble following the series! I recently made AsmTwo specifically to provide a stable and small Asm-One version that will work out of the box on anyone's Amiga, or emulator.
"May the source be with you!" (c) Photon
[Source](https://www.youtube.com/watch?v=p83QUZ1-P10)