From RoadsideThoughts ...
A Bit of Vectrex History
Mine Storm
Fortress of
Dark Tower

Vectrex Programmer's Guide

Links to Additional Contents

Project Breaker and the 6502 Vectrex

Hardware Description

Memory Map

The 6522 Interface Adapter

Programmable Sound Generator

RUM Routines by Function

RUM Routines in Alphabetical Order

ACT09 Assembler

The Development Environment

Some Programming Considerations

Below are a few programming notes that might help when reading through these pages:

  • The address of the instruction that is being executed is located in the program counter (also called the 'PC' register). The contents of the program counter are incremented, byte-by-byte, as instructions are read. Keep in mind that instructions can consist of one or more bytes, depending on function and addressing modes.
  • When a subroutine is invoked with either a 'JSR' or 'BSR' call, the address of the next instruction is pushed onto the stack and then the address of the first byte of the subroutine is entered into the program counter - execution continues within the subroutine. When the subroutine is done, you will find that an 'RTS' instruction will be used to exit the subroutine. The 'RTS' instruction will pop 2 bytes from the stack and load those bytes into the program counter. Execution will continue with the instruction after the calling 'JSR' or 'BSR'.

    The 6809 has an unusual feature: Multiple general purpose registers can be pushed onto the stack with just a single instrunction - with other processors, there is usually a PUSH instruction for each register to be pushed. The 6809 also permits multiple registers to be popped (or pulled) with a single instruction. The most interesting feature of these instructions is that it permits the program counter ('PC') to be pushed and popped like any other register.

    For example:

    SUBR       PUSH       A  
      PUSH   B  
      PUSH   X  
      PULL   X  
      PULL   B  
      PULL   A  

    can be
    written as
    SUBR       PSHS       A,B,X  
      PULS   A,B,X  

    or a little more
    SUBR       PSHS       A,B,X  
      PULS   A,B,X,PC  

    As you look through the code, you'll see a mix where either an 'RTS' or a 'PULS' instruction has been used to exit a subroutine. Generally speaking, what drives the choice is whether any registers where pushed onto the stack when the subroutine was entered.

    Just one more thought on this subject: You'll notice in the above example that the pull order is the reverse of the push order - the stack is a last-in/first-out structure. When using the 6809 'PSHS' and 'PULS' instructions, the push/pull order is inherent to the instruction. Just make sure that your pushes and pulls match before pulling the program counter.
  • Instructions can take a varying amount of time (or cycles) to execute. Execution time can be short and of fixed duration like when loading a register and unpredictably long when performing a multiply. Normally, the amount of time to execute a section of code doesn't matter too much (as long as it's not excessive). With the Vectrex, there are areas of code where the time of execution is crucial - right down to the number of cycles that it takes. Truly, a couple of cycles too long or too short can have a noticeable impact on what appears on the screen.

    Some situations might require an exact cycle count. While always needing attention to detail, this type of code can be difficult to accomplish because conditional instructions (like 'BNE' or 'BCS') will require additional cycles if the condition is true. Getting the right number of cycles can result in some peculiar looking code.


Sitemap Privacy
of Use


Please keep in mind that we can not guarantee the accuracy or timeliness of the information on this website, so use with care. We encourage you to double-check the information that is critical to you.

If you've found an error or have additional information that you would like to share, please don't hesitate to write. Click here to contact us.

Copyright 2016
All Rights Reserved
This page was last modified: 12 Jan 2017
By John Hall