To save code, the subroutine entry address (minus 1) is pushed onto the stack, high-order byte first. A 6502 RTS (return from subroutine) is used to pop the address off the stack and into the 6502 PC (after incrementing by 1). The net result is that the desired subroutine is reached by executing a subroutine return instruction!

Opcode Subroutines:

-------------------

The register op routines make use of the 6502 'zero page indexed by X' and 'indexed by X direct' addressing modes to access the specified registers and indirect data. The 'result' of most register ops is left in the specified register and can be sensed by subsequent branch instructions, since the register specification is saved in the high- order byte of R14. This specification is changed to indicate R0 (ACC) for ADD and SUB instructions and R13 for the CPR (compare) instruction.

Normally the high-order R14 byte holds the 'prior result register' index times 2 to account for the 2-byte SWEET 16 registers and the LSB is zero. If ADD, SUB, or CPR instructions generate carries, then this index is incremented, setting the LSB.

The SET instruction increments the PC twice, picking up data bytes in the specified register. In accordance with 6502 convention, the low-order data byte precedes the high-order byte.

Most SWEET 16 non-register ops are relative branches. The corresponding subroutines determine whether or not the 'prior result' meets the specified branch condition and if so, update the SWEET 16 PC by adding the displacement value (-128 to +127 bytes).

The RTN op restores the 6502 register contents, pops the subroutine return stack and jumps indirect through the SWEET 16 PC. This transfers control to the 6502 at the instruction immediately following the

RTN instruction.

The BK op actually executes a 6502 break instruction (BRK), transferring control to the interrupt handler.

Any number of subroutine levels may be implemented within SWEET 16 code via the BS (Branch to Subroutine) and RS (Return from Subroutine) instructions. The user must initialize and otherwise not disturb R12 if the SWEET 16 subroutine capability is used since it is utilized as the automatic return stack pointer.

Memory Allocation:

------------------

The only storage that must be allocated for SWEET 16 variables are 32 consecutive locations in page zero for the SWEET 16 registers, four locations to save the 6502 register contents, and a few levels of the 6502 subroutine return address stack. if you don't need to preserve the 6502 register contents, delete the SAVE and RESTORE subroutines and the corresponding subroutine calls. This will free the four page zero locations ASAV, XSAV, YSAV, and PSAV.

Page 54
Image 54
Apple II manual

II specifications

The Apple II, launched in April 1977, was one of the first highly successful mass-produced microcomputer products. It marked a significant leap in personal computing, setting standards for future developments in the industry. Created by Steve Wozniak and Steve Jobs, the Apple II differentiated itself with its user-friendly design, appealing aesthetics, and robust capabilities.

One of the standout features of the Apple II was its open architecture, which allowed users to expand and enhance the computer's functionality. This design enabled hundreds of third-party hardware and software developers to contribute to its ecosystem, resulting in an array of peripherals, including printers, modems, and storage devices. The Apple II utilized a MOS Technology 6502 microprocessor running at a clock speed of 1 MHz. Initially equipped with 4 KB of RAM, the machine could be expanded to 48 KB, accommodating more complex applications and programs.

The Apple II was also notable for its colorful graphics. It was one of the first computers to support color display, offering a 6-color palette with a resolution of 280x192 pixels in 16 colors when using its Color Graphics Card. This feature significantly enhanced the visual appeal of games and educational software developed for the platform, making computing more accessible and entertaining for various audiences.

Apple's commitment to user experience was evident in the design of the machine. It featured an integrated keyboard and a plastic case, which was both durable and visually appealing. The self-contained design included drive bays for floppy disk drives, allowing for quicker data access than traditional tape drives. It also supported audio output, enabling sound effects and music, a novelty at the time.

The introduction of the Apple DOS operating system further underscored the machine's capabilities. DOS streamlined file management and made it easier for users to navigate and manage their data. The combination of hardware and software positioned the Apple II as an educational tool and a gaming platform, fostering a vibrant software ecosystem.

The Apple II family continued to evolve, with variations like the Apple II+, IIe, and IIgs being introduced over the years. These iterations brought enhancements in memory, processing power, and graphics capabilities. The legacy of the Apple II endures, not only as a foundational product in personal computing but also as a symbol of innovation that paved the way for future advancements in technology. Its impact is still felt today, as it inspired countless developers and shaped the trajectory of the computer industry.