Introducing Buffalo: Part 3

Several utilities subroutines are provided along with Buffalo.  Most of these subroutines are simple and are somehow related to serial input/output communications.  A jump table in ROM just before the list of interrupt vectors provides easy access to these subroutines.  It's better to not directly access the Buffalo routines themselves.  As improvements are made, the actual addresses may change.

To make use of a utility program from a program that you are writing, use a jump to subroutine (JSR) instruction, using the appropriate jump table target address.  To call a utility subroutine from the Buffalo command line, use the CALL command.  The following is a partial list of Buffalo utility subroutines.  The column heading "Address" is the jump table target address used to make the corresponding call.

A Partial Listing of Utility Subroutines
 
Address Label   Description
$FF7C - WARMST - Warmstart, skip past "BUFFALO..." message, go to '>'
$FFA9 - INIT - Initialize the I/O device
$FFB2 - OUTLHL - Convert left nibble in A register to ASCII and output
to serial communications port
$FFB5 - OUTRHL - Convert right nibble in A register to ASCII and output
to serial communications port
$FFB8 - OUTA - Output the ASCII character in the A register
$FFBB - OUT1BY - Convert binary byte in memory that X register points at
to ASCII and output to serial communications port. 
The X register is incremented by one.
$FFBE - OUT1BS - Convert binary byte in memory that X register points at
to ASCII characters followed by a space and output to
serial communications port.  The X register is
incremented by one.
$FFC1 - OUT2BS - Convert binary byte in memory that X register points at
to ASCII characters followed by a space and output to
serial communications port.  The X register is
incremented by two.
$FFC4 - OUTCRL - Output a carriage return character followed by a
line feed character
$FFC7 - OUTSTR - Output a string of ASCII characters starting with that
pointed to by the X register and terminated with the
end of transmission character ($04)
$FFCA - OUTST0 - The same as OUTSTRG except that a leading carriage
return, line feed character pair are not produced
$FFCD - INCHAR - Wait for and echo an ASCII character, the received
character is returned in the A register
$FFD0 - VECINT - The initializes the pseudovectors in RAM, called in
initialization. A user program invoked by the jump
to $B600 feature in Buffalo should call this.

Calling a Utility Subroutine from Buffalo

As a first example, first use the RM command to put the ASCII code for capital letter A ($41) into the A register.  Next, use the CALL command to call the OUTA utility subroutine.  Note that when Buffalo returns from a call it always lists the contents of each register. 
 >rm a
 P-FFFF Y-FFFF X-FFFF A-FF B-FF C-D0 S-0041
 A-FF 41

 >call ffb8
A
 P-FFB8 Y-FFFF X-FFFF A-41 B-FF C-D0 S-0041
 >

Calling a Utility Subroutine from a Program

This second example illustrates use of the utility subroutines from a program that you write.  A program like this should be familiar to you if you have ever programmed using the 'C' high level language. 
* Hello.asm
* A traditional introductory program, use the
* Buffalo GO 140 command to run this.
EXIT:     EQU     $FF7C
OUTCRLF:  EQU     $FFC4
OUTSTRG:  EQU     $FFC7

          ORG     $100           ; Data origin
Messg:    FCC     'Hello World!' ; Message
          FCB     $04            ; End Of Tx

          ORG     $140           ; Program origin
Start:    LDX     #Messg         ; Message pointer
          JSR     OUTSTRG        ; Send message
          JSR     OUTCRLF        ; Send CR,LF
          JMP     EXIT           ; Program exit

Follow these steps:

>go 140

Hello World!

>

Destructive Calls

In making a call to a Buffalo routine, its generally a good idea to assume that the CPU register values are not preserved.  There are some exceptions; calls to OUT1BY, OUT1BS, and OUT2BS each increment the X register by one, one, and two, respectively.  For integers, its probably also a good idea to set aside a temporary memory location to hold a value while making a Buffalo call.  For various odd reasons, its possible for the temprary value to be destroyed while being is written to the system output. 

Copyright Notice

This tutorial page was written for EE332, the Introduction to Microprocessors course offered by the Electrical Engineering Department in the College of Engineering at the University of Hartford.  Copyright is dated October 18, 2001 and is reserved by the author, Jonathan Hill.  Permission is granted to make copies of this document for educational use as-is, provided that this statement remains attached.  Please forward corrections for my review along with suggestions.  Credits will be added as improvements are made to this document.
Original Author: Jonathan Hill (jmhill@mail.hartford.edu)
Last Modified: Thu Apr 4 01:25:15 2002