Bumbershoot Software发布了一篇ZX Spectrum计算机系统的技术教程,重点讲解如何使用汇编语言控制该系统的文本显示、图形字符和输入处理[1]。
该教程详细阐述了ZX Spectrum 48K系统的内存布局——系统ROM占据$0000-$3FFF,图形RAM为$4000-$5AFF,其余空间为RAM[1]。文中介绍了机器代码与BASIC共存的方式,通过CLEAR命令限制BASIC内存占用,使用USR函数调用机器代码子程序,并采用RANDOMIZE USR实现程序入口[1]。系统变量可通过IY寄存器(始终为$5C3A)访问,包括TVFLAG、ATTR-T、ATTR-P、MASK-T、MASK-P、P-FLAGS和BORDERCR等关键变量[1]。
文本输出通过RST $10指令调用ROM例程实现,控制码$10-$17对应INK、PAPER、FLASH、BRIGHT、INVERSE、OVER、AT、TAB等命令[1]。用户定义图形(UDG)范围为$90-$A4,其指针存储于IY+65,可通过LDIR指令加载字符数据[1]。键盘输入处理通过中断处理器更新LAST-K(IY-50)和FLAGS bit 5,直接I/O操作使用IN/OUT指令[1]。教程还涉及Kempston摇杆读取,其端口为$1F,返回值中各比特对应不同方向和射击按键[1]。文中通过具体代码示例展示了横幅显示程序的构建方法,机器代码版本相比BASIC原始版本体积显著缩减[1]。
Bumbershoot Software has published a technical tutorial on assembly language programming for the ZX Spectrum computer system, focusing on text display control, custom graphics, and input handling.[1] The guide explores how machine code and BASIC can coexist on the system, providing developers with detailed information on memory layout, ROM interfaces, and practical code examples for building display programs.[1]
The tutorial covers the ZX Spectrum 48K memory architecture, with system ROM occupying addresses $0000-$3FFF, graphics RAM from $4000-$5AFF, and the remainder reserved for general RAM.[1] Text output is accomplished through the RST $10 instruction to call ROM routines, with control codes $10-$17 corresponding to commands such as INK, PAPER, FLASH, BRIGHT, INVERSE, OVER, AT, and TAB.[1] System variables are accessed via the IY register, which is fixed at $5C3A and holds pointers to flags like TVFLAG, ATTR-T, ATTR-P, MASK-T, MASK-P, P-FLAGS, and BORDERCR.[1] The BASIC language provides the CLEAR command to constrain memory allocation, the USR function to invoke machine code subroutines, and RANDOMIZE USR to establish program entry points.[1]
The guide also addresses custom graphics implementation and input processing. User-defined graphics occupy the range $90-$A4 in the character set, with their pointer stored at IY+65, and can be loaded using the LDIR instruction.[1] Keyboard input updates are handled by interrupt handlers that modify LAST-K at IY-50 and set FLAGS bit 5, while direct I/O uses IN and OUT instructions.[1] For joystick control, the Kempston interface reads port $1F, with individual bits in the return value representing directions and fire button state.[1] Machine code implementations of sample programs achieve significant size reductions compared to their original BASIC versions.[1]