#!/usr/bin/perl -s
# NCR 53c810 script assembler
# Sponsored by
# iX Multiuser Multitasking Magazine
#
# Copyright 1993, Drew Eckhardt
# Visionary Computing
# (Unix and Linux consulting and custom programming)
# drew@Colorado.EDU
# +1 (303) 786-7975
#
# Support for 53c710 (via -ncr7x0_family switch) added by Richard
# Hirst <richard@sleepie.demon.co.uk> - 15th March 1997
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# TolerANT and SCSI SCRIPTS are registered trademarks of NCR Corporation.
#
#
# Basically, I follow the NCR syntax documented in the NCR53c710
# Programmer's guide, with the new instructions, registers, etc.
# from the NCR53c810.
#
# Differences between this assembler and NCR's are that
# 1. PASS, REL (data, JUMPs work fine), and the option to start a new
# script, are unimplemented, since I didn't use them in my scripts.
#
# 2. I also emit a script_u.h file, which will undefine all of
# the A_*, E_*, etc. symbols defined in the script. This
# makes including multiple scripts in one program easier
#
# 3. This is a single pass assembler, which only emits
# .h files.
#
# XXX - set these with command line options
$debug = 0; # Print general debugging messages
$debug_external = 0; # Print external/forward reference messages
$list_in_array = 1; # Emit original SCRIPTS assembler in comments in
# script.h
#$prefix; # (set by perl -s)
# define all arrays having this prefix so we
# don't have name space collisions after
# assembling this file in different ways for
# different host adapters
# Constants
# Table of the SCSI phase encodings
%scsi_phases = (
'DATA_OUT', 0x00_00_00_00, 'DATA_IN', 0x01_00_00_00, 'CMD', 0x02_00_00_00,
'STATUS', 0x03_00_00_00, 'MSG_OUT', 0x06_00_00_00, 'MSG_IN', 0x07_00_00_00
);
# XXX - replace references to the *_810 constants with general constants
# assigned at compile time based on chip type.
# Table of operator encodings
# XXX - NCR53c710 only implements
# move (nop) = 0x00_00_00_00
# or = 0x02_00_00_00
# and = 0x04_00_00_00
# add = 0x06_00_00_00
if ($ncr7x0_family) {
%operators = (
'|', 0x02_00_00_00, 'OR', 0x02_00_00_00,
'&', 0x04_00_00_00, 'AND', 0x04_00_00_00,
'+', 0x06_00_00_00
);
}
else {
%operators = (
'SHL', 0x01_00_00_00,
'|', 0x02_00_00_00, 'OR', 0x02_00_00_00,
'XOR', 0x03_00_00_00,
'&', 0x04_00_00_00, 'AND', 0x04_00_00_00,
'SHR', 0x05_00_00_00,
# Note : low bit of the operator bit should be set for add with
# carry.
'+', 0x06_00_00_00
);
}
# Table of register addresses
if ($ncr7x0_family) {
%registers = (
'SCNTL0', 0, 'SCNTL1', 1, 'SDID', 2, 'SIEN', 3,
'SCID', 4, 'SXFER', 5, 'SODL', 6, 'SOCL', 7,
'SFBR', 8, 'SIDL', 9, 'SBDL', 10, 'SBCL', 11,
'DSTAT', 12, 'SSTAT0', 13, 'SSTAT1', 14, 'SSTAT2', 15,
'DSA0', 16, 'DSA1', 17, 'DSA2', 18, 'DSA3', 19,
'CTEST0', 20, 'CTEST1', 21, 'CTEST2', 22, 'CTEST3', 23,
'CTEST4', 24, 'CTEST5', 25, 'CTEST6', 26, 'CTEST7', 27,
'TEMP0', 28, 'TEMP1', 29, 'TEMP2', 30, 'TEMP3', 31,
'DFIFO', 32, 'ISTAT', 33, 'CTEST8', 34, 'LCRC', 35,
'DBC0', 36, 'DBC1', 37, 'DBC2', 38, 'DCMD', 39,
'DNAD0', 40, 'DNAD1', 41, 'DNAD2', 42, 'DNAD3', 43,
'DSP0', 44, 'DSP1', 45, 'DSP2', 46, 'DSP3', 47,
'DSPS0', 48, 'DSPS1', 49, 'DSPS2', 50, 'DSPS3', 51,
'SCRATCH0', 52, 'SCRATCH1', 53, 'SCRATCH2', 54, 'SCRATCH3', 55,
'DMODE', 56, 'DIEN', 57, 'DWT', 58, 'DCNTL', 59,
'ADDER0', 60, 'ADDER1', 61, 'ADDER2', 62, 'ADDER3', 63,
);
}
else {
%registers = (
'SCNTL0', 0, 'SCNTL1', 1, 'SCNTL2', 2, 'SCNTL3', 3,
'SCID', 4, 'SXFER', 5, 'SDID', 6, 'GPREG', 7,
'SFBR', 8, 'SOCL', 9, 'SSID', 10, 'SBCL', 11,
'DSTAT', 12, 'SSTAT0', 13, 'SSTAT1', 14, 'SSTAT2', 15,
'DSA0', 16, 'DSA1', 17, 'DSA2', 18, 'DSA3', 19,
'ISTAT', 20,
'CTEST0',