Micro_Cornucopia_#39_Jan88 Micro Cornucopia #39 Jan88

Micro_Cornucopia_#39_Jan88 Micro_Cornucopia_%2339_Jan88

User Manual: Micro_Cornucopia_#39_Jan88

Open the PDF directly: View PDF PDF.
Page Count: 100

DownloadMicro_Cornucopia_#39_Jan88 Micro Cornucopia #39 Jan88
Open PDF In BrowserView PDF
N o. 39

Jan ./Feb. 1988

THE

$3.95

C R

M

TEe H N

PC Graphics
This issue we're concentrating on
graphics, from mathematically-generated
fractals to human-generated acorns.
Plus, we'll look at the newest hardware
for displaying the finished product.

Drawing The Mandelbrot
And Julia Sets page 6
It was so much fun creating Mandelbrots
that we couldn't resist using this one as
our first full-color cover. Larry tells you
how to do it.

Desktop Graphics

page 10

Expanding the desktop world . Here's
how an author and a graph ic designer
use desktop graphics.

Designing A PC
Workstation Board Around
The TMS34010 page 18
Dean Klein takes a close look at this
super-powerful graphics processor.

A Hercules Primer

page 24

The Hercules card is the only non-IBM
standard. Here's how to write graphics
routines for this interesting little card .

Controlling Synchronous
Serial Chips With A
Parallel Port page 30
Want some speed in your morning
serial? Bruce Eckel clocks in with a
primer on fast bits.

12

I
I',

.. . .
;

o

74470 19388

3

CAL

JOURNAL

VERY HIGH RESOLUTION

The PC Tech Monochrome Video Board and Monitor
~~Jl.flIl!iL!.'.!!!-LT~mri1[;';:;-m~:~~mtj:E:'",==~i::

:~'''!.',''I

PC Tech

• Windowing, most desk top

Scoop

';~PC;::TeC~hI=n(.=='~~====~
;~:~:::ff

•

publishing packages, full page
Lotus 123 and other applications.
PC, XT, and AT Compatible.

;Publisher at

• MDA (MONOCHROME) emulation.
• CGA (COLOR GRAPHICS)
emulation.
• Full Screen Graphics.
• 6 MIPS TMS34010 32-bit
graphics CPU. 736 by 1024
resolution. Both black on
white and white on black
text modes supported.

I
I

1~'";';""'wm""w'w""."""

,--------"
.,

•

Complete systems available.

*SPECIAL LIMITED TIME OFFER: PC Tech is offering the complete video system (monitor,
graphics adapter card,aH necessary interface software and cables) fora special introductory
price of $995 plus shipping and handling. Bank card orders welcome.

SPECIAL FOR'MICRO-C USERS: Ask for the Micro-C specialwhichwillinclude ~xtensive
development software at no charge!
~.'>.

N

<.,

~

~

", }

Now also available: The PC Tech Color 34010 Video Board. This is the workstation class graphics
engine featuring:
• 6 MIPS TMS34010 32-Bit graphics CPU.
• Color palette provides up 256K
color choices.
• Up to 4 Megabytes non-display memory.
• Hardware support for CGA/M DA
• Up to 1 Megabyte of display memory.
emulation.
• Eight bits per pixel give 256
• 800 by 512 to 1024 by 800 resolution.
simultaneous colors.
This board is designed to be the ultimate windowing engine with the PC Tech native mode
MS-Windows driver. In addition to the MS-Windows support, CGA and M DA emulation software
is provided as well as the PC Tech graphics development toolkit.

Introductory SpeCial: $995

(includes 1.5mega/lytesme1p9ry, and software)

Designed, Sold and Serviced By:
904 N. 6th St.
Lake City, MN 55041
(612) 345·4555
(612) 345·5514 (FAX)
PC, XT, and A T are trademarks of International Business Machines Corp.

Reader Service Number 3

Enlarged
Shift keys

Two Ctr/and
Aft keys for
ambidextrous
access. - _ __

Positive-tactile,
firm-feel
keys.

Isolated

12 Function
keys for
increased
automatic
operation.

Extra-wide, easy-tofind Return key.

Dedicated

Separate
dedicated

Function Control keys.

IBM changed sizes
again by shrinking their
Return key.

Numeric Pad
with enlarged
Enter key, four

Arithmetic

r----- Function keys.

Escape key.

IBM just announced their new
redesigned "standard" keyboard for personal computers. There's only one problem:
it won't work on your IBM computer if it
was purchased priortoJune 1986 oron any
PC compatible purchased at any time!
Not to worry. Our new Turbo-1D1 Enhanced
Keyboard gives you the layout and enhancements of the IBM with some logical
improvements (see above photo). And it
works on your existing PC, XT, AT, PCjr,
AT&T, Epson and virtually all compatibles!

I

Get Borland's Turbo Lightning
For FREE!
To really turbocharge
your productivity, we are'

~~~ra~~~
:~~~h~~~~~~e,
Lightning software with

™

OFF'l:!R'
SPEC/'AL
H
J;;, •
ONLY $149.95*

FOR BOTH
KEYBOARD & SOFTWARE

,.'

.

The Turbo-l0l is the best data entry tool
since the pencil!
For users of spreadsheets like 1-2-3, the
Turbo-101's separate cursor controls and
numeric keypad makes entering numeric
data into cells and moving from cell to cell
as natural as moving your fingers. And for
word-processing, the 'Selectric'typewriter
layout makes the Turbo-101 as easy to
use as a pencil; and with the extra large
Enter, Shift & Control Keys, you'll make so
few mistakes, you won't even need an
eraser!

i.'f. '·.•,,.: '·,·~:

!.'
. . ,1
~~

each keyboard. Now,
when using SideKick, WordPerfect, Microsoft Word, 1-2:'3 or most popular programs,
our Turbo-101 Keyboard will check your
spelling as you type, gives you instant
access to Random House's 80,OOO-word
Concise Dictionary and 60,OOO-word
Thesaurus and much, much morel
"Lightning's good enough to make
programmers and'users cheer, executives
Of other software companies weep," says
Jim Seymour of PC Week. Sold separately,
, Thrbo Lightning retails for $99.951

"Who Can Pass Up a Deal?
Department. Talk about an
aggressive productl"
John C. Dvorak,
InfoWorld Mar 86

"It s a good keyboard. Good
feel: the keys have tactile
feedback. No mush at al/.
This Is about as good a keyboard deal as you're likely
toflnd
... 1 have absolutely no
"It solves all of the problems
hesitation In recommendexhibited by their regular
Ing the Model PC8700."
PCIXT keyboard ... It sa
Jerry Pourne/le.
great bargain!"
Byte
JI1agazlne Sept. 86
PC Productivity Digest
JI1ay86
"This keyboard Is 1Ieat to
"DataDesk Inti. has designed type on andfeels solid. It
a sturdy and handsome key- has tactllefeedback keys... 1
ca1l type much faster on It."
board that has tactile re·
Test Drive Scorecard:
sponse... ls the hardware
DataDesk-l0 Key Tronlcs·9
bargain of the year" says
Teleconnect Magazine
Charles lIumble, Oregonian May 86
Jan 86
"The bestpart of the keyboard Is the way Itfeels. It's
Ideal! Andfast. I've 1Iever
worked on a keyboard with
a nicer touch."

Includes 30-day money back
guarantee and 2 year full warranty.
To prove that we don't ignore you
or your pocketbook, you get our
Turbo-101 Enhanced Keyboard and
Business Computer Digest
:
Borland's Turbo Lightning for an
Aug 86
_--astounding $149.95.* No, you didn't ~__
'
read it wrong. During this amazing
Introductory Offer you get both
',
~\\\\f>.\\t~\)'~

t.

\~\\V.\):\\\\ ~v-.\\~~

i...•.•.:..:.ii:.•'.....

you-know-who~:
11&',,'."

N

~Pt\~

'.. .

Turbo-101 is a trademark of DataDesk International, Turbo Lightning Is a
trademark of Borland International, IBM and IBM AT are registered trade·
marks of International Business Machines. Inc,

.

'Price does not include adaptor
cables required by certain compat·
ibles • A Limited offer-price subject
to change without notification.

:

-,

.~:~~:~~:~:\\,~~
~\\\~:t~~'

Dt\\tt~

~~~i~O:~~~

~~~1j;~!a~:5398."~,:~ ~~~'~

. .

\\~,,~.
. .. . .•
'.
~:' .' '.' . 1.\~'.---..\)\)\\~~~" '. '. '. :' ...' .. ". .%"\~ .• ~------

t.\rt~~~~'~\\ .~"'~:~
~~\~~
\t~",:~~~~ ::'

Re'ader Service Number 8

.

'i.'

~JL::,"

INTERNATIONAL

7650 Haskell Avenue
Van Nuys, California 91406 (818) 780-1673 ,

\

\.\u\\\\\\\\~" ~~ ",:k ~r~l~O

a

still feeling ignored, you can
always do what
wants you to do.. .and buy
a new computer to get their

: \

v.\1\\\
\\}\\v.\)
~~"lv.\)ft..\\\) f>.\\\) ~~f>.\\~T\)\\
\)\\\1'.

keyboard
software
for less
than
mostand
software
programs:\:·
....
by themselves! Now, if you're
........' .

keYbOard!,,,

On9.\\A~

~ 
DIR

How slowly the display scrolls! Yet, this
mode (C040) is only 320 by 200 pixels,
mediocre resolution! Can you imagine
1024 by 800 pixels, where each pixel is
eight bits instead of two?
Unfortunately, this slow speed has
led the programmers of most good

18 MICRO CORNUCOPIA, #39,J9-n-Feb 1988

graphics programs to skip, the BIOS and
operating system so they can access the
hardware directly.
All of these boards have a 6845 CRT
controller chip or 6845 emulation for
performing the display refresh and cursor functions.
Workstation Graphics
Workstation manufacturers have
taken a different approach by making
the workstation graphics controller intelligent with the addition of a
microprocessor dedicated to graphics
tasks. Typically this has been a 68000,
and lately has been enhanced with the
addition of special hardware to speed
the graphics operations.
There are several advantages to using
a second processor for graphics operations. First, the graphics processor can
do some of the image calculations for
the system processor.
Second, and perhaps more important,
the graphics interface for applications
programs can be, made device-independent. Thus, workstation, v'endors
have been able to offer several graphics
options (with a range of resolutions,
black and white or color... ) without affecting application programs.
New Generation Graphics Controllers
Two types of graphics controllers
have been developed by semiconductor
companies during the last two years:
display list processors and graphics
processors.
The display list processor chips trans-:
form lists of commands into raster data
for the display. These can be both
character and graphics commands. Display list processor manufacturers include AMD, Hitachi, Intel, NEC, and
National Semiconductor. Some of these
devices even include windows and
zoom-in hardware. Huwe.ver, in order to
be most effective in a high-level gr~'p~ic~

By Dean A. Klein, President
.

task, the display list processors must
have a microprocessor controlling them
(to interpret the high-level commands).
The Graphics CPU
Combining the graphics drawing
capabilities of th~ display list processor
with a high performance microprocessor
on a single chip is an approach taken by
Texas Instruments and National Semiconductor.
The Texas Instruments TMS34010 is a
5-6 million instruction per second 32-bit
CPU, optimized for graphics operations.
For a basic overview of this part see the
April-May 1987 issue of Micro C (#35, p.
86, "Changing The Picture").
Designing A Graphics Board
I think a great video board for a PC
is one with all the capabilities of a
. workstation but without the cost. That's
why we chose the TMS34010 when we
faced designing a graphics card, which
not only had to support high resolution

without flinching but also emulate common PC video cards.
Let's dig into the details (see Figure 1
for a block diagram of the system).
The 34010 supports two types of
memory. One type holds programs and
fonts, the other holds data f

VIDEO RAM

HIGH...;"SPEED

1----,/

..,.--_-,-J---1/

l - -_ _

ImORIVER

1-1--.....,> ~lPUTS

Ic6li-~~1

f-- - -

256K

MICRO CORNUCOPIA, #39, Jan-Feb 1988

19

directed to the active bank. This is done
by sending the latched upper addresses,
as well as the TMS34010 RAS or CAS
signal, to a decoder. In this case, the
decoder might be a PAL (Programmable
Array Logic) or PROM.
Special Memory Cycles
The TMS3401 0 performs two types of
refresh cycles: memory refresh and
screen refresh.
The first is quite simple and well understood. Since each and every row of
the dynamic RAM must be refreshed at
least once every four milliseconds, the
chip refreshes RAM downright regularly.
During a refresh cycle the designer
must be sure that every bank of memory
receives the refresh address and a RAS
signal. Thus, if the bank selection
decoder is selecting banks of memory
using the RAS signal, all banks must
receive RAS in this special case. The
TMS3401 0 announces refresh on its
LAD15 pin during the start of the
memory cycle. This signal must also be
latched.
Screen Refresh Cycles
The screen refresh cycle requires a little background. The TMS34010 must use
a special type of dynamic RAM for its
screen buffer. The RAM is often called
Video RAM (VRAM) or multi-port
dynamic RAM. (A hint of what makes
this RAM so speciaL)
The multi-port dynamic RAM has
two ports for accessing data. One port is
nearly identical to a standard DRAM interface, having address pins, a RAS pin,
a CAS pin and an OE (output enable)
pin. This is the port used by the
TMS34010 for writing or reading screen
memory. The second port is a serial access port, where data can be shifted in
or out at rates up to 25 MHz (for a 120
nsec part). This is the side of the DRAM
closest to the display.
During the screen refresh cycle, data
in the multi-port dynamic RAM is transferred, one row at a time, to the serial
access port (to be displayed). Each row
is 256 bits. The multi-port dynamic
RAM assumes it will be this type of
memory operation if its OE pin is active
at the start of the memory cycle. The
34010's TR/QE pin is connected directly
to the RAM's OE pins.
Meanwhile, all video RAMs must
receive RAS and CAS during a screen
refresh cycle. The video controller
provides a signal on LAD14 'during the
column address time of a screen refresh

20

MICRO CORNUCOPIA, #39, Jan-Feb 1988

Figure 2-TMS 34010 Pinout.

~ I ~ ~ i ; ~ II I ~ ~ m~11111 I
HD0

LAD'"
LADl

11

HD1

LAD2

12

HD2

LAD3

13

HD3

LAD4

14-

HD4

LADS

15

HD5

LAD6

16

LAD7

17

Vss

18

LADS

19

LAD9

2121

HD9

LADt'"

2t

HDt0

LAD'1

22

HOlt

LADt2

23

HD12

LAD13

24

LAn

LAD14

25

HDn = HOST DATA

HD6

FN

PACKAGE

HD7

Ves

(TOP VIEW)

= LOCAL

HOB

HD13

ADDRESS

HD14
HD15

LAD15

Figure 3-Triple Multiplexing of Addresses and Data.
ROW
ADDRESS

COLUMN
ADDRESS

DATA

1:1--1:1---

RF

lAO

15

26

TR

14

LAD 13

25

29

13

LAD

p--12 p---

24

2B

12

LAD 11

23

27

11

LAO

22

14

10

21

13

9

20

12l

8
7

GSP
LAD 15
LAD 14

b--10 b---

LAD 9

p---

LAD 8

b---

LAD 7 :::J---

I 19

11

I

LADS :::J---

t

H~

I

18

9

I

5 '

LAD '4 :::J---

I 16

8

I

4

LAD :5 :::J---

!

15

7

!

:5

LAD 2 :::J---

I 14

6

I

2

LAD 1 :::J--LAD 121 :::J---

,

5 ..J
L..13___ ____
I

12

121

4

~-,~~
I
SITS 12-26

I

6

I 17

LAD 5 :::J---

J

i

t

27-29

BITS 0-15

32-81T MEMORY ADDRESS

SIT 31 (MSS)

16-BIT DATA WORD

t

(lSB) BIT 0

t

SIT 15 (MSB)

t

BIT 0

(lSB)

= DRAM-REFRESH BUS STATUS BIT
lAO = I~STRUCnON' ACQUISrnON BUS STATUS" BIT

RF

m= VRAM SHIFT-REGISTER-TRANSFER BUS STATUS BIT

cycle.
110 Interface
The host processor (the PC) communicates with the TMS34010 through a
host data bus and several other control
pins. This interface allows the host to access all of the 34010' s memory as well as
its I/O registers.
The host data bus is 16 bits wide but
can be used with an eight bit bus quite
simply. Two input signals, UDS and
LDS, select the upper and lower halves
of the bus.
By connecting the upper half of the
host data bus (HD8-HD15) to the lower
half of the host data bus (HDO-HD7),
and by connecting LDS to the host's
lowest address pin (AO) and UDS to inverted AO, the eight bit interface is complete. The TMS34010 also has conventional chip select, read and write input
pins. Two address inputs select anyone
of the four internal registers (see Figure
4).

CRT Interface
I mentioned earlier that the screen
buffer is a special type of memory. This
memory has a second access port
through which data may be shifted out
at up to 25 MHz. These shift registers
are 256 bits long.
Figure 4 - Register Select Logic.

HFS1

HFSO

Selected
Register

0

0

0

1
0
1

HSTADRL
HSTADRH
HSTDATA
HSTCTL

1
1

Since a screen refresh cycle can occur
only during the horizontal blanking
time (once per scan line), it's obvious
that something else is needed to accomplish state-of-the-art video output
with over 1000 pixels horizontally and
data rates of over 100 Mpixels per
second. The solution is to parallel
several multi-port dynamic RAMs with
their outputs going into a high-speed.
shift register. The register then sends the
data to the display.
On our 34010 board we set the rate at
75 MHz, though we tested the logic at
up to 110 MHz. We used 74F393 high-

speed shift registers rated at 125 MHz.
At these speeds timing is very critical, and you soon learn that every
nanosecond counts. The shift registers
must be reloaded the instant they shift
out their last pixel. A high-speed
counter keeps track of load cycle timing
and clocks in the data from the multiport dynamic RAMs.
We provide two bits per pixel to the
CRT, giving four levels of pixel intensity. We simply duplicated the highspeed shift registers to output the
second data bit.
On the TMS34010, a pixel (in our
case, two bits) is placed in adjacent
memory locations. This is in contrast to
many other systems where a pixel's bits
are stored in several planes of memory.
The adjacent bit organization provides
much simpler control of pixel color (or
intensity) than the multiple plane organization.
ECL Outputs
In addition to having TTL outputs to
a monitor, the board also has ECL outputs. The advantages of the ECL outputs are higher speed and fewer
problems with noise.
Both true and complemented ECL
data is sent to the CRT. Since both signals run in close proximity to each other
through a cable to the CRT, the effect is
the radiation from one line cancels the
radiation from the other. This means
your radio is less likely to go to lunch
and the FCC stays happy.
The disadvantage with ECL is that
it's really a power hog, consuming large
amounts of current from the PC's
wimpy -5V supply. We use only one
ECL chip, a 10124 TTL to ECL convertor, to keep power consumption to a
tolerable level.
CRT Timing Registers
Most CRTs need horizontal and vertical sync signals to time the start of the
beam across the face of the CRT. The
controller provides these signals and allows the timing of them to be
programmed
(via
eight
internal
registers) to match the characteristics of
most CRTs. To the programmer, these
registers appear in TMS34010 memory
space starting at address COOOOOOOH
(see Figure 5).
PC Specific Support Hardware
In order for a video board to be compatible with most IBM PC applications,
the PC must see display memory at
either BOOOOH (for MDA) or B8000H (for
Reader Service Number 22

MICRO CORNUCOPIA, #39, Jan-Feb 1988

21

Figure 5 - CRT Timing Registers
REGISTER

Imo,g,Wlae

M

DPYADR

ADDRESS
COOO OlEO

DESCRIPTION
Display
Address

Serial Digital Imaging System

Counts the number of scan lines output between
successive screen refresh cycles· and ~ontains
the source of the row and column addresses
output during a screen refresh cycle:
LNCNT (bits 0-1)
- Scan line counter
SRFADR (bits 2-15) - Screen refresh address

DPYCTL

Image Wise functions as a
standalone video digitizer or
a complete tele-lmaging and
video capture system.
Image Wise's serially bit
mapped digitized pictures
are universally compatible
with any computer or modem.
It is ideally suited for
CAD/CAM Desktop Publishin~, Teie- Imaging, and
Security.
• System Specifications •
*NOT bus dependent
;*Captures an image in 1/60th second
'* Accepts any B /W. or color NTSC video
*Resolution of transmitted image is
256x244x64 gray scale. Resolution
selectable: High - Medium - Low

unretouched photos
*Video Input: 75 Ohm. IV peak-to-peak.
*Video Output: 75 Ohm. NTSC. 1.5V
peak-to-peak.
*Serial Input/Output: RS-232 - 8 bit.
one stop bit. no parity - 300 bps to
57.6K bps selectable data rate Xon/Xoff handshaking - switch selectable data compression (on/off);
*Modem compatible: Functions as a
video or a remote serveillance camera.
*Video processing: PC/MS-DOS picture
. upload/download and conversion
utilities to popular Paint & Desktop
Publishing programs.
Optional PC Utilitie~ Disk converts
ImageWise files for use with popular
Desktop and Paint programs.
DTOI Digitizer/Transmitter $349.00

DROI Receiver/Display

$349.00

To order call

1-800-635-3355
TELEX: 643331

For technical Information call
1-(203)-871-617~

MICROMINT, INC.
.
4 Park St., Vernon, CT 06066

..-

Display
Control

Contains several parameters that control video
timing signals:
HSD (bit 0)
DUDATE (bits 2-9) ORG (bit 10)
SRT (bit 11)
SRE (bit 12)
DXV (bit 13)
NIL (bit 14)
ENV (bit 15)
Bit 1 is reserved.

Horizontal sync direction
Display address update
Screen origin select
Shift register xfer enable
Screen refresh enable
Disable external video
Noninterlaced video enable
Enable video

DPYINT

COOO OOAO

Display
Interrupt

Specifies next scan line that will cause
a display interrupt request.

DPYSTRT

COOO 0090

Display
Start
Address

Provides ctrl of the automatic mem-to-shiftregister cycles necessary to refr a screen:
LCSTRT (bits 0-1)

- Specifies number of scan
lines displayed between
screen refreshes.
SRSTRT (bits 2-15) - Starting scrn-refr. addr
DPYTAP

COOO 01BO

Disp Tap
Pt. Addr

Contains a VRAM tap point addr output during
shift register transfer cycles.

HCOUNT

COOO 01CO

Horiz.
Count

Counts the number of VCLK periods per horiz
scan line.

HEBLNK

COOO 0010

Horiz.
End Blank

Designates the endpont for horiz blanking.

HESYNC

COOO 0000

Horiz.
End Sync

Specifies the endpoint of the horiz sync
interval.

HSBLNK

COOO 0020

Horiz.
St~t Blnk

Specifies the starting pOint of the Qoriz
blanking interval.

HTOTAL

COOO 0030

Horiz.
Total

Specifies the total number of VCLK periods per
horizontal scan line.

VCOUNT

COOO 01DO

Vertical
Count

Counts the horiz scan lines in video display.

VEBLNK

COOO 0050

Vertical
End Blank

Specifies the endpoint of the vert blanking
interval.

VESYNC

COOO 0040

Vertical
End Sync

Specifies the endpoint of the vert sync pulse.

VSBLNK

COOO 0060

Vertical
Strt Blnk

Specifies the· starting pOint of the vert
blanking interval.

VTOTAL

COOO 0070

Vertical
Total

Specifies the value of VCOUNT at which the
vertical sync pulse begins.

CGA), as well as a 6845 type video controller at a certain I/O address, depending on video type.
We chose to do neither on the PC
Tech card, yet· we remain compatible
through clever deception. (Editor's note:
Now I suppose you'll be running for higher
office.)
When graphics information is written
to the IBMCGA screen, it's displayed

Reader Service Number 23

22

COOO 0080

MICRO CORNUCOPIA, #39,Jan-Feb 1988

from left to right starting with the most
significant bit to the least significant bit.
This is opposite from the way the
TMS34010 displays data. To accommodate this difference, the host CPU
reverses the data when it reads from or
writes to TMS34010 memory.
This is easy to do since the two data
buses are separated by buffers. This little
trick gave Earl (Hinrichs) fits when writ-

ing the TMS34010 code for emulating a
text display since the ASCII codes are
also reversed.
Emulating the 6845 register set is a
bit more difficult since the 6845 has an
index register, which. points to one of
many data registers; We accommodated
this by providing a hardware index
register to override the lower address
bits during a read or write to a 6845
data register. The data is actually in a
special region of TMS34010 dynamic
memory. This trick fools even the best
programs.
We also generate a: display enable
signal which changes with each
horizontal sync., Many application
programs check this signal to see if they
can write to the display memory
without causing screen disruption.
And we added software control of
video emulation. (We just write to a
34010 register to select emulations.)
Emulation modes include-, '
MDA compatible - 80 characters by 25
lines
Enhanced MDA
lines

- 80 characters by 66

Come to

SOgo/II!
Jury 14 - Jury 16
'Bent£, Oregon

CGA compatible - 80 characters by 25
lines
- 320 by 200 graphics
- 640 by 200 graphics
Enhanced CGA
lines
- 320
- 640
- 736

- 80 characters by 66
by 200 graphics
by 200 graphics
by 1024 graphics

Wrap Up
Earl will detail several of these in his
article next issue. I would just like to
add that the CGA emulation modes are
good enough to fly Flight Simulator and
Jet. The high resolution 736 by 1024
graphics mode is compatible with
another popular video board, allowing
most any desktop publishing application or other graphics application to
work without modification.
In the future, emulating other video
boards will become less important as
higher-level graphics standards are
adopted on the Pc. This may be a
standard such as Microsoft Windows or
Presentation Manager, or possibly CGI,

DGIS,
Metawindows
or
HALO.
Whatever the standard, the TMS34010
will really shine by off-loading most of
the graphics tasks from the host CPU.
What else does the future hold? Certainly higher resolutions. I've already
modified a board to provide 1600 by
1024 resolution at 1 bit per pixel. The
data rate has been run as high as 160
million pixels per second in this mode.
And 2048 by 1500 resolution at 200 million pixels per second isn't far'away.
Texas Instruments has let it be
known that a successor to the TMS3401 0
is on its way. The TMS34020 promises a
full 32-bit data path and probably some
new instructions. Higher speeds and a
larger cache are not unlikely, either.
Personally, I'd like to see floating
point capability, 10-15 MIPS sustained
performance, parallel processor support,
etc., etc ...
Editor's note: Dean and Earl are marketing their 34010 graphics board through
their company, PC Tech, 904 North 6th St.,
P.O. Box 128, Lake City, MN 55041.
111111

omn~ ~D

, WINDOWS!

SPRITES!

ROW TABLE SCREENS!

FOR THE 'S3 KAY PRO II OR 4, XEROX S20-1, ANO BIG BOARO-11
THE

DMNIVID

DEVICE

DRIVERS

B1 azi ng fast assembly 1anguage de vi ce dri vers make i mpressi ve
screens quick and easy! No complicated code to write. Just
send si mp1 e escape sequences to your Con sol e Output routi ne.
Multiple screens, each with its own windows and sprites, may be
held in memory for instant use! OMNIVIO· makes it simple .
.;nd, with FLEXUTlL.COM (provided) it's quick and easy to create
'an executable .COM file which loads your selection of the
OMNIVlO- device drivers in protected upper TPA, above the BIOS,
or at any absolute address. Information on how to write and
include your own device drivers is also provided!

ALSO

A devi ce dri ver whi ch supports
a MICROSOFT compatab1e serial
(RS-232) mouse.
(Can be
confi gured to support the
popular LOGITECH C7 serial
mouse.)
Now you can write
mouse driven programs with
pop-ups and pull-downs for
your Z80 computer!!

*

A devi ce driver for dumpi ng
the screen to your pri nter.

*

SLOTS.COM - A realistic slot
machine game demonstrates ROW
TABLE ORIVEN SCREENS.

*

JAWS - A game to demonstrate
the abil ity to ani mate usi ng
the OMNIVlO- device drivers.

Easy to use with most High Level Languages. Toolboxes provided
for Sbasic~ and Turbo Pasca1~. TURTLE-BOX (also included for
use with Turbo Pasca1~) brings TURTLE GRAPHICS abil ity.

=c_

Available now for the '83 Kaypro II, 4, Xerox 820-1, Big Board-I.
Soon for the '84 series Kaypros and PC compatab1es.
ONLY 49.95 (includes shipping)
KY residents add 510 Sales Tax
VI SA, MC, or COO accepted

Call or write for info.

INCLUDED

*

Or order documentation on disk for only $8.00 (includes shipping).

ALSO AVAILABLE

f4.na'Bring ~our
~riendSl

A GRAPHICS CHARACTER ROM for your 83 Kaypro II or 4, Xerox 820-1, or Big Board-l
supplements the OMNIVIO- device driver package with a thin-line and pixel graphic
(160 x 48) character set.. As well as providing better looking window borders and
an improved alphanumeric character set, the pixel graphic character set is highly
desirable for use with TURTLE-BOX (above). ROM PRICE 19.95 (includes shipping).

TEL (606J 325-3736

FLEXISOFT .

9AM - 6PM EST

3987 VALLEY VIEW DRIVE· ASHLAND.KY 41101

TM

Reader Service Number 25

MICRO CORNUCOPIA, #39, Jan-Feb 1988

23

A Hercules Primer
Black Sheep Graphics

Need to increase your New Year's resolution? Here's nearly everything YOll ever
wanted to k1loW abollt writhlg graphics
rOll tines for the Hercllies card.

probably
should
call
this
monochrome sheep graphics. The
Hercules graphics card stands out as
the only "nonstandard" graphics card to
become succesful in the PC market.
CGA and EGA cards both have the
support of ROM BIOS routines to control the graphics mode and set individual pixels. Not so with the Hercules card. Pascal graphics libraries do
exist for the Herc. But in the switch to
Turbo C for coding fractal programs, I
lost them.
I can't do without the Herc's 720 X
348 resolution, it's still the best mix of
low cost and high resolution going. So
let's build a library of functions to tame
the Hercules card.

I

Is It There?
First things first. Is there a Hercules
card installed in the system? I guarantee
some weird results if you use these functions to draw in a non-Hercules system.
Interrupt llh checks for the presence
of a monochrome card. If the AX register
has bits four and five set on return, then
some kind of monochrome card is out
there. It could, however, be the lowly
IBM Monochrome Display Adapter
(MDA).
To further discriminate between
monochrome cards, we'll have to dig a
little deeper. At the heart of most PC
video boards lies Motorola's 6845 CRT
controller. Two I/O ports to the Hercules card give access to the 6845's
registers, while another two ports
provide status information and mode
control.

24

On the Hercules card, bit seven of the
status port contains information on vertical retrace. During horizontal scans, bit
seven remains high. After the bottom
scan line has finished, the electron beam
returns to the top scan line. During this
return, or retrace, the Hercules card
resets bit seven to zero.
The MDA always leaves bit 7 low, so
during retrace the Hercules looks just
like the MDA. herc_there samples bit 7
long enough to be sure vertical retrace
has finished. Then, if bit 7 ever goes
high, it's a Herc. (See Figure 1 for all
graphics functions.)
Why use 800h for the number of
times to sample bit 7? Strictly because it
works on each of the mongrel machines
in the Micro C office. If you want to be
absolutely sure of correctly identifying
the video card, use 1000h.
Configuration
The Hercules card has two video
pages, each 32 Kbytes. The first, page 0,
starts at address OxbOOOO. This is the
location of the monochrome text screen.
Page 1 starts at Oxb8000. The configuration port controls access to the 6845's
various modes.
You can set up the 6845 thre~ different ways. With bits zero and one at
zero, the card displays only text. Setting
bit zero to one allows the graphics
mode. Finally, a zero in bit one masks
the use of graphics page 1. Or, a one in
bit one enables page 1.
Note that, since we can mask off page
1, both the Hercules card and a CGA
card could be installed in the same system. Both page 1 and the CGA card start
at Oxb8000. But with page 1 masked,
there's no contention.
Graphics Mode
Before setting any graphics mode,
send a byte to the configuration port to
allow graphics on one or both of the

video pages. (See set_graphics in Figure
1.) Next, turn off the screen so the user
won't see any nastiness during the mode
change. This involves the mode control
port.
Only four bits of the mode control
port have any effect. Bit one sets text
mode (zero) or graphics mode (one). Bit
three either blanks the screen (zero) or
activates it (one). Bit five disables text
blink (zero) or enables it (one). And bit
seven determines the active displayzero for page 0 and one for page 1.
So we'll send 000000lOb to the mode
control port, turning off the screen and
setting graphics mode. Now program
the gaggle of registers in the 6845. Of its
18 registers, only the first 12 have any
importance in setting video modes.
Figure 2 gives a description of each of
them.
The final lines of the set_graphics
function clear both pages and turn on
the video display of page O. More about
clear~r_scr later. For now, the important aspect of this function is that· it
sends 00001010b to the mode control
port, displaying page O.
Text Mode
set_text looks a lot like seCgraphics.
A zero to the configuration port locks
out the graphics modes. Another zero to
the mode control port sets text mode
and turns off the screen. A new slough
of parameters goes out to the 6845
registers. Then we clear the screen and
send 00101000b to the mode control
port. This enables the text blink and
turns on the screen.
I've read about timing problems
when programming the 6845 from high
level languages. My Hercules clone's
documentation warns against the practice due to the undefined frequenci~s
output during a mode change. But I've
been using Turbo C to control the 6845
for some time now with no smoke. I've

MICRO CORNUCOPIA, #39, Jan-Feb 1988
------------------------------~---------

By Larry Fogg
Micro C Staff'

even successfully programmed the 6845
with Turbo Pascal. If you're worried,
you can always rewrite the mode changes in assembler.
What's The Point?
In order to do anything with
graphics, you'll need to be able to perform the most fundamental graphics
function-draw a point. Our display is
bit-mapped, with each pixel on the
screen corresponding to a bit in
memory. So setting the appropriate bit
turns on a pixel. The only trick lies in
finding the memory address of a given
pixel.
We have to deal with a fa'ctor-of-four
interleave in memory addressing of
rows. The first (Oth) row starts at offset 0
within the page. Row one starts at offset
2000h, row two at 4000h, row three at
6000h, and row four at 90d (90
bytes/row * 8 bits/byte = 720 bits/row).
So where's the point (X, Y)? (Y MOD
4) tells us which quarter of the page's
memory it's in. 2000h * (Y MOD 4) gives
the offset of that quarter page. The line
containing (X, Y) is (Y DIV 4) lines
down within the quarter page. Chalk up
another 90 * (Y DIV 4) bytes to add to
the offset. Within that row there will be
an offset of (X DIV 8) bytes to the byte
containing (X, Y). And the bit we're
after is bit (7 - (X MOD 8». Messy indeed. (See draw_point in Figure 1.)
To draw the point, set up a mask
byte by shifting a one into the corresponding bit. Then, ORing the
memory location with the mask turns
on the pixel. ANDing with the one's
complement of the mask turns the pixel
off.
Line Drawing
Lines are just collections of points,
and we already have the draw_point
function. But how do you decide which
points should be included in the line? I

lifted Bresenham's algorithm from
pllter

Graphics-A

Programmillg

C0111-

Ap-

proac11, a graphics text by Steven Harrington.
Bresenham's algorithm works with
integer arguments and uses only integer
math. It also avoids division and multiplication so it zips right along. Very
briefly, this algorithm breaks the
problem into two major cases-steep
lines and shallow lines.
In the shallow line case, it draws one
endpoint, then steps through the
columns toward the other endpoint. At
each column, it tests to see if the line has
moved into a new row. If so, the row
number gets incremented (for positive
slope lines) or decremented (for negative slopes). The steep line case reverses
the situation. We step through the rows
and test for a change of column.
I might mention that although the
variable name dX stands for "Delta X,"
this code is guaranteed not to crash.
Miscellaneous Functions
init takes care of initializing the two
global variables, page_drawn and
page_viewed. page_drawn holds the
segment address of the active drawing
page and page_viewed holds the segment address of the displayed page.
set_page_viewed and set_page_drawn
alter
these
two
variables.
set_page_viewed also programs the
mode port to display the specified page.
You can use these functions to write to
one page while viewing the other.
No mysteries in clear_gr_scr. I turn
off the screen when clearing the displayed page, but that's just a matter of
taste. It's not necessary. clear_txt_scr
needs to fill all attribute bytes with
sevens-the normal attribute.
Save any screen to disk using
save_screen. It copies the specified page
directly to disk under the file name
passed to the function. I fooled with this

one for quite a while. The pointer to
video memory just wasn't working out.
Tony Ozrelic put me on the right track,
and while the code I came up with ain't
portable, it does work.
get_screen restores a saved screen. If
you omit the screen_off in get_screen,
you'll get to see a graphic demonstration of the video memory interleave. To
save a screen in text mode, use
save_screen and pass it pageO as a
parameter.
Direct Screen Writes
Sure it's not graphics, but foregoing
the video services of interrupt lOh is
what this article is all about. And you
can very easily write characters directly
to video memory with a Hercules card.
Characters live in the even bytes of
video memory while their attributes
(blinking, underline, etc.) are found in
the succeeding odd locations. Eac 1character / attribute pair takes up t\
bytes and each row of 80 characte.
takes up 160 bytes. So it's easy to find
the memory offset of a particular screen
location.

offset = 160

*

row + 2

*

column

scr_write just pokes away at memory
until it reaches the end of the string
being written. No sweat. If you use this
function on a CGA system, you'll need
to consider the following.
Video memory is dual ported. That
means the processor can write to
memory at the same time that the video
card reads it for a trace on the screen.
On color systems this creates snow
during direct screen writes. Inexcusable.
A program has only to poll the vertical
retrace bit of the status port and restrict
screen writes to the retrace period. No
more snow.
The Herc doesn't care, though. It

MICRO CORNUCOPIA, #39, Jan-Feb 1988

25

must be doing arbitration on its own because you can alter video memory any
old time you please. Of course, this applies to the graphics mode as well as the
text mode.
Turbo C Tirade
I have to bitch about Turbo C for a
bit. . Version 1.0 has some major
problems. The floating point library
does peculiar things. And the classic
style of function definition doesn't work
with floats. The following function will
print a value for var1, but it won't be the
value you passed.
void param_pass (varl)
float varl;
{

printf ("value

= %f", varl);

Figure 1 - Graphics Routines For The Hercules Card
#include 
#include 
#include 
#define boolean char
#define yes 1
#define no 0
#define index Ox3b4
#define data Ox3b5
#define mode Ox3b8
#define status Ox3ba
#define con fig Ox3bf
const
const
const
const
const
const
const
const
const
const
const
const

/* 6845 ports */

/* Herc ports */

char normal = Ox07; /* char attributes for direct memory screen writes */
char reverse = Ox70;
char under line = Ox01;
char normal blink = Ox87;
char reverse blink = OxfO;
char under blink = Ox81;
int pageO ~ OxbOOO;
/* base address of video pages */
int pagel = Oxb800;
int text base = OxbOOO;
/* base address of text page */
int max col = 719;
/* Herc parameters */
int max-row = 347;
int screen_size = Ox800;
/* bytes per page */

/* current drawing and viewing pages */

Changing the function to:

{

page drawn = pageO;
page-viewed = pageO;
/* Init */

void param_pass (float var1)
{

printf ("value

= %f", var1);

/* set initial values for global variables */

void init ()

boolean herc there ()

-

{

/* test for presence of Hercules card */

int i;

solves the problem. There shouldn't
have been a problem. Things get worse
when you use inline assembly language.
Now, anytime you use a float in an assignment statement, the compiler does
some funny casting and MASM gags.
(Hence the popular expression, "That's
enough to gag a MASM.")
But I love Turbo C in spite of these
annoyances. The integrated environment
makes program development much
easier. And compilation and execution
times are impressive. I wish Borland had
had its act together for version 1.0, but
so far I've been able to work around the
problems.

geninterrupt (Ox11);
if « AX & Ox30) == Ox30)
/* check for monochrome card presence */
for-(i = 0; i < Ox800; i++)
/* is it a Herc? */
if (inportb (status) & Ox80)
/* watch bit 7 */
return yes;
return no;
/* herc_there */
void ·screen off ()

-

{

outportb (mode, 2);
/* screen_off */
void set-page_viewed (int page)
{

if (page == pageO)
outportb (mode, OxOa);
else
outportb (mode, Ox8a);
page viewed = page;
/* set-page_viewed */
void set-page_drawn (int page)

Play Time
I've covered only· the bare essentials,
but they'll be enough to get you started.
If you're interested, I'll go over arc
drawing, shape filling, and the like in a
future article. So do some fractals or
spiff up your latest program. Enjoy
yourself. Graphics needn't be useful, just
fun.

•••

{

page drawn = page;
/* set-page_drawn */
void clear gr scr (int page)

- -

{

int i;
if (page viewed == page)
screen-off ();
for (i =-0; i < Ox3FFF; i++)
poke (page, 2 * i, 0);
if (page viewed == page)
set-page_viewed (page);
/* clear_gr_scr */

/* turn off screen if page is displayed */

/* reset all bits in the page */
/* turn screen on again */

void clear txt scr ()

--

{

int i;
for (i = 0; i <= Ox3fff; i++)
/* fill text pg with nuls & attribute 7 */
poke (text base, 2 * i, Ox0700);
/* clear_txt_scr */

26 MICRO CORNUCOPIA, #39, Jan-Feb 1988

void scr write (int X, int Y, char str [81], char attrib)
{
/* direct memory write of text */
int i, offset;
i = 0;
offset = 2 * (80 * Y + X); /* find memory offset of first char in str */
while (str [i] != '\0')
/* poke each char/attrib pair */

FORTHkit
5 Mips computer kit

{

pokeb (text base, offset, str [ill;
pokeb (text=base, ++offset, attrib);
i++;
offset++;

$400

/* scr_write */
void

set_graph~cs

Includes:

()

{

char i;
char params [12] = {Ox35, Ox2d, Ox2e, Ox07, Ox5b, Ox02,
Ox57, Ox57, Ox02, Ox03, OxOO, OxOO};
outportb (config, 3);
screen off ();
for (i-= 0; i < 12; i++)

/* allows both graphics pages */
/* program 6845 registers for graphics */

Novix NC4000 micro
160x 1OOmm Fk3 board
Press-fit sockets
2 4K PROMs

{

outportb (index, i);
outportb (data, params [ill;

Instructions:
/* clear and turn on screen */

clear gr scr (pageO);
clear-gr-scr (pagel);
/* s;t_graphics */

Easy assembly
cmFORTH listing
shadows
Application Notes
Brodie on N C4000

void set text ()

-

{

char i;
char params [12]

{Ox6l, Ox50, Ox52, OxOf, Ox19, Ox06,
Ox19, Ox19, Ox02, OxOd, OxOb, OxOc};
/* lock out graphics modes */
/* set text mode and blank screen */
/* program 6845 registers for text */

outportb (config, 0);
outportb (mode, 0);
for (i = 0; i < 12; i++)
{

outportb (index, i);
outportb (data, params [ill;
clear_txt_scr ();
outportb (mode, Ox28);
/* set_text */

/* enable blink and turn on screen */

void save screen (char fname [13], int page)

/* write to disk */

You provide:
6 Static RAMs
4 or 5 MHz oscillator
Misc. parts
250mA @ 5V
Serial line to host

FILE *f;
char far *screen;
screen = page * OxlOOOO;
f = fopen (fname, "w");
fwrite (screen, screen_size, 1, f);
fclose (f);
/* save_screen */
void get screen (char fname [13],

{

-

/* wierd, but it works */

int page)

/* read from disk */

FILE *f;
char far *screen;
screen = page * OxlOOOO;
f = fopen (fname, "r");
screen_off ();
fread (screen, screen size, 1, f);
set-page_viewed (page);
fclose (f);
/* get_screen */

/* turn the screen back on */

Supports:
8 Pin/socket slots
Eurocard connector
Floppy, printer,
video I/O
272K on-board memory
Maxim RS-232 chip

Inquire:
Chuck Moore's

void draw-point (int col, int row, boolean fill)
{

int byte ofs;
char mask;

/* offset within page for byte containing the point */
/* locates point within the byte */

mask = 1 « (7 - (col % 8»;
byte ofs = Ox2000 * (row % 4) + 90 * (row / 4) + (col / 8);
if-(fill)
/* draw the
pokeb (page_drawn, byte_ofs, peekb (page drawn, byte_ofs)
else
/* erase the
pokeb (page drawn, byte_ofs, peekb (page_drawn, byte_ofs)
/* draw-point */

point */
I mask);
point */
& -mask);

Computer Cowboys
410 Star Hill Road
Woodside, CA 94062
(415) 851-4362

Reader Service Number 21

MICRO CORNUCOPIA, #39, Jan-Feb 1988

27

UNINTERRUPTABLE
POWER SOURCE

void draw line (int Xl, int YI, int X2, int Y2, boolean on)
{/* use Bresenham's algorithm to draw a line
int dX, dY;
/* vector components
int row, col,
final,
/* final row or column number
G,
/* used to test for new row or column
incl,
/* G increment when row or column doesn't change
inc2;
/* G increment when row or column changes
boolean pos_slope;
dX = X2 - Xl;
dY = Y2 - YI;
pos slope
(dX > 0);
i f (dY < 0)
pos slope = !pos slope;
if (~s (dX) > abs-(dY»

MICRO

SOLUTIONS protects your equipment
and your data from power outages and
brownouts: Our power systems provide
the fastest switching speed in the industry (2 ms± 1).

watts
watts
watts
watts
watts

*/
*/
*/
*/

/* find vector components */
/* is slope positive? */

/* shallow line case */

{

if (dX > 0)

/* determine start point and last column */

{

col = Xl;
row = YI;
final = X2;

EMI/RFI filtering and surge/spike protection all in one affordable unit. 1 year warranty on all units. Available in a size to
suit your needs 200
350
550
800
1000

*/
*/

else
col
X2;
row
Y2;
final = Xl;

$290.00
$360.00
$410.00
$610.00
$710.00

incl = 2 * ahs (dY);
/* determine increments and initial G */
incl - ahs (dX);
inc2 = 2 * (abs (dY) - ahs (dX»;
if (pos slope)
while-(col <= final)
/* step thru cols. checking for new row */

~'=

{

Includes shipping to your door in the continental U.S .. As specialists in overseas
systems, we can supply 220 volt units.
Call or write for details.

draw-point (col, row, on);
col++;
i f (G
{

>=

/* it's time to change rows */

0)

row++;
/* positive slope, so increment through the rows */
G += inc2;

SOFTWARE SPECIAL

else
G += incl;

BROOKLYN BRIDGE

/* stay at the same row */

else
while (col <= final)

The BROOKLYN BRIDGE supplies the
link between the new PS/2 IBM computers or laptops that use 3.5" diskettes
and the rest of the MS-DOS world still
using 51f.1" drives. The cable supplied will
allow you to transfer files and software
between the two computers FAST. Simple
to use and reliable. Get it now for only
$99.00

/* step thru cols. checking for new row */

{

draw-point (col, row, on);
col++;
if (G > 0)

/* it's time to change rows */

{

row--;
/* negative slope, so decrement through the rows */
G += inc2;
else
G += incl;

/* stay at the same row */

}

/* if IdXl > IdYl */
else

r&!Asher

i f (dY > 0)

ASHER TECHNOLOGY PUTS FAX ON
YOUR DESKTOP OR YOU CAN TAKE IT
WITH YOU ON YOUR LAPTOP FOR
LESS THAN $500. We have found the
answer to every small business's need for
FAX at a price they can afford, and that
works. Get in on this exciting new
technology. Call for free demo disk!

Iiiiiiii1
I!!!!!I

I

col = Xl;
row = YI;
final = Y2;
else
{

col
X2;
row
Y2;
final = YI;
incl = 2 * ahs (dX);
/* determine increments and initial G */
G = incl - ahs (dY);
inc2 = 2 * (ahs (dX) - ahs (dY»;
i f (pos slope)
while-(row <= final) /* step thru rows - check for new column */

C R 0

_SOLUTIONS

{

P.O. Box '166 Riner, VA 24149
1-800-323-4829
(703) 382-6624
call 24 hours - 7 days a week
Visa

draw-point (col, row, on);
row++;
if (G >= 0)
col++;

Dealers Supported

Reader Service Number 24

28

MICRO CORNUCOPIA, #39, Jan-Feb 1988
---------------

/* it's time to change columns */

{

MasterCard C.O.D.

We Ship Worldwide

/* determine start point and last row */

{

RON ANGERT S

M

/* steep line case */

--------~---

...

/* pos. slope, so increment through the columns */

G += inc2;
else
G += inc1;

/* stay at the same column */

else
while (row <= final) /* step thru rows checking for new column */

you use a
SCIENTIFIC OR FINANCIAL
CALCULATOR and a
PERSONAL COMPUTER,
you need the

{

draw-point (col, row, on);
row++;
i f (G > 0)

/* it's time to change columns */

{

co1--;
G += inc2;

/* neg slope, so decrement through the columns */

else
G += inc1;

/* stay at the same column */

PC HYPERCALCULATOR.
YOU NEED: A pop-up scientific/financial
calculator for the IBM PC Integrated with
every program you use.
YOU NEED: A programmable calculator
with 100 registers, 1000 program steps,
and alphanumeric prompts.
YOU NEED: A faithful emulation of the
Hewlett-Packard H P-11 C and H P-12C
that runs 20-40 times faster.
YOU NEED: Only $49.95 plus $3 for
shipping (includes free 8087 version
and utility programs).

}

/* draw_line */

Figure 2 - 6845 Registers
Settings (hex)
Text
Graphics

Register

Function

o

Total horizontal characters
Displayed horizontal characters
Horizontal sync position
Sync width
Total vertical rows
Vertical total adjust
Vertical rows displayed
Vertical sync position
Interlace mode and skew
Maximum scan line address
Cursor's starting scan line
Cursor's ending scan line

1
2
3
4
5
6
7
8
9
10
11

61
50
52
Of
19
06
19
19
02
Od
Ob
Oc

35
2d
2e
07
5b
02
57
57
02
03
00
00

Stop copying from calculator
to computer now!
Call toll-free:
(800) 628-2828, ext. 502
Sunderland Software Associates
Post Office Box 7000-64
Redondo Beach, CA 90277
HP-llC. HP-12C and IBM PC are trademarks of
Hewlett-Packard Co. and International Business Machines
Corp .• respectively.

Reader Service Number 41

CBTREE does it all! Your best value in a B+tree source!
Save programming time and effort.

Access any record or group of records by:

You can develop exciting file access programs quickly and easily because
CBTREE provides a simple but powerful program interface to all B+tree
operations. Every aspect of CBTREE is covered thoroughly in the 70 page
Users Manual with complete examples. Sample programs are provided on
disk.

• Get first
• Get previous
• Get less than
• Get greater than
• Get sequential block
• Get all partial matches
• Insert key and record
• Delete key and record
• Change record location

Gain flexibility in designing your applications.
CBTREE lets you use multiple keys, variable key lengths, concatenated
keys, and any data record size and record length. You can customize the
B+tree parameters using utilities provided.

Your programs will be using the most efficient searching techniques.

CBTREE provides the fastest keyed file access performance,
with multiple indexes in a single file and crash recovery utilities.
CBTREE is a full function implementation of the industry
standard B+tree access method and is proven in applications
since 1984.

• Get last
• Get next
• Get less than or equal
• Get greater than or equal
• Get partial key match
··Get all keys and locations
• Insert key
• Delete key

Increase your implementation productivity.
CBTREE is over 6,000 lines of tightly written, commented C source code.
The driver module is only 20K and links into your programs.

Port your applications to other machine environments.
The C source code that you receive can be compiled on all popular C
compilers for the IBM PC and also under Unix, Xenix, and AmigaDos! No
royalties on your applications that use CBTREE. CBTREE supports multiuser and network applications.

CBTREE IS TROUBLE-FREE, BUT IF YOU NEED HELP WE PROVIDE FREE PHONE SUPPORT.
ONE CALL GETS YOU THE ANSWER TO ANY QUESTION!
CBTREE compares favorably with other software selling at 2,3 and 4 times our price.
Sold on unconditional money-back guarantee.
YOU PAY ONLY $99.00 - A MONEY-SAVING PRICE!
TO ORDER OR FOR ADDITIONAL INFORMATION
CALL (703) 356-7029 or (703) 847-1743
OR WRITE
1]i!'~P'1"~~~,!:r1tt~.ri~~\~t':t~'·~t'~

j:';;\~':"

r~

." ':~:~Pe'a~ock
iIf~~,j,};~l~"t..;.\'~:~~t~II'r'Cll·}/r,.j,,"
'J"

"I]

"~

~

I

IJi/~''llk'\~)''(' j:~ _~~

,

1

,

1

_:

~I·" t:I,~'/'t~!:~

Reader Service Number 20

MICRO CORNUCOPIA, #39, Jan-Feb 1988

29

Controlling Synchronous Serial Chips
With A Parallel Port
Long Distance Data Transfers At Incredible Speeds

This month I'm going to show you how
· to use your parallel printer port to control
serial TTL chips. The output chip will drive
a seven segment display, and the input chip
will read setpoint values from the outside
! world. The Turbo C code is a background
-task triggered by the serial clock interrupt,
so you can run all your normal programs
-while monitoring and controlling an external
process. Real Multitasking! But first, a little
deviation.

y friend Daniel Will-Harris has
written his first book, called
"Desktop Publishing With Style."
:It's filled with great examples and is
; MUST reading if you're into serious
~ desktop publishing on the Pc.
Daniel and I have competed in every, thing since junior high school. There was
even a bet about who was going to be
. taller (for which, I might mention, I've
'never been paid. Ahem). So when I
,found out he was writing a book, I of
course got busy outlining MY book.
While researching it, I discovered a
problem. Desktop publishing is a new
'field, and Daniel's book is the first which
isn't just a rehash of a manual for people
who've nipped the program. There are,
'however,many good electronics books.
And as I read through them, I 'found
much of what I was going to talk about
already on paper. Could I really make a
;worthwhile contribution when the subject 'has been so well covered?
-

M

Chapter Two
Everyone's working on chapter two
of a book, right? SO;until I come, up with
a really smashing idea, I'll give you a list
of electronics books which I've found
'clear and valuable:
(1) The Art Of Electronics, by Horowitz

30

and Hill. Sophisticated enough for
designers, but with a nuts-n-bolts feel to
it.
(2) The Texas Instruments TTL Data
Book and the National Semiconductor
Linear Data Book. A CMOS data book is
also handy. Page through these and look
at the diagrams. After a while, your
brain will decide things aren't intolerably complicated.
(3) Forrest Mim's Circuit Scrapbook II
(I don't have "I", but I assume it's as
good). This guy has been designing
small, clever circuits and writing clearly
about them for as long as I can remember. I expect to get some article inspirations from this book.
(4) Don Lancaster's TTL and CMOS
cookbooks are good introductions with
many simple circuits. You could probably use these in lieu of data books for a
while.
Books which deal with the innards of,
and electronic interfacing to, PC's-,
(5) The IBM PC From the Inside Out,
by Sargent and Shoemaker. A great
book: it explains electronics AND interfacing AND PC hardware. Buy it first.
(6) Interfacing to the IBM Personal Computer, by Eggebrecht. This is a condensation and clarification of the technical
manuals. This book has more than its
share of errors, but it's good for PC bus
interfacing.
(7) The IBM technical manuals. If
there's one thing Big Blue can do, it's
, document. The Rom BIOS listings are
very useful as examples.
(8) Programmer's Problem Solver for the
IBM PC, XT & AT, by Jourdain. Bite-size
examples about each and every internal
organ of the Pc.
(9) Joseph Carr's books seem to cover
the same topics, but he presents the subject well. I have Interfacing Your Computer to Virtually Anything from TAB
(how's that for a one-line movie plot?).
There. That ought to keep you busy.

MICRO CORNUCOPIA, #39, Jan-Feb 1988

Synchronous Communications
And now down to business. In the
last issue, I went into all the details of
the $21 Microsphere parallel printer card
(which is identical to most others), so
you know how to use it to control
hardware. Now we'll do a rather odd
thing: use the parallel port to control
serial hardware.
This isn't serial hardware like you're
used to thinking of: the serial port on
your computer. Those are asynchronous
serial ports, which means you give the
UART
(Universal
Asynchronous
Receiver-Transmitter) chip a byte, and it
sends it out on a single wire, without
any other wire containing synchronizing
information (Le., an additional clock signal to tell the receiving unit when the
bits are valid).
Asynchronous transmission is tricky
in that each bit transmits during a certain precise period of time within the
byte transmission. And each byte is surrounded by start and stop bits to mark
the beginning and the end. The timing
information is, in essence, built into the
signal.
A synchronous interface has separate
data and clock lines. To send information, you put a bit on the data line, cycle
the clock, put the next bit on the data
line, etc. To receive information, you
read the data line, cycle the clock, etc.
This system has two big advantages:
(1) speed, and (2) the elimination of critical timing requirements. The fastest
UART usually runs at 19.2 Kbaud
(19,200 bits per second; the Zilog SCCSerial Communications Controller on the
Macintosh can run at 2 Mbaud, but it's
not exactly the cheap, common UART
used in RS-232).
In a synchronous system, we're only
limited by the speed of our logic, which
can be significant since any sort of serial
communication is generally slower than
parallel transfers. In this case, we're

By Bruce Eckel
Eisys Consulting
1009 North 36th St.
Seattle, WA 98103

limited by the speed of the PC since
we're "bit banging."
Since we control the clock there are
no critical timing requirements. If an interrupt occurs in the middle of a byte,
fine: we can pick up whenever it's
finished without corrupting anything.
This is very convenient for software
control. It's possible to make a software
UART, but it must never be interrupted:
so it won't work on a Pc.

Figure IA - Converting Serial To Parallel.
+5V

PORT CONNECTIONS
OB-25 PIN 3
ADDRESS
BASE: BIT 1

QH 1-'.:,..3--< h (decimal poInt)
QG 12
9
Q,I-'..;....1_-<
Q
1(3
e

2 SERIAL IN B

>-_ _1---..." SERIAL IN A
9-CLfAR

E

Q

Just Two Little Chips ...
Figure 1 shows a circuit for eight bits
of synchronous serial input and output.
I tried to be clever and minimize the
number of communication lines.
Originally I used three: one for clock,
one for control,' and one for data (you'll
recall from issue #38 that four lines on
the parallel port can be read AND written). But I found the single data I/O line
was getting corrupted by the LS165, so I
used separate data input and output
lines.
I discovered the LS165 was STILL
messing with the LS164. I gave it a
separate load/select line to pin one.
,Things started working right, so I rearranged the proto-board. I accidentally
pulled an important wire, but it kept on
working anyway. I couldn't figure out
why. I finally threw up my hands and
stopped trying to save wires. You can
probably find ways to combine them,
but I had a deadline.
So much for clever. The PC turned
out to be very useful for debugging
, hardware. One generally has to fe~ch an
oscilloscope or logic analyzer to figure
out what's happening. When driving
the logic with a PC, however, you simply put in printfO's and getchO's. The latter causes the program to pause until
you'hit a key, to slow the thing down to
a crawl. You can watch what's happening and tweak the lines any way you
want. I prefer it to an oscilloscope, and
it's MUCH cheaper.

OB-25 PIN 2
ADDRESS
BASE: BIT (3

SEVEN SEGMENT .
DISPLAY CONNECllONS
(SEE FlG. 3)

7
...---VC{;.L...----GNl..----,
D

PARALlEL PRINTER

8
>-----L> CLOCK

f-6_ _< d

o5

Qc~--<

e

4
QBf-- - < b
QAI-3_ _----+
SWITCH WILL "BOUNCE- (CHATIER)
AS IT· CLOSES, BUT WE ARE SAMPUNG
SO SLOW!.Y IT DOESN'T MATIER.

Figure SB - LM339 Quad Comparator Pinout

14

9

8

GROUND ALL' PINS OF
UNUSED COMPARATORS

5

2

6

7

Figure SC - One Bit AID Converter

and 68001218/9

+5V

SOFTWARE
SK*DOS - a powerful DOS
for the 6809 ($75) or the
68000 ($140, incl. an editor,
assembler, Basic, utilities,
code for a boot ROM, etc.)
HUMBUG - a monitor/boot
ROM, $50 - $75.
OlliER SYSTEM SOFTWARE including assemblers, text formatters, editors,
spell checkers, languages,
etc., all very reasonable.

'10

GND

•••

_ee__

11

13

+5V

~0K

-

THERMISTOR, CdS UGHT
CELL OR OTHER
RESISTIVE SENSOR.

-

MEASURE THE RESISTANCE
OF YOUR SENSOR AROUND
ITS THRESHOLD VALUE.
CHOOSE A ROUGHLY EQUAL
RESISTOR VALUE.

m

INPUT >--+--<
PIN
NOTE: LM324
CAN ALSO BE
USED. IT HAS
'A DIFFERENT
PINOUT.

+5V

i
-=-

POTENTIOMETER
THRESHOLD
ADJUSTMENT
(SMAll. 111lK, '0 TURN.
IT'S NOT TOO CRITICAL
WHAT. YOU USE)

-=-

Figure'SD - Monitoring Several Thresholds on the Same Sensor

HARDWARE
A wide selection of singleboard computers and systems, from $275.

+5V
SENSOR

COMBINATIONS
Package deals of fast and
powerful computer plus DOS
and more, from $350.

~R-K

SOFTWAR E SYSTEMS CORP.

BOX 209 • MT. KISCO, NY 10549
914/241-028~

Reader Service Number 40

34

MICRO CORNUCOPIA, #39, Ian-Feb 1988

RESISTOR
CHOSEN AS
IN' FlG.' 5C.

New, Lower Prices for CP/M
• VEDIT Version 1.40 ........... $49 (Single file, no windows)
• VEDIT PWS Version 2.32 ...... $79 (Multiple file, no windows)
• VEDIT PWS Version 2.33 ...... $95 (Current version with windows)

PROGRAMMABLE
EDITOR
FREE Fully Functional
Demo Disk *
Stunning speed. Unmatched performance. Total flexibility. Simple and intuitive operation. The newest VEDIT
PLUS defies comparison.

. . Call for 286 I XENIX Version
Fully Network Compatible

Try A Dazzling Demo Yourself.
The free demo disk is fully functional - you can try all
features yourself. Best, the demo includes a dazzling
menu-driven tutorial - you experiment in one window
while another gives instructions.

•
•
•
•
•
•
•
•
•

Simultaneously edit up to 37 files of unlimited size.
Split the screen into variable sized windows.
'Virtual' disk buffering simplifies editing of large files.
Memory management supports up to 640K.
Execute DOS commands or other programs.
MS-DOS path name support.
Horizontal scrolling - edit long lines.
Flexible 'cut and paste' with 36 'scratch-pad' buffers.
Customization - determine your own keyboard layout, create
your own editing functions, support any screen size.
• Optimized for IBM PC/>IT/AT. Color windows. 43 line EGA.

The powerful 'macro' programming language helps you
eliminate repetitive editing tasks. The impressive
demo/tutorial is written entirely as a 'macro' - it shows that
no other editor's 'macro' language even comes close.
Go ahead. Call for your free demo today. You'll see why
VEDIT PLUS has been the #1 choice of programmers,
writers and engineers since 1980.

EASY TO USE

Available for IBM PC, Tandy 2000, DEC Rainbow, MSDOS, CP/M-86 and CP/M-80. (Yes! We support windows
on most CRT terminals, including CRT's connected to an
IBM PC.) Order direct or from your dealer. $185.

Compare features
and speed
'Off the cuff' macros
Built-in macros
Keystroke macros
Multiple file editing
Windows
Macro execution window
Trace & Breakpoint macros
Execute DOS commands
Configurable keyboard
Layout
'Cut and paste' buffers
Undo line changes
Paragraph justification
On-line calculator
Manual size / index

BRIEF

Norton
Editor

PMATE

•
•
•
•
•

VEDIT
PLUS

No
Yes
Only 1
20+
20+
No
No
Yes

No
No
No
2
2
No
No
Yes

Yes
Yes
No
No
No
No
Yes
Yes

Yes
Yes
100+
20+
20+
Yes
Yes
Yes

Hard
1
Yes
No
No
250/No

No
1
No
No
No
42/No

Hard
1
No
No
No
469/Yes

Easy
36
Yes
Yes
Yes
380/Yes

FOR PROGRAMMERS

• Automatic IndenVUndent for 'C', PLJI, PASCAL, etc.
• Match/check nested parentheses, i.e. T and '}' for 'C'.
• Automatic conversion to upper case for assembly language
labels, opcodes, operands with comments unchanged.
• Optional 8080 to 8086 source code translator.
FOR WRITERS

•
•
•
•
•

1 :15 min 34 sec
20 sec Cannot
2:40 min Cannot

• 'If-then-else', looping, testing, branching, user prompts,
keyboard input, 17 bit algebraic expressions, variables.
• Flexible windowing - forms entry, select size, color, etc.
• Simplifies complex text processing, formatting, conversions
and translations.
• Complete TECD capability.
• Free macros: • Full screen file compare/merge. Sort mailing
lists • Print Formatter. Menu-driven tutorial

1 :07 min 6 sec
Cannot 2 sec
Cannot 11 sec

~;~~~:~~ ~°tT~~~~:r:.rfn~~~~A~~ l~a~~~~~k~:r~ ~~~~~~~i~ i~~~~~I~g:~;'L~~~~~:tSo~
Editor is a trademark of Peter Norton Computing Inc.

*. Demo Disk is fully functional. but does not readily write large files.

Reader Service Number 7

Word Wrap and paragraph formatting at adjustable margins.
Right margin justification.
Support foreign, graphic and special characters.
Convert to/from WordStar and mainframe files.
Print any portion of file; selectable printer margins.

MACRO PROGRAMMING LANGUAGE

Benchmarks in 120K File:
2000 replacements
Pattern matching search
Pattern matching replace

Interactive on-line help is user changeable and expandable.
On-line integer calculator (also algebraic expressions).
Single key search and global or selective replace.
Pop-up menus for easy access to many editing functions.
Keystroke macros speed editing, 'hot keys' for menu
functions.

'

CompuView

1955 Pauline Blvd., Ann Arbor, Ml 48103 (313) 996-1299, TELEX 701821

Figure 6 - Turbo C source of Synchronous Interface.
/* Complete listing (1)

-- CLOCKINT.C, MYFUNC.C,

SERIAL.C, COLORS.H */

/* CLOCKINT.C : Turbo C program to install your own interrupt
function in the clock interrupt, while still preserving everyone
else's. Bruce Eckel, Eisys Consulting 1987. To make the control
program, you must create a project file which contains the
following, and make it's file the "project name": colors.h is a
header which the C file includes; if the header gets changed,
that C file will be re-compiled even if it wasn't modified
itself. */
#define CLOCKINT 8

/* IRQO on the 8259 is interrupt 8 in the
vector table */

#define PROG SIZE Ox87F
/* Run the Turbo C compiler with the
options: linker: mapfile set to "segments."
Look at the mapfile
generated for this program.
The" stop" address for the stack is
the highest adress used -- set PROG SIZE to this value for use
with the "keep()" command */
void interrupt

(*old_int_handler) ();

/* This, believe it or not, is a variable declaration.
I've put
it way out here (outside of any function declarations) so it
doesn't go away when main exits (i.e. it's global). It holds the
address of the old interrupt handler function so the NEW
interrupt handler can call the OLD one when it's through. To read
it, start in the middle and work your way out: old int handler is
a POINTER (" *") to a FUNCTION (" () ") of type "inte~rupt"; this
function doesn't return a value ("void").
*/'
maine)
/* all this does is install the interrupt handler.
I
don't use any "printf () sIt because it increases the
resident program size so much. */

/* first: function prototypes, right out of the book.
These
don't generate any code, but they tell the compiler (and us)
exactly how the functions should be called so it can catch
mistakes.
The same effect can be achieved with "#include
", but this is more educational. */
extern void interrupt (*getvect(int intr num» ();
/* The above declaration is tricky to read: getvect returns a
pointer to a function of type interrupt (and an "interrupt"
function never returns a value, thus the "void").
It's deceiving
because the function "getvect" is actually returning something,
but the first word you see is "void" */
extern void setvect(int intr num, void interrupt (*isr) (»;
/* This function really DOESN'T return return anything.
It must
be passed an integer and a pointer to a function of type
interrupt which has no return value.
The ability to pass
function addresses around allows us to almost entirely eliminate
the need for assembly language when using C. */
void interrupt my int handler();
/* Prototype for the interrupt we are
chain (a lot like inserting an item
the word "extern" doesn't appear in
function definition is contained in

inserting in the clock
in a linked list).
Notice
this declaration because the
this file. */

/* The code is trivial: get the old clock interrupt vector (for
our routine to pass control to when it's done), install our
routine as the new interrupt service routine, and call "terminate'
but stay ready." * /
old_int_handler = getvect(CLOCKINT);

/* store the address of the old
handler */

setvect (CLOCKINT, my_int_handler);.
keep(O,PROG_SIZE);
/* first parameter is exit status */

(Listing continues 011 page 38.)

36

MICRO CORNUCOPIA, #39, Jan-Feb 1988

DEBUIiIiINIi SWA,. ,.EAM
Order fco-C88 Rei. 4.0 New Modeling Compiler
and get C-more at no extra charge!
Seek and Correct
You already know that fast compilation does not mean fast program development. Backing
up for bogus error messages and removing the bugs takes time. Eco-C88's "Seek and Correct"
three - way error checking finds even the most elusive bugs, clearing the path for swift program
development.

Double Barrel Error Checking
Eco-C88 nails syntax errors cold and tells you about the error in plain
English. And there's no avalanche of false error messages, either. Other
compilers can generate up to four times the number of error messages
actually present; they leave it up to you to guess which ones are
real. You'll be more productive with Eco-C88 because there is no
guess work.
Eco-C88 provides ten levels of semantic error checking. You can
select from almost no checking to the fussiest you've ever seen.
Eco-C88's "picky flag" finds subtle errors that slip by
other compilers.

Eco-C88 also features:
• All data types, plus ANSI Enhancements
• Robust library, including many new ANSI
functions
o CED editor with online function help, split
windows, compile-edit-link capability
o New, expanded manual with sample programs for the library functions

C-more Source Code
Debugger
Finally, if a really nasty bug persists,
put C-more, our source code debugger, to work. With C-more you can
watch your program as it executes,
single-step it, set simple or conditional
breakpoints, test complex expressions,
use variables as indexes into other variables, initialize and trace variables, examine
CPU registers, display results with printfOtype options and much more. C-more can help
you track down bugs in minutes rather than days.
The price for Eco-CB8 is $99.95. And, for a
limited time, we'll give you our C-more debugger
at no extra charge.

Ecosoft Inc.
6413 N. College Ave.
Indianapolis, IN 46220
(317) 255-6476 (Tech Info)
(800) 952-0472 (Orders)

(Listing continued from page 36.)
void 'interrupt my_ int_handler ( )
{

extern void my function();
/* i.e.: this is defined in another file */
const int clock_count
9;
/* wait this many ints between invoking our
function; there are about 18 interrupts per second. */
/* The interrupt counter doesn't go away
static int i = 0;
between interrupts */

=

clock_count) { my_function(); i = O;}
/* Do whatever we want ... */
/* (with the usual caveat that we can't make any DOS or BIOS calls) */
(*old_int_handler) ();
/* ... and continue the chain by de-referencing the
pointer to the old clock service routine.
*/
/*
This was just TOO easy!! */
if(i++

==

}

/* A caveat: I haven't done extensive testing, so this could slow
down the time-of-day clock on the PC.
If it does, one might add
a function to restore the correct time from the battery-backed
clock-calendar.
*/
/* MYFUNC.C: Turbo C function installed as a TSR by CLOCKINT.C.
Bruce Eckel, Eisys Consulting 1987.
This integrates the serial
input and output functions, and some screen display code from
issue #38 (which must be used since an interrupt routine can't
make DOS calls; i.e. DOS isn't re-entrant).
Each time
my function() is called, it outputs a new character from the
led table[] to the serial-to-parallel chip, gets a byte from the
parallel-to-serial chip, and displays the byte as ones and zeroes
in the lower right corner of the screen.
You can replace the code in my function() with anything else
(as long as your code or any C-library functions you call don't
make DOS or ROM BIOS calls -- printf() does) .to create your own
clock interrupt background process. */
#include "colors.h"

/* #defines for the CGA */

/* Now we tell the compiler that "led table []" is in another
file.
We still have to show what it looks like so the compiler
can generate the right code when we reference elements of the
structure.
The actual address of led table[] is figured out
("resolved") by the linker.
This type of declar~tion is often
contained in a header file as a "typedef."
The header file is
then included in the file where the table is defined and any
other files where it is declared.
Note, however, that a header
file with anything other than definitions in it (i. e. code) is
asking for trouble. */
extern const struct {
char character;
unsigned char code;
} led_table [] ;
/* Here's the function which is called by my_int_handler()
void my_function()

*/

{

void display byte(unsigned char byte);
extern void outbyte(unsigned char ch);
extern unsigned char inbyte();
static int i = 0;
/* statics don't go away between function
calls, so we don't output the first character every time.
only initialized to zero when the program is loaded. */

It's

/* Read the LS165 and display it on the screen. */
/* send a character to the seven~seqment
display.*/
0) /* increment the table index and see if
we're at the end of the table; */
/* if so, start over.
*/

display byte(inbyte(»;
outbyte(led_table[i] .code);
if(led_table[++i].code
i

=

0;

==

(Listing continues on page 40.)

38

MICRO CORNUCOPIA, #39, Ian-Feb 1988

UAI TE:n
I

I • • _1

-Ie PROGRAMMERS-

RACAUVADIC
STANDALONE

'lJ/AT COMPATIBLE

ALL USE SINGLE SLOT IN YOUR Xl/AT AND INCLUDE
EXlERNAL PODS WITH ZERO INSERTION FORCE
SOCKET(S)

MODEM
MODEL 212LP
'1200/300 BAUD
• BELL 2121103 COMPATIBLE
• AUTO DIAUAUTO ANSWER
• OEM VERSION P.S. & CASE
NOT INCLUDED.

$1995

PAL PROGRAMMER '269.95
-PROGRAMS MOST 20 & 24 PIN PALS
-VERIFY. PROGRAM & BURN SECURITY FUSE LINK

8748/49 PROGRAMMER '199.85

SHUGART SA801 R 8" FLOPPY
DRIVE- SOaK SSDD • Still Sealed in
Factory Boxes ........ .

-EPROM PROGRAMMERS-

PROGRAMS 2m to 27512
12.5,21, 25V DEVICES INCLUDES SOFTWARE FOR
STANDARD & INTEL HEX FORMATS

SINGLE GANG ••••••••••••••••••••••• '109.95
FOUR GANG ••••••••••••••••••••••••'169.95
TEN GANG •••••••••••••••••••••••••'309.95

$ 149.00

.._---~\

\!\\\\i\\\\i\il\\li!:il

.1iiI• •a

HALF HEIGHT EXTERNAL
DRIVE ENCLOSURE
• Attractive Low Profile
Chassis 19x 15x2 l/,
• Fits nicely directly under PC
• Standard IBM Colors
• Bezel for 5'1'" and 3%" Drive
• 60 Watt P.S. wlDC Fan and Drive Cables

L1nON

HALTED SPECIALTIES offers its customers
Unique "SUPERMARKET STYLE" shopping
for ANY and ALL ELECTRONIC NEEDS. We
stock literally THOUSANDS of parts- from the
newest IC's to some of the first transistors.
ALSO, for the electronic enthusiast, we carry a
full line of computer accessories, test
equipment, tools, R+D supplies and much
more! PLEASE CALL OR VISIT ONE OF OUR
THREE RETAIL STORES TODAYI'

• NEW!! Tl 787 Terminal -

TRACKBALL
• 250 CYCLES PER REVOLUTION
• 5 VDC OPERATION
• SPEC. SHEET INCLUDED

$4995

• 120 CPS Thermal Printer
110 to 9600 BAUD MODEM: Bell
212, 103 + Racal3400 Compatible.
• Acoustic/Direct Connect
• RS·232 Interface, Includes Manuals, Cables & pape$r

.

3 CONVENIENT LOCA TlONS:
HSC Electronic Supply of Santa Rosa

I

II

5549 Hemlock St. _
Sacramento, CA~
(916) 338·2545

..0'

I

Double Sided-Double Density
360K
Tandon Full Ht. W/IBM Logo ...... '59.95 .
MPI Half Height ................ 69.95 .

aBUS SASI HOST ADAPTER.
·Made by Xebec ·Brand New!!
$35.00

ANDERSON/JACOBSEN Stand·
Alone MODEM- • 1200 Baud. Racal

3400 Compatible • Acoustic/direct Connect • • Originate Only • INCLUDES
MANUAL + CABLES. .......••

$ 29.95

. 249.00

WE SHIP C. O. D.

827 EVEL YN AVE., SUNNYVALE, CA 94086

HSC Electronic Supply

6819 S. Santa Rosa Ave.
Cotati, CA
(707) 792·2357

IBM COMPATIBLE
FLOPPY DRIVES

MA IL ORDERS

Store Hours:
Mon·Fri 8;00·7;00

Call NOW! (408J732-1573
Reader Service Number 11

MICRO CORNUCOPIA, #39, Jan-Feb 1988 .

39

(Listing continued from page 38.)

/* This function displays a byte as ones and zeroes in the lower
right corner of the CGA screen, without calling printf(). */
void display_byte(unsigned char byte)
{

void putc at location(char,

int, int, unsigned char);

/* you don't HAVE to give variable names in a declaration, but it's not
as clear if you don't. */
int i, column = 64;
/* "line" and "column" are the starting locations */
const int line = 24; /* The compiler barfs if we try to change a constant.*/
for ( i = 7; i >= 0; i--){ /* start with the high bit and work down */
putc at location(byte & (1 « i) ? '1' : '0', column++, line,
- LIGHT GREEN CHAR I RED BACK);
/* See SERIAL. C for a description of the ;';""?:" ternary expression. * /
putc_at_Iocation(' " column++, line, BLACK_CHAR I RED_BACK);
}

/* Puts a character and its attribute anywhere on the screen. */
void putc at location(char ch, int x, int y, unsigned char attribute)

- -

{

pokeb(SCREEN BASE, «y * SCREEN WIDTH) + x) * 2,ch);
pokeb (SCREEN_BASE, «(y * SCREEN_WIDTH) + x) * 2) + 1, attribute);
/* SERIAL.C: Turbo C program to write to a TTL LS164 and read
from an LS165 through a parallel printer card.
Bruce Eckel,
Eisys Consulting 1987. You can create either a stand-alone
program for testing, or link the compiled file into the
"CLOCKINT.C" project using CLOCKINT.PRJ. */
#undef test

/* #define test creates a stand-alone test program
from this file */
#define BASE Ox238· /* I modified my $21 Microsphere card so it's in an
unused address space (no collisions with other
printer cards) */
#define BIT (I)

(unsigned char) (1 « I )
/* this should be evaluated
at compile time so there won't be any overhead at
run time.
The" (unsigned char)" is called a "cast"
(like casting into a mold); it forces the result to
be that data type (in this case, one byte long and
don't mess with the high bit). */

/* These definitions make the code much easier to follow (and
thus less prone to error). "ORing" with a bit sets that bit to
"1", while "ANDing" with the complement of a bit sets that bit to
zero.
I'm being sort of tricky here: BASE is the printer data
address and can be read from as well as written to, so I read-it,
change a single bit, and write it out again so the other bits
aren't changed and can be used for other applications.
You can't
do this with the other printer port locations (BASE+l and
BASE+2).
It would probably be ~ore proper to use global memory
locations to preserve the state of all three. */
/* The output clock for the LS164:
*/
#define LOWER CLOCK 0
out port (BASE,inport(BASE) & ~BIT(O»
/* pin 2 on DB-25
#define RAISE:CLOCK:O
outport (BASE, inport (BASE) I
BIT (0»
/* Changing the output data bit for the LS164: */
#define DATA 0 (inport (BASE) & ~BIT(l»
/* pin 3 on DB-25
#define DATA-1 (inport(BASE) I
BIT(l»/* Load and shift control for the LS165
#define LOAD-LS165
outport(BASE, inport(BASE) & ~BIT(2»/* pin 4 on'DB"';25
#define SHIFT LS165
outport(BASE, inport(BASE) I BIT(2»
/* The input clock for the LS165:
*/
#define LOWER CLOCK I
outport(BASE,inport(BASE) & ~BIT(3»
/* pin 5 on DB-25
#define RAISE:CLOCK:I
outport(BASE,inport(BASE) I
BIT(3»
I

-----_._---- - - - - - - - - - - - - - - - - - - - - - -

*/
*/
*/
*/
*/

(Listing continues on page 42.)

The Ultimate Lap-Top

The MCfek286B Lap-Top combines the fastest, most reliable:, . '
AT motherboard available .
with the most visible full- l
size LCD lap-top screen i
on the·market. Running /l
at a switchable 8 orj
10 MHz, it includes l;~i
a 20MB hard disk, - - -_ _IIIIIill!!~~::.:J.:i:E.•~j;
~'?' .i.1:"'''.!'v.. ,':",•.•,,:.'wx,...."",.,,~ ••.....,
31/2" floppy drive,
electroluminescently backlit, 80-column by
parallel & serial ports, Award
3.01 bios, 640k, turbo indicator
25-line LCD with adjustable intensity and
LCD & mouse interface. The
screen-angle. It's as readable as a CRT.
screen is a fantastically readable,
You can also plug in a digital or analog
•.. ·.,:.:,.,.; •.• :.·,:· ..

.

color monitor or a digital
or composite monochrome
monitor. Included also is
an external 51/4" floppy port
for reading and converting
to 31/2" disks (51/4" external
drive w/case, power supply:
$179 when purchased with
"
.J,Lap-Top). The MCfek 286B
Lap-Top comes fully assembled with our one-year parts &
labor guarantee, and sells for
an amazing, complete price of only
0

$1899'

3 MB On-BoardAT! XT Turbos & Supers
Our MCTek 286A is the most integrated AT-compatible to date.
It utilizes the highly regarded Chips & Technology chip set, and
includes memory upgradable on board to 3 megabytes. No more
worries about speed compatibility with expanded memory cards!
The 8110MHz, 0-wait state MCfek 286A runs at 11.5 Norton SI, and
an effective 13.2MHz on the Landmark test. Serial, parallel & game
ports are all standard on board. With Award 3.01 bios, 640k, 200W
power supply, Samsung amber monitor with Hercules-compatible
controller, locking case, AT-style keyboard, 12MB drive, 20MB
Seagate. Assembled & fully tested, with a full one-year warranty.
~
Get in on the most advanced AT-compatible
on the market, at the lowest price ever offe~ed! :
:7
••

$1 99' ,

McTek Systems. Inc.• 2316 4

TH

640k 4.77/SMHz and 4.77110 switchable XT turboboards;
two 360k floppy-disk drives with controller; one parallel,
one serial and one game port; AT-style keyboard; clock,
FCC-approved slide-case; eight slots; H~rcules-compatible
graphics card; amber monitor w/base; fully assembled and
tested; one-year parts and labor warranty.

$649

DISK DRIVES

PRINTERS

MONITORS

PC/XT

Citizen CD 120 ........ $159
Citizen CO 180 ........ $189
HPLASAR SerlaI2 ••••• $1799
Epson LX-800 ......... $219
Toshiba 321 XL •••••••• $559
Call for prices of other brands

Samsung amber •••••••• $ 79
TVM EGA color ......... 399
TVM RGB color ......... 289
NEC Multisync .......... 559
Sony Multiscan •••••••••• 650
HGC-compat.mono card •• 55
Color graphic card ••••.•. 49
EGA Paradise" ......... 159

640k TurboMothrbrd •••• $ 85
10MHz TurboMothrbrd •••• 95
Multi I/O w/dlsk contrlr ••• 59
640K RAM card ........... 39
2MB expansion card ..... 115
RS232 2-port card •••••••• 35
4-serial port card ....••••• 95
Game I/O card ........... 15
384k Multifunction card .•. 69
FCC-app. slide XT case ... 28
150W power supply ••••.•• 59
XT keyboard ............. 52

MODEMS

Superturbo
4.77110MHz
Complete

$699

Street. Berkeley. CA 94710 • 415-843-0714

Fujitsu 360k ............. $75
Fujitsu 1.2MB".:" .. ",.. $99,
Teac ••.•••.••••.••••••.• $79
Teac 1.2MB ........... $105
Toshiba 3%" 720k ... " $119
Floppy controller " •.•••• $22
20MB Hard Disk Kit .... $289
30MB Hard Disk Kit •. " $319
ST-225 .••.••••••.•.••• $239
ST-238 ................ $269
ST-4038 ............... $529
ST-251 40MB" ........ $429

. Easydata Int. 300/1200 •.• $85
. Talheho external 3/12 .. $105
Everex 2400 external. •. $195

XTTurbo
4.77/SMHz
Complete

MOUSE
Logimouse C7 .......... $ 75

, MISC.

PC/AT
McTek286 6/8/10/12MHV. 299
Baby McTek 286B-AT
8/100-walt ........... 339
McTek 286A O-walt 3MB
4 ports on board ...... 449
3MB Multifunction card •• 125',
2MB expansion card .••.• 125
Multi I/O card ............ 59
Locking slide case •••••••• 65
200W power supply •.•••.• 79
AT-style keyboard ••• " ••• 55
WO HD/floppy controller. 149

"

'

Klngtech Portable Computer
Kits: XT/AT (power supply,
case, keyboard, monitor)
................... $380/410
Eprom burner 4-socket •• 139
Lap-Top Kits ............ 899
AC power center ••••••••. 25
AC power strips .......... 15
Diskette file box ........... 9
Printer or serial cable •••••• 8

Ventura Publishing
Software ......... $489

Reader Service Number 42

(Listing continued from page 40.)
/* This is a table with characters and the codes which generate them on
the seven-segment display:

*/

const struct. {
/* Notice the 'array declaration led table [) •
char character;
/* You don't have to put the number-of array
unsigned char code;
/* entries in the brackets; the compiler
led table [ ] =
/* counts them for you I
{ '~', Ox3f},
/* ~e seven-segment display:
{ '1', Ox30}, /*
{ , 2', Ox5b}, /*
a
bitO
{ , 3', Ox4f}, /*
{ '4', Ox66}, /*
I
I
{ , 5', Ox6d}, /*
f: bit 5 I
I b: bit 1
{ , 6', Ox7d}, /*
I g:
I
.{ '7', Ox07},' /*
I
I
l-b-i~t~6-1
{ '8', Ox7f}, /*
{ , 9', Ox6f}, /*
e:bit 4 I
I c: bit 2'
{ , A', Ox77}, /*
I
I
{ 'B', Ox7c}, /*
I
I
{ ',C', Ox39}, /*
d: bit 3
{ 'D', Ox5e}, /*
[*]
{ 'E', Ox79}, /*
h: bit 7
{ , F', Ox71}, /*
{ 'H', Ox76}, /* For example, the number 5 would use segments:
{ 'J', Oxle},' /* a, c, d, f , g which forms the binary number:
{ , L', Ox38}, /* 01101101 or the hex number Ox6d
{ 'N', Ox54}, /*
{ '0', Ox3f}, /* Some of the letters require a stretch of the
{ 'P', Ox73}, /* imagination, but they get the message across.
{ 'R', Ox50}, /*
{ , S', Ox6d},
{ 'T', Ox78},
{ 'U', Ox3E},
{ 'Y', Ox6E},
{ '?', Ox53},
{
Ox80},
{'-'
Ox40},
{ , =', Ox48},
{
Ox08},
{ '\O',O} /* this tags the end of the table, so new entries can
added without any other code modification.· */

*/

*/.
,*/
*/

*/
*/
*/
*/
*/
*/

*/

*/

*/
*/
*/
*/
*/

*/
*/

*/
*/
*/

*/
*/
*/

*/
*/

be

};

#if defined (test)
/* for stand-alone testing */
maine)
{ /* function declarations first: * /
void outbyte(unsigned char ch);
unsigned char inbyte();
void print_byte(unsigned char byte);
int i = 0;
char Chi
do {
print_byte(inbyte(»;

/* get a byte from the parallel-to-serial chip
and display it in binary */
ch = toupper(getch(»; /* get a keyboard character and convert to
upper case */
/* search the table until you find the character or hit the end. */

for(i = 0; led table[i] . character , != ch && led table[il.code !'= 0; i++)
; /* All the work is done inside the ';"for" parentheses. * /
outbyte(led_table[i].code);
/* send the code to the
.
~erial-to-parallel chip */
} while ( ch != 27 );
/* repeat until the "escape", key is pressed */
/* end of main */

/* I'm putting this definition inside the "#if (defined)" conditional
compilation because the code for'printf() is .very big arid I don't want
it included when the Terminate-And-Stay-Ready program is created.' * / '

(Listing continues on page 44.)

42

MICRO CORNUCOPIA, #39, Jan-Feb 1988

If You Don't Have WindowDOS 2.0,
You're Wasting Time!!·
" When Baba Ram Dass said "Be here now, remember, "designers of hard disk utilities should have paid heed. A
powerful manager like XTREE can track files and subdirectories and execute DOS commands, but it isn't memory resident. Handy pop-up DOS commanders like PopDOS may be here now, but they lack the power of a fullfledged disk manager. After much meditation, the developers of WindowDOS 2.0 have come up with the best
answer yet to the guru's paradox.
Until now, the closest thing to a real RAM-resident disk manager was version 1.0 of WindowDOS. If offered a fullscreen pop-up menu and could rename, copy, and delete files. But it couldn't move files, format disks, or rename
subdirectories-which XTREE can. Now version 2.0 is here, and its a winner. Its RAM resident (using/ess than
SDK) but offers all the power of a nonresident disk manager."
-Patrick Marshall, WindowDOS 2.0 Product Review, PC World, May, 1987
Once you've experienced the convenience of instant access to DOS commands, you'll neverbe satisfied with returning
to DOS to list files, format disks, or copy, rename, or erase files. Nor will you be happy with a DOS shell, because
shell programs are just as inaccessible as DOS when you are using an application program. Only one program
combines memory-residency with the power of a full-featured disk manager: WindowDOS Version 2.0.

Features Not Found In DOS
• Sort directories in 8 ways--or not at
all
.Copy, erase, and move groups of
files
• Find any file in seconds
• Display default directory of any
drive with a single keystroke
• Display graphic tree
• Global copy & erase commands
• Copy function prompts you to insert
another disk when necessary
• Display hidden files andsubdirectories
• Display file contents in various formats and page forwardlbackward
• Display Wordstar files in readable
format
• Unique RAM Environment function
shows name, size, location, and
interrupts of every program in
memory
• Rename subdirectories for instant
reorganization
• Hide and unhide subdirectories
• See and change file attributes
• Send control codes to printer
• Switch default printer
• Password "lock" your system
.Set AT Real-Time Clock
• 5-minute screen-blanking function
• Input response macros

Enhances These Functions
• Format disks (faster than DOS)
• Make and erase subdirectories
• Copy, rename, and erase files
• Copy files to printer or COM ports I:l:j::::i:j::: ;::::::::( .:: .. : .;, .. 2 .: : : . : ::: ' : : : :.
• Display disk free space and other
media information
:·:::::··:::;::::::.:.:::.H:: .. :.:.:· . .::. .: :?:. :: :.::. . :. :•.. .:. :. :. : :.: :..:. :•.
::: :;:::,:0:.. :.. : .: ...... .
• Check and set the time and date
::;:(l::::::':···
Benefits
• Saves Time-No waiting to exit or
reload programs. Instant access to
DOS functions whatever your
current task. Easily saves 10 or :~
more minutes a day.
;v
• Comprehensive-Broad range of
commands, including many not >
•••..•••••• <: ......................................................... ,.
supplied by DOS. Satisfies the
needs of both new and advanced
. ·'·::::::i~:::,,·.:.:'::':::·::··
users.
• Simplifies DOS-No need to
. '.~ . :
remember exact DOS commands.
Intuitive interface and "point and ,..--_ _ _ _ _ _ _ _ _ _ _-.,
shoot" design saves keystrokes and Other Information
prevents mistakes.
Group file
''tagging'' avoids the drudgery of • Not copy protected
• Uses only 51 K of memory
repetitive commands.
• Supports EGA & Hercules
• Security-Capability to hide/un• Runs memory-resident or as a
hide subdirectories, password
stand alone program
"lock" a computer, and check for un•
Uninstall command
wanted programs in RAM helps
• PC/XT/AT/100O/o Compatibles
secure data and prevent unauthor• Order Today-Only $49.95
ized access.

.•. .•.• .•.• .• • • • . . . .
~

······l!;,t
'~-::

::.':: :.::;;': ': .... :::,: ;;: ::;,: : : :.... :....'.: ..::.'.::.!.'. .:.:.:....
:

WindowDOS Associates - Box 300488-C -Arlington, Tx 76010 - 817-467-4103

!:

i: :.:.

(Listing continued from page 42.)
void print byte(unsigned char byte)

{

-

int i;
for(i = 7; i >=0; i--)
byte & (1 « i) ? printf("1 ") : printf("0 ");
/* See below for description of the "?: II ternary expression. * /
printf ("\n") ;
#endif defined (test)

/* You can put things after an

II #endif II
as notes to
yourself; the compiler ignores them. */

/* And now, the function definitions: */
void outbyte(unsigned char byte)
/*
Send a byte to the serial-to-parallel chip (LSI64)

*/

{

int i; .
RAISE_CLOCK_O;
/* This is just for the benefit of the initial call. */
for(i = 7; i >= 0; i--){ /* I start with 7 because that bit goes out first */
LOWER_CLOCK_O;
/* Now present the data at pin 1 of the DB-25 */
outport(BASE, byte & (1 « i) ? DATA_O : DATA_I); /* Outputs are
inverted */
/* The "ternary expression" returns the value to the left of the I I . II
of the question is true (i.e. non-zero) and the value to the right
of the ":" if the question is false (i. e. zero).
It's very nifty
and compact, since it not only performs an "if-then-else, II but it
also returns a value. */
/* clock the data in */

unsigned char inbyte()
/* read a value from the parallel-to-serial chip (LSI65)

*/

{

int i;
unsigned char result = 0;
RAISE_CLOCK_I; /* Clock should be high before loading data into the chip */
LOAD LS165;
/* Move the data at the inputs into the flip-flops */
SHIFT LS165; /* Enable shifting out of the data */
for(i-= 7; i >= 0; i--) { /* bit 7 comes out of the LS165 first */
/* Bit 7 is present at the .output imm:ediately when the chip is loaded,
so we have to pluck it off (into pin 12 of the DB-25) before we do
any clocking. * /
result 1= «inport (BASE+1) & BIT (5»
? 1 : 0) « i;
/* form result:
The ternary expression returns 1 if bit 5 of i/o
address BASE+l is a "1" and O.if it's a zero.
This value is
shifted into the appropriate bit position by the "« i".
result 1= is the same as saying: result = result I, so the bit is
ORed into the result.
This way, we poke each serial bit into the
correct place in the parallel . result . * /
LOWER_CLOCK_I;
RAISE_CLOCK_I; /* The next bit appears on the rising edge of
the clock. * /
return result;

/* COLORS.H: definitions for CGA screen characteristics and colors */
#define SCREEN_BASE Oxb800
/* base address of color graphics card (and EGA
in color graphics mode
*/
#define SCREEN HEIGHT 25
#define SCREEN-WIDTH 80
#define SCREEN CHARS (SCREEN_WIDTH * SCREEN HEIGHT * 2)
./* number of chars and attributes in a screen */
#define BIT (I)

(unsigned char) (1

«

It· /*. A bit mask macro.
The compiler
evaluates it, so it doesn't cost anything. */

/* Make a complete attribute by ORing a CHARacter type with a
BACKground type */

(Listing continues on page 46.)

44

MICRO CORNUCOPIA, #39, Jan-Feb 1988

TURBO C QUICK C LET'S C DESMET C DATALIGHT C ECO-C
LATTICE C MICROSOFT C AZTEC C COMPUTER INNOVATIONS C

------------NEW

000

Limited time offer.

Peacock System's CBTREE
Object library for only $291

~~®@®
©~/rMil©2a2

Our FULL COMMERCIAL VERSION of CBTREE in object library format
is being offered for the amazingly low price of $29.

M(p)alftible

CBTREE provides you with easy to use functions that maintain key
indexes on your data records. These indexes provide you with fast,
keyed access, using the industry standard B+tree access method.

ZRP/M is an operating system combined with a Z280 emulator. Either standalone or with DOSpresent, ZRP/M provides
the solid base of a genuine operating system reliably distinct
from the facade created by an MSDOS interface. All 2.2
system and eBIOS calls are supported, 56.5k TPA, file date
and time stamping, fast virtual disk, iobyte redirection, terminal emulation, color console display, auto relog, COM
path, SAVE anywhere, single key phrase recall, built-in access to DOS drives. SETDISK redefines a drive to any of over
80 CP/M formats. System disk with manual $129. Shipping
$5 ($10 nonUS) ~ ~

A.

Everything you need to fully utilize CBTREE in your applications is
included. The CBTREE source code can be purchased later at any
time for the $70 difference. Example source programs and utilities are
included FREE.
CBTREE source library
Object library only

This limited time offer is simply too good to refuse. Peacock's standard
ROYALTY FREE, UNCONDITIONAL MONEY·BACK GURANTEE, AND
FREE TECHNICAL SUPPORT applies to this offer.
To order or for additional information

.

~~I (703) .3.56.7029 or (703) 847·1743 or write:

~
~~

118 SW First St. - Box G

Micro
Jnflle"thods, nne.
D

Warrenton, OR 97146

(503)861-1765

$99
$29

~.

"-'-'

'\. __

~,
PEACOCK SYSTEms. inC

PEACOCK SYSTEMS, INC.
2108 GALLOWS ROAD, SUITE C
VIENNA, VA 22180

Trademarks: Turbo C (Borland); Ouick C (Micro$Oft); Lers C (Mark Williams); DeSmet Software);
Datalight (Dataiight); Lattice C (Lattice); Micro$Oft C (Micro$OfI); Aztec C (Manx Software); Computer
Innovations C (Computer Innova~ons); Eco-C (Ecosott. Inc).

Reader Service Number 20

For Sale! T-SHIRTS from
THE

MICRO

JeRO

S-M-L-ExL

$6.95

TECHNICAL

JOURNAL

ORNUCOPIA

Phone 1-800-888-8087
MICRO CORNUCOPIA, #39, Jan-Feb 1988

45

(Listing COil till lied fro1l1 page 44.)

Dolt Yourself
Micro Ad

Only 99
THE

MICRO

TtCHNICAL

JOURNAL

MICRO CORNUCOPIA
See Page 94.

ICs

QUANTITY ONE PRICES SHOWN for OCT. 25, 1987

#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define

BLACK CHAR 0
CYAN_CHAR (GREEN_CHAR I BLUE_CHAR)
MAGENTA CHAR (RED CHAR I BLUE CHAR)
BROWN_CHAR (RED_CHAR I GREEN_CHAR)
WHITE CHAR (RED CHAR I GREEN CHAR I BLUE_CHAR)
GRAY_CHAR (INTENSE I BLACK_CHAR)
LIGHT BLUE CHAR (INTENSE I BLUE CHAR)
LIGHT=GREEN_CHAR (INTENSE I GREEN_CHAR)
LIGHT CYAN CHAR (INTENSE I CYAN CHAR)
LIGHT-RED CHAR (INTENSE I RED CHAR)
LIGHT~GENTA CHAR (INTENSE I-MAGENTA CHAR)
YELLOW_CHAR (INTENSE I BROWN_CHAR)
BRIGHT_WHITE_CHAR ( INTENSE I WHITE_CHAR)

#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define

BLACK BACK 0
CYAN_BACK (GREEN_BACK I BLUE_BACK)
MAGENTA BACK (RED BACK I BLUE BACK)
BROWN_BACK (RED_BACK I GREEN_BACK)
WHITE BACK (RED BACK I GREEN BACK I BLUE_BACK)
GRAY_BACK (INTENSE I BLACK_BACK)
LIGHT_BLUE_BACK (INTENSE I BLUE_BACK)
LIGHT_GREEN_BACK (INTENSE I GREEN_BACK)
LIGHT_CYAN_BACK (INTENSE I CYAN_BACK)
LIGHT_REO_BACK (INTENSE I RED_CHAR)
LIGHT MAGENTA BACK (INTENSE I MAGENTA CHAR)
YELLOW_BACK (INTENSE I BROWN_BACK)
BRIGHT_WHITE_BACK ( INTENSE I WHITE_BACK)

Factory New, Prime Parts.u

68000 NOW!
TinyGiant 68000 Single Board Computer
The HT68K TinyGiant is a great little 68000
single board computer. It uses only +5 and +12
volts and has all of these features: Two
Serial Ports, 1 Parallel Port, Expansion Bus,
128K RAM - Expandable on Board to 512K. Floppy
Disk Controller, uses MS-DOS Disk Format.
5.75" x 8.0", Fits on a 5 1/4" Drive. K-OS ONE
Operating System and Software.

*

MasterCardlVlSA or UPS CASH COD

K-OS ONE 68000 Operating System Package
Get the K-OS ONE operating system for your
68000 hardware. With it you can read and write
MS-DOS format diskettes on your 68000 system.
Included
in the package are:
K-OS
ONE
Operating
System
Source
Code,
Editor,
Assembler, HTPL Compiler, Sample BIOS Code.
O~

HT68K TinyGiant with K-OS ONE . . $395.00
K-OS ONE Operating System Package $50.00
HT - Forth Language . . . . . . . $100.00
Edit Toolkit - HTPL Source & Manual
Line Editor, Screen Editor
and Text Formatter
. . . . . . $50.00
Lizard Land - Ari HTPL Adventure Program
with Source Code
$15.00

P
00

MICROPROCESSORS UNLIMITED, INC.

(918) 267.4961

24,000 S. Peoria Ave.,
BEGGS, OK. 74421
No minimum order. Please note that prices are subject to
change. Shipping & insurance extra, & up to $1 for packing materials. Orders received by
9 PM CST can usually be delivered the next morning, via Federal Express Standard
Air @ $4.00, or guaranteed next day Priority One @ $10.501

46

BLUE CHAR BIT(O)
GREEN CHAR BIT(l)
RED CHAR BIT(2)
INTENSE BIT(3)
BLUE BACK BIT(4)
GREEN BACK BIT(S)
RED_BACK BIT(6)
BLINKING BIT(7)

PROMPT DELIVERY!!!

SAME DAY SHIPPING (USUALLY)

DYNAMIC RAM
1048Kx1 100 ns $29.50
256Kx4 120 ns
32.00
51258
6.95
256Kx1 100 ns
64Kx4 150 ns
3.60
4464
41256
256Kx1
80 ns
5.95
5.15
41256
256Kx1 100 ns
41256
256Kx1 120 ns
3.95
41256
256Kx1 150 ns
3.50
41264 + 64Kx4 120 ns
5.25
EPROM
27C1000 128Kx8 150 ns $37.95
27C512 64Kx8 200 ns
15.50
27256
32Kx8 250 ns
5.75
27128
16Kx8 250 ns
5.50
STATIC RAM
43256L-12 32Kx8 120 ns $11.50
5565PL-15 8Kx8 150 ns
3.30

1Mbit
1Mbit

#define
#define
#define
#define
#define
#define
#define
#define

Service Number 37
MICRO CORNUCOPIA, #39, Jan-Feb 1988

Write or call today for more information
and a free 68-KNEWS letter.
Order Now:
VISA/ MC ICOD
(503) 254-2005

ceo
Hawthorne Technology

8836 Southeast Stark
Portland, OR
97216
Reader Service Number 34

C CODE FOR THE PC
source code, of course
C Source Code
Bluestreak Plus Communications (two ports, programmer's interface, terminal emulation)
CQL Query System (SQL retrievals plus windows) . . . . . . . . . . . . . . . . . .
Greenleaf Data Windows (windows, menus, data entry, interactive form design) . . . . . .
Barcode Generator (specify Code 39 (alphanumeric), Interleaved 2 of 5 (numeric), or UP C)
GraphiC 4.0 (high-resolution, DISSPLA-style scientific plots in color & hardcopy)
Vitamin C (Mac Windows) . . . . . . . . . . . . . . . . . . . . . . . . .
resident C (TSRify C programs) . . . . . . . . . . . . . . . . . . . . . .
Greenleaf Communications Library (interrupt mode, modem control, XON-XOFF)
Greenleaf Functions (296 useful C functions, all DOS services) . . . . . . . . .
Essential C Utility Library (400 useful C functions) . . . . . . . . . . . . . .
"
Essential Communications Library (C functions for RS-232-based communication systems)
PC /IP (CMU /MIT TCP /IP implementation for PCs) . . . . . . . . . . .
B-Tree Library & ISAM Driver (file system utilities by Softfocus) . . . . . . . .
The Profiler (program execution profile tool) . . . . . . . . . . . . . . . . .
Entelekon C'Function Library (screen, graphics, keyboard, string, printer, etc.) . .
Entelekon Power Windows (menus, overlays, messages, alarms, file handling, etc.)
QCBB C compiler (ASM output, small model, no longs, floats or bit fields, BO+ function library)
CBTree (B+tree ISAM driver, multiple variable-length keys) . . . . . . . .
ME (programmer's editor with C-like macro language by Magma Software)
Wendin PCNX Operating System Shell
Wendin PCVMS Operating System Shell. . . . . . . . .
Wendin Operating System Construction Kit . . . . . . .
EZ_ASM (assembly language macros bridging C and MASM) .
.
Multi- User BBS (chat, mail, menus, sysop displays; uses Galacticomm modem card)
Heap Expander (dynamic memory manager for expanded memory) . . . . . .
Make (macros, all languages, built-in rules) . . . . . . . . . . . . . . . . .
Vector-to-Raster Conversion (stroke letters & Tektronix 4010 codes to bitmaps)
Coder's Prolog (inference engine for use with C programs) . . . . . . . . . .
PC/MPX (light-weight process manager; includes preemption and cooroutine packages)
Biggerstaff's System Tools (multi-tasking window manager kit) .
TELE Kernel (Ken Berry's multi-tasking kernel) . . . . . . .
TELE Windows (Ken Berry's window package) . . . . . . . .
Clisp (Lisp interpreter with extensive internals documentation), .
Translate Rules to C (YACC-like function generator for rule-based systems)
6-Pack of Editors (six public domain' editors for use, study & hacking) . . .
ICON (string and list processing language, Version 6 and update) . . . . . .
LEX (lexical analyzer generator) . . . . . . . . . . . . . . . . . . .
Bison & PREP (YACC workalike parser generator & attribute grammar preprocessor) .
C Compiler Torture Test (checks a C compiler against K & R) . . .
Benchmark Package (0 compiler, PC hardware, and Unix system)
PKG (task-to-task protocol package) . . . . .
A6B (6BOOO cross-assembler)
Small-C (C subset compiler for BOBO and BOB8)
tiny-c (C subsubset interpreter including the tiny-c shell)
Xlisp 1.5a (Lisp interpreter including tiny-Prolog in Lisp)
List-Pac (C functions for lists, stacks, and queues)
, , XLT Macro Processor (general purpose text translator).
"
C Tools (exception macros, wc, pp, roff, grep, printf, hash, declare, banner, Pascal-to-C)
Data
DNA Sequences (GenBank 4B.0 of 10,913 sequences with fast similarity search program)
., Protein Sequences (5,415 sequences, 1,302,966 residuals, with similarity search program) . .
Webster's Second Dictionary (234,932 words) . . . . . . . . . . . . . . . . . . .
U. S. Cities (names & longitude/latitude of 32,000 U.S. cities and 6,000 state boundary points)
The World Digitized (100,000 longitude/latitude of world country boundaries)
KST Fonts (13,200 characters in 139 mixed 'fonts: specify '.rEX or bitmap format) .
US NO Floppy Almanac (high-precision moon, sun, planet & star positions)
NBS Hershey Fonts (1,377 stroke characters in l~ fonts)
U. S. Map (15,701 points of state boundaries) ';. . . . . . . . . . . . .
The Austin Code Works
, 11100 Lea/wood Lane
Austin, Texas USA 78750-9409

Free surface shipping on prepaid orders

$400
$325
$315
$300
$275
$200
$165
$160
$160
$160
$160
$100
$100
$100
$100
$100
$90
$BO
$75
$75
$75
$75
$60
$50
$50
$50
$50
$45
$45
$40
$30
$30
$30
$30
$30
$25
$25
$25
$20
$20
$20
$20
$20
$20
$20
$20
$20
$15
$150
$60
$60 $35
$30
$30
$20
$15
$15

Voice: (512) 258-0785
BBS: (512) 258-8891
Email: FidoNet 1:982/12
MasterCard/VISA
Reader Service Number 4

Taming The PC's Serial Port
Not Just Any Port In A Storm

Serial ports are not trivial pursuits. Here
Russ tries to talk directly to his serial ports.
How he does it and why are the subjects. His
serial port test routine is dynamite - we've
already used it here at Micro C to verify that
one of our cards has a bad serial controller.

s a result of recent experiences
with the serial port on an IBM PC
AT, a number of descriptive words
for the port have come to mind. Most of
them aren't printable.
I encountered this curious beast while
working on the Physiologic Acquisition
and Telemetry System (PATS) at the
JHU Applied Physics Lab. PATS is part
of the Large Primate Facility, a joint
U.5./French mission to be flown on
NASA's Space Shuttle in 1992.
We plan to use two IBM 80286
machines (such as the PS/2 Model 50) as
PATS Flight Support Stations aboard the
Shuttle. We'll select a machine next year,
and it might be a portable (batterypowered) 80C286 machine if a workable
one's available.
The job of the computers will include
system control and data acquisition via a
command/telemetry link. Part of the interface work we are doing involves communicating
with
the
command/telemetry link at 4800 baud via
one of the AT's serial ports.
In the process of developing the sy~­
tem, I've learned a lot about writing
serial port software.

A

Speed Limitations & Coding Methods
Please note that speed depends on
lots of things: the type processor, its
clock speed, etc. Therefore, nothing I'm
about to say is absolute.
That said, my first conclusion is that
there is an upper limit of 1200-2400 baud
when using BASIC. The exact upper

48

limit depends upon how you are carrying out the communication, and how
much other processing, calculating, displaying or file storage, you have to do.
H absolutely all you're doing is outputting or receiving data to or from
RAM, you might beat 2400 baud. But
probably not.
Even assembly language is limited to
4800 baud unless your program is. talking directly to the hardware. DOS's
serial port services- Function Interrupt
(21H) or the ROM BIOS Serial Port Interrupt (14H) -are just too slow for 9600
or 19,200.
Fairly Fast Serial Functions
Of course, the highest level assembly
language interface is DOS Function Interrupt 21H. With this interrupt, you'll
use either the auxiliary (serial) input and
output services (03 and 04, respectively),
or the default auxiliary file handle (03).
Interrupt 21H is a pain for two
reasons. First, it starts losing incoming
characters at 3600 baud on 4.77 MHz
machines. Second, there is no way to
check the status of the serial port or to
detect I/O errors (incorrect or lost
characters).
Despite all its drawbacks, 21H is the
only serial interface that's valid for all
compatibles.
Machines
made
by
manufacturers other than IBM may have
ROM BIOS structures and Port Address
arrangements different than IBM's.
(Editor's note: Actually, compatibility
isn't much of a problem, only the incompatibles like the Sanyo 555 or other early
kluges have non-clone BlOSs. The reason
that Award, Phoenix, and others have put so
much work into their ROMs is to make
them look precisely like IBM's.)
Fairly Faster Serial Functions
You can shortcut some of the delays
in Interrupt 21H by directly calling
ROM BIOS Serial Port Interrupt 14H.

MICRO CORNUCOPIA, #39, Jan-Feb 1988

This gives you two big advantages.
You can initialize the port with interrupt 14H. And, it's faster.
It isn't fast enough, however, to communicate reliably at 4800 baud (on a
4.77 MHz machine) if the machine also
has to do some file management. (Part
of the problem is that the BIOS's serial
driver isn't interrupt driven.)
Furthermore, we discovered that this
second level doesn't work with PATS. A
quick look at the ROM BIOS listing
shows that it expects to be talking to a
modem or printer. In the absence of
handshaking, 14H throws up.
So we decided we'd have to write
code that talked directly to the 8250. The
software is thus hardware specific and,
in our case, will probably work only on
IBM hardware.
Not only will it work only on IBM
hardware, it turns out that it works only
on some IBM hardware. And this leads
me to the subject of apparent incompatibilities among various versions of
IBM equipment.
(Editor's note: If anything, all the 8088
and V20 based clones we've tried have appeared electrically identical to the XT. In
fact, as alike as the ROMs are, the hardware
appears even more so. We've tried Russ's
test routine on a number of systems, including one running an 8 MHz 80186. The
routine didn't flinch.)
The serial controller chip used in AT
serial· cards is not totally compatible
with the XT's 8250, nor is the AT environment identical to the XT.
This means that chip level software
written for the PC or XT may not work
on the AT. And, vice versa, XTs will
probably have trouble with AT specific
code.
We wrote the first version of the
PATS software on a standard PC, then
tried to run it on an AT with the 8250based serial board from the Pc.
We got a number of errors - some

By Russ Eberhart
6770 Halfcrown Ct.
Columbia, MD 21044

fairly consistently, some only occasionally. As soon as we substituted a
real AT serial port board, and made a
few changes to the software, the errors
went away.
I can't explain it all, but I came to
one conclusion. The 8 MHz AT is significantly faster than the PC, so you cannot reliably do two consecutive OUTs to
a register.
For example, the following sequence
won't work:
mov dx,register_address
mov al,something
out dX,al
moval,something_else
out dX,al
But the following will:
mov dX,register_address
mov al,something
out dX,al
jmp $+2
moval,something_else
out dX,al

We tried using a NOP, but it didn't
do the job so we used the JMP. The
NOP takes 3 clock cycles, the near JMP
takes 15.
In case you haven't run into the "jmp
$+2" command, it simply means "jump
two bytes from the beginning ($) of this
instruction." It is, therefore, functionally
the same as an NOP. (It is not documented in any of my assembly language
books, not even Intel's iAPX 86/88,
186/188 User's Manual.)
You'll find quite a few of these JMP
$+ 2 commands sprinkled around in the
AT's BIOS. My theory is that many, if
not most, of them are there because of
timing problems. It seems a shame to
have to slow the 80286 machine down.
Oh, well.
Anyway, we have written our first

version of communications software for
PATS at the hardware level. For the
second version, we'll probably write a
special device driver.
Both versions could be subjects for
future articles, but next is a piece of
diagnostic software that came about as
we tried to figure what in tarnation was
going on with our serial ports.

YoU'll find quite

a few of these JMP
$+2 commands
sprinkled around in
the AT's BIOS. My
theory is that
many, if not most,
of them are there
because of timing
problems.
Serial Port Diagnostic
Our development of this elementary
serial port diagnostic was definitely a
case of necessity. We had blown out six,
count ' em, six, serial port boards. And
in the brief periods when one would
work, we would get errors that didn't
make any sense.
We had no idea where the problem
was. There were four main candidates:
1) the external interface circuitry to
which the serial port was connected; 2)
the cable that connected the two, including sub-possibilities of incorrect wiring
and open/shorted connections; 3) the

serial port board itself; and 4) the communications software.
It turned out there were problems in
three of the four areas. If we hadn't had
a simple diagnostic, we'd probably still
be troubleshooting.
SEPOD
The routine, named SEPOD, for
SErial POrt Diagnostic, is far from complete and far from ideal. So before discussing it in detail, I'll layout my idea
of an ideal diagnostic.
The ideal routine should check absolutely everything: all baud rates, control lines, parity settings, and interrupts.
In other words, it should verify each bit
of each of the ten registers in the 8250.
And, it should check the line transmitter
and receiver chips.
It should also be easy to run and require a minimum of external hardware
(ideally, it would run itself and require
no external hardware).
If your serial port hardware is
functioning properly, it should tell you
so. If it isn't, it should tell you exactly
what the problem is - in plain English.
Oh yes, and it should run on any
machine that runs MS-DOS or PC-DOS,
whether true blue or completely clone.
Since this is the real world, SEPOD is
not ideal. It is easy to run and, if it's included in your autoexec.bat file, it will
run automatically. Also, it tells you in
plain English where your trouble may
lie.
It does, however, require an external
connector (with three pairs of pins
jumpered) plugged into the serial port.
It doesn't check all baud rates, and it
doesn't test interrupt operation. As they
say in the textbooks, the rest of the baud
rates and the interrupts are left to the
reader.
Confidence
Overall, I'd estimate that the successful running of SEPOD probably gives
you a 95-97 percent degree of con-

MICRO CORNUCOPIA, #39, Jan-Feb 1988

49

fidence that the serial port hardware is
okay. If it doesn't succeed, chances are
probably 97-99 percent that you have a
hardware problem.
The routine runs at 4800 baud, which
is faster than most applications software.
In particular, it should be more than
adequate for checking serial ports used
with 2400 baud modems.
The routine is written at two of the
three levels discussed earlier. The por,..
tion which checks general port operation
uses BIOS level calls, so it should run on
all really compatible machines.
The internal-loop part of the routine
addresses the hardware registers directly. You'll need to substitute your serial
port hardware register addresses for
those in the program (which are for an
IBM PC/XT) if yours are different.
Figure 1 contains the assembly language source. Please read the notes
before you assemble and link it.
(Editor's note: All the code for this issue,
including SEPOD.ASM and SEPOD.EXE,
is available on the Micro C RBBS (503)
382-7643, and on the Issue #39 disk. Order
the Issue' #39 disk from Micro C for $6
(U.S. subscribers) and '$8 (non-subscribers
and foreign). Ask for 5 1/4" MS-DOS or
Kaypro, or 3 1/2" MS-DOS format. Price
includes postage.)
When running the program, the external check is performed first. You must
have a DB-25 connector with three pairs
of pins jumpered for this test to succeed.
Jumper pins 2 and 3, 4 and 5, and 6 and
20. (For serial ports with non DB-25 connectors, jumper the TX-RX, CTS-RTS,
and DTR-DSR lines.)
The second part of the test, the internal loopback, runs if there's an error in
the external check. If you don't know
your hardware register addresses, you
can disable this part of the program by
changing the "jna intIp" statement to
"jmp exit."
So, for the cost of a, DB-25 connector
(about $1.50) and a few minutes soldering " on the screen. If we
enter the following items after the
prompt(+

3

4)

The function + is applied. to the arguments 3 and 4 to produce the result, 7.
We can describe LISP as working
continually in a REAo-EV AL-PRINT
loop. It reads what we type in, evaluates
it, and prints out the result of evaluation. Then it goes back to waiting for us
to give it something else to evaluate and
print.
Let's look at a couple more examples
of functions mapping. arguments into
results. For historical reasons, the function for extracting the first element of a
list is called "CAR" (standing for Contents of Address Register). It's standard
in most LISP implementations (along
with other standard functions like + , -, *
and I).
Suppose we give XLISP a list with
"CAR" as the first item:
> ( car '

(A BCD E)

Then, "CAR" is treated as a function
to be applied to the arguments which
follow it. In this case, there's only one
argument, the list of five items A
through E. So, applying the function, the

MICRO CORNUCOPIA, #39, Jan-Feb 1988

system produces the response A on the
screen.
Why put the quote in front of the list?
When LISP looks at any list, it will assume the first item is a function to be
applied to the following items.
In this case, A is not a function to be
applied to B, C, 0, and E. The quote
mark tells the system to treat the whole
list as data. To put it another way, we're
telling the system NOT TO EVALUATE
the list (AB C 0 E), but leave it as it is.
(Note: I've used lower case characters
for function names because some versions will accept only lower case.)
You can see the difference between
evaluation and preventing evaluation by
using a quote in the following example.
If we type in (+ 3 4), LISP responds
with a 7. But if we type in '(+ 3 4), LISP
responds with (+ 3 4); that is, it returns
the list unevaluated. We can force an
evaluation with the built-in function
"EVAL":
(eval '(+ 3 4) ) produces a 7.

CDR And CONS
Two other built-in functions which
have a central role in LISP are CDR and
CONS.
(1) "CDR"-(again, an historical
name), drops the first item of the list
leaving the rest of the list as the result.
For example, asking for ( cdr '(P Q R S) )
will produce (Q R S).
Remember, the CDR of a list is always a list, too. So, what is ( cdr '( F) )?
Clearly, the result here is an empty list,
and in most LISP implementations, the
result would appear on the screen as
"nil."
(2) "CONS"-accepts two arguments,
placing the first argument in the first
item position in the second argument.
For example, ( cons' A '(B CO) ) will
produce the result (A BCD ). Again, if

By Ramachandran Bharath
Mgmt, Mktg, & C.IS. Dept.
Northern Michigan University
Marquette, MI 49855 .

we ask for the result of (cons '(A B) '(C
D) ), the result we get will be: ( (A B) C
D ).
The point to note here is that in this
case we've asked the system to put the
list (A B) as the first item of a list which
has two elements C and D. So the result
is a list with three items, in which the
first item is itself a list. We can have lists
within lists within lists ...
Defining Our Own Functions
A powerful feature of LISP is that it
makes it easy to define our own functions, to supplement the built-in functions like + and CDR.
I'll illustrate: Suppose we don't like
the name CAR for extracting the first
item of a list, and would prefer to call
the first item by a more natural name of
HEAD of the list. Here's how we would
teach LISP to recognize the new name.
We type in:
( defun
whatever)

head (whatever)

(car

defun stands for DEfine FUNction.
We're telling the LISP system that when
we want it to apply the function "head"
to any argument "whatever," we mean
the same thing as "CAR" of that argument.
The system acknowledges this with a
message, which varies with the particular LISP implementation.
Now we can type: ( head '(L M N) ),
and the system will respond with L. If
we'd tried this without first giving the
definition using DE FUN, the system
would have responded with an error
message.
Similarly, we can define whatever we
want. For example:
(defun

tail (L)

(cdr L) )

After providing the system with this
definition, we can ask for (tail '(X Y Z) )
and get back (Y Z) as the result.

In the two examples above, I've used
only one argument in the definition.
However, I could have used any number of arguments to define a new function. We'll see some examples after
looking at the next key concept.
Branching
Let's say we want to input a number
which represents the temperature in
degrees Fahrenheit, and we want the
program to CLASSIFY this input using
the following criteria: If the temperature
is more than 90 degrees, it should be
classified as HOT. Otherwise, if it's 90
degrees or less, but more than 70
degrees, it should be classified as
W ARM. Otherwise, if it's 70 degrees or
below, but above 40 degrees, it should
be classified as OK. Finally, any
temperature of 40 degrees or below
should be classified as COLD.
I've coded this in Figure 1.
Figure 1 - Hot & Cold LISP
tempclass(x)

(defun
( cond

(

> x
> x
> x

(

t

(

(

. 'HOT
'WARM
40)
'OK
'COLD
90)

70)

»

(1) I use "DEFUN" to DEfine a
FUNction "temp class," and this function will operate on one argument x as
input, to produce a result.
(2) The keyword "COND" is used to
indicate that this is a function which
produces different results depending on
tests of conditions.
(3) Following the keyword COND,
there is a series of lists consisting of two
items each. In each of these pairs, the
first item is a logical condition; if the
condition is true, the action is taken.
Otherwise, the program tests the next
pair.
So, if the condition ( > x 90) is true,

(Le., x is greater than 90), the program
will output the message HOT and end.
Otherwise, it will go and test the next
condition ( > x 70) ... and so on. So we
see that by typing in (tempclass 92) we
would get the message HOT; (temp class
62) would produce the message OK and
so on.
(4) The last condition-action pair has
just the condition "t" which stands for
TRUE. In other words, if the tests of all
the conditions have not produced a true
result, the program reaches this last pair
and takes the final action. If, for instance, we type (temp class 30) the
program will display COLD.
(5) The parentheses have got to
match, as we have put lists within lists;
but these can be indented or even written on separate lines to increase
readability.
LISP has other conditional instructions, but COND is a good starter.
Recursion-A Power Tool In LISP
Recursion is a key concept in AI
programming, in LISP as well as in
Prolog.
A recursive program is one which invokes or calls itself, but with some
change in the arguments. To put in
another way, part of a recursive
program has a pattern similar to the
whole program.
The reason a recursive description of
a structure or a recursive program
doesn't become a circular definition is
this: we describe a pattern as having a
subpattern similar to the whole. This
means this subpattern has a part which
is similar, and this in turn has a similar
subpattern. As we go on, we finally get
to a part which is extremely basic, the
simplest possible example of the recurring pattern. A list is a good example.
A list is a pattern which has a part,
the CDR or tail, which is also a list. This
tail has a subpattern, with its CDR also
a list, and this in turn has a CDR which
is a list ... and finally, when the list is

MICRO CORNUCOPIA, #39, Jan-Feb 1988

55

down to one item, it has a CDR which is
an empty list, the simplest list.
Similarly, to see how a recursive
program "recurses" to a simple case,
let's look at a classical example: a recursive program for joining two lists to
produce a combined list. We want a
function called, say, "JOIN," so that if
we say:
JOl.n '(a b c)

'(d e f g)

)

we get the result:
(a b c d e f

g)

We can define this operation recursively as follows:
To join list#1 and list#2:
set aside the CAR of list#1,
join the CDR of list#1 to list#2
to produce list#3,
Then CONS the CAR of list#1 to
list#3 to produce the result we
want.

We see the typical recursive structure. Joining list#l and list#2 requires
the actions for joining, but with some
change in the arguments. We're using
the CDR of list#l, not the whole of
list#l.
We can see that joining, using CDR
of list#l, will in turn involve using its
CDR ... until we reach the stage where
the first argument is an empty list. And
this brings us to the simple case, joining
art empty list to a second list. The result
is just the second list. We can express
this in LISP; see Figure 2.
This uses some of the concepts
we've already seen. The first condition
tested is whether the first list is "null"
(empty). If it is, the result has to be the
second list. "null" is a built-in function
in most versions of LISP, including

handy. If the "null" test fails, we see the
next condition action pair has "t" as the
condition, because there's nothing else
to test. And the action to be taken is to
CONS the CAR of the first list to the join
of the CDR-of-the-first-list with the
second list, as we've done above.
This function also illustrates a general
rule for writing recursive programs. We
should test first to see if we have
reached the simplest case (or BOUNDARY CASE) to see whether we need
more recursion. We then put in the code
for handling the non-boundary cases to
get them down to th.: '".imple case.
This operation of joining two lists to
produce a combined list is a very useful
programming tool, so most versions of
LISP provide this as a built-in function,
usually with the name "append." I've
used it as an example because it illustrates the principles of recursion nicely. You might like to experiment with it
and other more complex recursive ideas
(like Quicksort) in order to experience
the power of recursion.
In Closing
I'd like to summarize a few distinctive features of LISP:
(1) It's a FUNCTIONAL programming language. If programs are written
as functions which are evaluated and
return a value, then we can write functions in which one of the arguments is a
function, and the value of this second
function is used by the first function,
and so on "recursively" to any depth.
Thus our programs can be tested as
small modules-which are part of larger
modules-which are part of larger
modules-and so on.
(2) Recursion and the flexible structure of lists work together when processing symbolic information.
(3) Because programs are functions
which are lists of items, and data can
also be lists of items, a LISP program
can use a LISP program as its data!

powerful features, and many complex
programs have been written in this
"old" language. I haven't said anything
about the many similarities between
LISP and Pascal (or BASIC)-operations
like assigning a value to a variable, writing a loop, and so on. For a more indepth discussion of LISP and LISP
programming, check out one or more of
the following books:
Abelson, H. and others: The Structure

and Interpretation of Computer Programs
(MIT Press, 1985).
Betz, David: An XLISP Tutorial (pages
221 ff in BYTE, March 1985).
Fladung, B.J.: The XLISP Primer (Prentice-Hall,1987).
Friedman, D.P. & Felleisen, M.: The
Little LISPer (Science Research Associates, 1986).
Narayanan, A. & Sharkey, N.E.: An
Introduction to LISP (Halsted Press/John
Wiley,1985).
Touretzky, .David S.: LISP: A Gentle

Introduction

to

Symbolic

Computation

(Harper & Row, 1984).

•••

PCB-Edit. .. creates multi-layered PCB's
with ease. Included are solder mask and
legend ink support, plotter -- printer drivers

MUCH MORE
$99.95
PCB-S hop ... will build double sided,

plated thru hOles, Circuit boards from your
artwork or PCB-Edit files for only $1.00 per
square inch (single quantities) with no set
up charges.

ANALOGIC ... the 32 channel logic
Figure 2 - Joining Two Lists
(defun

join (first second)

(cond
(
(null first)
second
(
t
( cons (car first)
(join (cdr first) second»

»

XLISP.
Recursing a list always ends with an
empty list, so a test for "null" is really

56

Smart Programs
Let's take this one more step. How
about letting programs create or modify
other programs? Modify themselves? Ultimately, when we say a person learns,
don't we mean he modifies his own
program?
In other words, LISP has the structure to learn and change. This is a major
reason it has become a key tool in Artificial Intelligence work. The breakthrough
expert systems programs in the 1960's
were written in LISP.
As I said earlier, LISP has many

MICRO CORNUCOPIA, #39, Jan-Feb 1988

analyzer for the IBM PC. Has 16 bit trigger
word, 80 nano second sample time, for
only.
FULL UNIT
BARE BRD

$399.95 $99.95
MOVE R... the two axis stepper motor
driver controlled by your printer port.
only:
FULL UNIT
BARE BRD

$179.95

$49.95

£~£J1@@Jl©

PHONE(602) 458-4065
BOX 3228. Sierra Vista. AZ 85636
Reader Service Number39

Now it's
. easier than
ever to order
from Micro
Cornucopia!
Use your
""
Visa or
Mastercard

m

~~~:

~

XT CLONE SYSTEMS
(One YEAR guarantee on system)
Turbo Mother Board 4.77 and 10 MHz
640 K Ram installed on board
Serial, Parallel, Game Ports
Clock/Calendar
AT Style Keyboard
Color Video Board (CGA)
Monochrome Opt
150 Watt Power supply
Flip Top Case
ABOVE WITH 2 FLOPPY DISK DRIVES $ 649.00
WITH 1 FLOPPY AND 20 MEG
$ 899.00
WITH 2 FLOPPY AND 20 MEG
$ 979.00
Assembled and Tested for 24 Hours
AT TURBO SYSTEM
AT COMPATIBLE MOTHER BOARD WITH BIOS
8 MEG AND 12 MEG SWITCHABLE SPEED
512K RAM INSTALLED UP TO 1024 ON BOARD
WA2 HARD DISK/FLOPPY DISK CONTROLLER
MONOCHROl1E GRAPHICS VIDEO v7ITH PRINTER
1.2 MEG OR 360 K FLOPPY
220 WATT POWER SUPPLY
AT CASE
AT KEYBOARD
SET UP DISK
ONE YEAR WARRANTEE ON SYSTEM
$1095.00
$ 100.00
EGA UPGRADE FOR ABOVE
$ 50.00
512K UPGRADE (1024 INSTALLED)
5339 KEYBOARD UPGRADE
$ 30.00
HARD DISK DRIVES
20 Meg Seagate ST4026 (for AT) $ 495.00
30 Meg Seagate ST4038 (for AT) $ 595.00
Does NOT include controller

C
:s-

Q.,.

"';
Q)

Color fvionitor RGB (CGA)
Color Honitor RGB (EGA)
Monochrome TTL (Green)
Honochrome TTL (Amber)
EGA Color Video Card
MS DOS 3.1

$
$
$
$
$
$

275.00
385.00
110.00
120.00
150.00
50.00

CITIZEN PRINTERS
120 CPS 9"
HODEL 120D
.
MODEL MSP-IO
160 CPS 9"
160 CPS 15"
MODEL IvlSP-15
200 CPS 9"
MODEL MSP-20
200 CPS 15"
l10DEL NSP-25
MODEL 35 35 CPS LETTER QUALITY
ALL PRINTERS COHE WITH CABLE

$
$
$
$
$
$

200.00
300.00
400.00
350.00
500.00
500.00

CASCADE ELECTRONICS, INC.
ROUTE 1 BOX 8
RANDOLPH, MN 55065
507-645-7997
Please ADD Shipping on all Orders
COD Add $3.00
Credit Cards ADD 5%
Limited to Stock on Hand Subject to change
Reader Service Number 15

Parallon Message Passing:
Using MS-DOS And C To Communicate In Parallel

We took a close look at the Transputer in
issue #3S. This article covers the software
side of a parallel system based 011 a very different processor, the SOSS-compatible V20.
111 fact, this is a real, expandable parallel
processor system based on boards (each with
S V20s) which can simply· be plugged into a
PC/XT/AT or clone.

he future .of parallel processing
. depends, more than anything else,
on the development of good
software. So far, manufacturers of parallel hardware have tried to solve this
problem for their users by building highlevel parallel language environments
which shield users from the underlying
parallelism of the hardware.
Unfortunately, this approach places
the burden of parallel systems research
on the shoulders of a few people, leading to relatively unsophisticated solutions. By contrast, we believe parallel
software can best be developed in the
same way as today's microcomputer
software-through the creativity of independent developers.
Our Parallon 1 board contains 8 node
processors, each consisting of an' NEC
V20 Intel-compatible CPU and 32K or
64K of local no-wait state RAM, a master
processor. with an NEC V20 and either
32K or 128K of no-wait state RAM, a
DMA controller, timers, and I/O ports.
The board can be plugged into the slot
of a' PC, AT, or (optimally) 386 compatible. You can use it alone. or add additional boards, each under control of
the host.
We've achieved this flexibility by integrating the Intel. CPU and IBM bus architectures into a Virtual Tree architecture, a hierarchy of processors shaped
like an inverted tree. See Figure 1.
Each processor in the tree can control

Figure };.. Parallon's Virtual Tree Architecture.

HOST

PC

HOST PC BUS

r------------------ll.---~.~-----..;.~--.:..---.,.

,

,

.

I '
I '
I

T

'

MASTER

PARALLON BOARD,

V20

I

64-128K

D

I
I

"

'.

I
I
I
I

I"

'

PARALLEL BUS

I D DD· D D D DD
I
I

I

<...c·'L:.... -"'7" _ _ _ _ _ _ _ _ _ -

I

!
I
L
I

-

-'- - - - -

up to 16 processors below it. (For instance, the host computer can control up
to 16 boards, each board containing up
to 16 nodes.)
In the PC-based Parallon system, the
PC's built-in processor (the host), is at
the top of the inverted tree. At the' next
level down are the master processors
(one on each Parallon board), all accessible to the host over the PC bus. At the
bottom are the node processors, accessible to the master over an on-card bus.
Communications
Okay, you're' about to ask-how do
all these processors communicate?
First, processors at the lowest level of
the tree (nodes) do the computing, while
all higher levels (masters and host)
handle message passing. Second, all tree
control functions are top-down between
adjacent layers and use memorymapped registers (leaving the I/O map

58 MICRO CORNUCOPIA, #39, Jan-Feb 1988

,
I.

- - -."7" -

- -:.... --"7" - -:-. - -'- - _ _

J,

free for I/O).
Part of the memory map of each
master, for instance, is a window into
the full memory map of a node, switchable (using memory-mapped registers)
to reach different nodes. Because this is
true at every level of the tree, it's possible for the host to access the RAM not
only of the masters (Le., its branches)
but also the nodes (its branches'
branches)-a very useful feature for
debugging.
One implication of this is that since
processors (particularly nodes) can't
directly access the RAM of other processors at the same layer of the tree, this
isn't a "shared-memory" system in the
usual sense. Rather, it's a message-passing system like a local area network in
which information is passed between
processors explicitly as messages-but
much faster, over parallel busses instead
of serial lines.

By Sam Bogoch & Lain Bason
Human Devices, Inc.
322 w. 71st St.
New York, NY 10023

Because bus control between layers is
top-down, sending messages down the
tree is a matter of writing to the next
layer down, while messages aren't sent
up the tree so much as retrieved by the
next upper layer.
Message Passing
The basic message-passing procedure
goes like this: when a node has a message to send, it alerts its master (running
MP ASS.EXE, its messaging program);
the master copies the message into its
own RAM, checks a destination header,
and sends the message down to the destination if that node is also on its board,
or alerts the host if it isn't. At that point,
the host (running HPASS.EXE) would
send the message down to the appropriate master, which in turn would
relay it down to the appropriate node or
nodes.
Each message automatically takes the
shortest possible path from source to
destination-messages between nodes
on the same board never reach the PC
bus, for instance. Because all interconnects are achieved via parallel busses instead of serial ports, interprocessor communications are direct and fast, limited
only by bus bandwidth.
To address applications which require the widespread distribution of
common data, we've supported a
variety of hardware logical-address or
"group" modes. While messages of this
type occupy the same bandwidth as
single physical-address messages going
up the tree, when sent down they are
broadcast to a group-any or all processors at a given level-simultaneously.
The challenge of designing the system software for the Parallon 1 was to
make the system as flexible as possible,
without sacrificing ease of use or speed.
The system should encourage experimentation, freeing users from the
details of inter-processor communication
without restricting them. Finally,
programmers should be able to write

code once which can be reconfigured for
any Parallon system.

Experienced
MS-DOS

programmers can
therefore
immediately start
programming for
the Parallon,
without learning a
new language or
environment.
Tools
Since each node on a Parallon 1
board can execute Intel machine instructions, the Para lIon systems software al. lows programmers to choose from a
wide variety of off-the-shelf MS-DOS
development tools. Most programmers
have a favorite high-level language and
environment "tool kit." The Parallon
systems software can work with just
about any of these because it avoids implementation-dependent ".OBJ" files
and uses only standard ".EXE" files,
which any MS-DOS development system can generate.
Experienced MS-DOS programmers
can
therefore
immediately
start
programming for the Parallon, without
learning a new language or environment.

Inter-Node Communication
Inter-node communication on the
Parallon 1 is available to programmers
at the assembly-code level or through
function calls which support messagepassing. With just a few C-compatible
function calls, the programmer can send
and receive messages between processing nodes and perform I/O. These function calls are OUTP, WAI,T, INP,
RELEASE, and DISCARD .
. The system calls for output are
OUTP and WAIT. Most operating systems copy output to a system buffer
before passing it on to its ultimate destination. OUTP allows a program to
keep running without copying the message into a buffer, because the master
will soon copy the message into its own
memory space anyway. However, between the time when a program calls
OUTP and the master picks up the message, the program must avoid clobbering the message.
When a program wants to reuse the
memory it has recently used to send a
message, it must WAIT. The program
cannot continue until the master has
picked up the message. A cautious
programmer might call WAIT after
every OUTP call, but with care, occasional calls will suffice.
The system calls for input are INP,
RELEASE, and DISCARD. A call to INP
returns to the address of the current incoming message. If the next message
isn't in the node's memory yet, it's
fetched from the master's memory.
Since the nodes have limited memory, a
node can only store a few messages at a
time.
DISCARD tells the system that the
program has finished reading the message. The memory space used by the
message is freed, and the next call to
INP gets a new message. RELEASE tells
the system that the program will not be
using the message for a moment. This
allows the system to move the message
to another memory location if it needs

MICRO CORNUCOPIA, #39, Jan-Feb 1988

59

to create a large block of contiguous
memory.
Each message created by OUTP has a
header containing an address field
which can be either a "physical" address, which has four-bit fields to
specify one of 16 boards and one of 16
nodes, or a "logical" address, which
points to a procedural list of physical
addresses.
The address field is very inconvenient to use directly, since it requires
the programmer to code for a specific
hardware configuration. Instead, we've
implemented a system of symbolic addressing. This refers to labels in the
source code which are assigned logical
and physical addresses at load time, allowing the programmer to experiment
with different communication configurations without recompiling.
A user-specified netlist of connections
tells the loader how to assign the symbolic addresses. We assume each node is
running a separate program module
even if the code is identical.
The netlist provided to the loader
specifies a series of connections between
the symbolic addresses of different
modules. For instance, module A's symbolic address "outJight" could be connected to module B's symbolic address
"in_left" with the line (A,out_right)(B,in_Ieft).
'
In addition to the translation of symbolic addresses at load time, the Parallon
system software maintains runtime
tables to translate from logical addresses
to physical addresses, allowing messages to be broadcast or to be rerouted
on the fly. The logical-to-physical tables
can be omitted to save space if the
programmer doesn't need them.
Optimizing Message Passing
We designed the message-passing
system to accommodate different types
of algorithms. Some algorithms use
many short messages, while others use
fewer, larger communications. Sometimes data is sent continuously, other
times in bursts.
Short messages aren't as efficient
since each message requires some overhead. The overhead can become significant if the message contains only a
few bytes.
To minimize the overhead involved
in sending short messages, MPASS.EXE
running on the master concatenates
them into larger messages if the communications load is heavy. When only a
few messages are being sent, short messages are sent individually.

60

If a node receives a continuous
stream of messages, its memory space
can become fragmented. Programmers
can choose a version of INP which compacts memory when necessary, eliminating fragmentation.
The intelligent memory compaction
algorithm can usually free the required
space with the smallest possible overhead. Memory compaction can move
but
the
messages
unpredictably,
protocol for locking a message in place
is very simple.

1e

familiar

MS-DOS
development tools
provide a large
library of

sophisticated DOS
1/0 calls, but
programmers must
remember that the
code they write will
not be running on
a PC.
When INP is called, the received message is automatically locked, preventing
it from being moved until the module
explicitly RELEASEs or DISCARDs the
message. The programmer has the option of RELEASEing messages frequently, infrequently, or not at all. Furthermore, fragmentation can be essentially
eliminated by specifying a larger message-passing space at load time.
1/0

The message-passing system is very
useful for simplifying parallel programming, but by itself it doesn't allow any
communication with the outside world.
The familiar MS-DOS development tools
provide a large library of sophisticated
DOS I/O calls, but programmers must
remember that the code they write will
not be running on a Pc. As a result,

MICRO CORNUCOPIA, #39, Jan-Feb 1988

DOS system calls and input/output procedures won't work the Parallon.
The Parallon
system
software
provides a simple and flexible alternative to DOS system calls. The I/O
facilities rest on top of the message-passing system. Messages representing I/O
are sent to and received from devicedriver processes running under HPASS
on the PC host processor. The links between Parallon modules and devicedriver processes can be reassigned, just
like the links between Parallon modules.
For example, the Parallon 1 comes
with a color version of Conway's game
of Life. Each module calculates a subsection of the display screen, and must
communicate with the modules which
calculate neighboring sections. When the
modules are loaded into the Parallon,
the programmer can specify that module
A sends its right edge to module B's left
edge, and vice versa.
The modules' input channels for their
initial states can be tied to a devicedriver process which reads a file, or to
one which accepts keyboard input.
Likewise, the modules' output channels
can be tied to a display-driver program
which relocates or perhaps rotates the
subscreen they represent. Neither the
modules nor the device-driver processes
need know where the messages they
send actually go, since HPASS takes care
of the details of mapping between symbolic and real addresses.
Wrap Up
The modular and flexible nature of
Parallon systems software provides a
convenient base for developing applications. As parallel software developers
become more familiar with the tricks of
parallel programming, they can write
higher-level tools which build upon the
Parallon systems software.
Tasks which could be automated include assignment of code modules to
nodes, decisions about how best to interconnect modules, serializing parallel
code (thus eliminating message passing
overhead between two small modules),
and parallelizing serial code.
Each of these tasks requires a nontrivial level of analysis, but the system
certainly can support such complex
software.

•••

Software Developers
We need your program!
Do you have a program that's good enough to
sell, but don't want the problems or financial risk
of producing, typesetting, printing, packaging,
warehousing, marketing, distributing and supporting a product?
Why start your own software house?
We've done it for you!

C864.1

Merlin Publishing Group
is now accepting submissions of micro-computer
software for pUblication.
You get:
• initial cash payments
• generous royalties
• to spend your time programming
But we can't help you if you don't submit. Call
or write today for our submission guideline kit.

---_- .. -----_
- - ..
. ,--~: . .,------ ...... --=

Ji:~-I(IIIIIl

_

.....

....

.-

_ _

_

~~....:~~:=:.~=:~
-..
. . . . . . . . . .

=.

~I

..

-

-

.-

_

._--

PUBLISHING GROUP

TM

1240 Johnson Ferry Place, Suite AlO
Marietta, GA 30068
(404) 977-6034
P. S. See us in Atlanta at COMDEX-Spring '88

Aztec ROM Systems

New PC/M5-00S
CP/M·86· ROM

6S02I6SC02 • B080IZSO
SOB6/80xB6 • 68OxO

An IBM or Macintosh is not only a less
expensive way to develop ROM code, it's
better.
Targets include the
6502l65C02, 80S01Z80, S086/80x86,
and 68OXO.
Aztec C has an excellent reputation for
producing compact high performance
Aztec C86·p...................$199 code. Our systems for under $1,000
• optimized C with near, far, hu~e, outperform systems priced at over
small, and large memory - Inllne $10,000.
assembler - In line 8087/80287 ANSI support - Fast Float (32 bit) - InlUal Host Plus Targel ..$ 750
optimization options • Manx Aztec
8086/80x86
macro
assembler Additional Targets ...........$ 500
'Aztec overlay linker (large/small ROM Support Package....$ 500
model) • source level debugger •
object librarian • 3.x file sharing &
Vax, Sun, PDP';11 ROM
locking • comprehensive libraries of
UNIX, DOS, Screen, Graphics, and
HOSTS
special run time routines.
Call for information on Vax, PDP-11,
Sun and other host environments.

Superior performance, a powerful
nffN array of features and utilities,
and pricing that is unmatched make
the new Aztec C86 the first choice
of serious software developers.

Aztec C86·d...................$299

Reader Service Number 35

• includes all of Aztec C86-p • Unix
utilities make, diff,grep • vi editor •
6+ memory models • Pro filer.

Cross Development

Most Aztec C systems are available as
cross development
systems. Hosts
Aztec C86·c...................$499 include: PC/MS-DOS, Macintosh, CP/M,
• includes all of Aztec C86-d • Vax, PDP-11, Sun, and others. Call for
Source for library routines • ROM information and pricing.
Support • CP/M-8S support • One
year of updates.

CP/M· 8080fZ80 ROM

XentmCcpy-PC
o~af(\

\'

C~OO S

n~Ob

ts '10\l~
t'

\e

\,C

$79.95 +

CI!:r

Sales Tax Of

v~
. . ., -

I

$5.00 S/H

CA

~

°

UPs
COD

READI WRITE /
I
FORMAT IDUPLICATE
Disks from over 300 other micros

I

C compiler, 80801Z80 assembler,
linker, librarian, UNIX libraries, and
A large array of support software specialized utilities.
is available for Aztec C86. Essential
Graphics • C Essentials • C Utility Aztec C lI·c CP/M & ROM.... $349
Ubrary • Greenleaf Com. • Greenleaf Aztec C lI·d CP/M.................$199
General • Halo • Panel • PC-lint •
PforCe • Pre-C • Windows for C •
Windows for Data • C terp •
, db Vista • Phact • Plink86Plus • CHow To Become A User
tree.
To become an Aztec C user call 800221-0440. From NJ or international
C' Prime
locations call 201-542-2121. Telex:
PC/Ms:.OOS. Macintosh 4995812 or FAX: 201-542-8386.
Apple II. TRS-aO. CP/M
C.O.D., VISA, Master Card, American
Express,
wire
(domestic
and
These C development systems are international), and terms are available.
unbeatable for the price. They are One and two day delivery available for all
earlier versions of Aztec C that domestic and most international
originally sold for as much as $500. destinations.
Each system includes C compiler,
Azt S t
bo ht dO tl f
assembler, linker, librarian, UNIX
ec ys ems ug
Irec y rom
°
Manx have a 30 day satisfaction
r~utines, and m9 re..
SpeCial ~uarantee. Most systems are upgradable
discounts ar~ available for use as by raying the difference in pnce plus
co,urse material.
$10. Site licenses, OEM, educational,
C Prime .............................$75 and multi
discounts are available.

Third Party Software

"Iable from previous versions
1

Upgrades a,va $25 00 Call for Authorization
for on Y
•
To Order Contact:

<><¢"w~ ~~~, \~~~
0

To orde(or

1454 Sixth Street, Berkeley, CA 94710

"
~

(415) 525-3113

~

~
"0

o
o

'"
Reader Service Number 38

"

-'W.1·..,..·~·1 80n4~2'
U"~\ ~,'
•

,

•

,

D: •

Manx Software Systems
One Industrial Way
Eatontown, NJ 07724

' .

In NJ

,

\

t·c~li~'~~~!\"

O'AfA'O;

'~;~~'

*

or in~mati?!l~c~t(~1) ~2-21~,t>"

,\TELfX 4,~~;8*~.~~N' ... '*W"
"",.,.J.,.~#

Reader Service Number 17

The Wrong Side Of The
Law

By Laine Stump
Redhouse Press
Merkez PK 142
34432 Sirkeci
Istanbul, Turkey

Want to add a little fun to your dull and dreary
existence? Thought of casting off the old routines
and trying something new? How about packing lip
your computer expertise and taking it overseas for a
year or two? Laine's been in Turkey for over two
years and he's having a....

osh Geldiniz! ("You Came With Happiness!"), said the man in the black
coat, white shirt, black tie, and twen,
ties style slouch hat as he reached
through the jeep's window to shake Sarge's
hand.
"Gunaydin!" ("Good morning!"), Sarge
replied, obviously too shaken to realize that it
was late afternoon. Our friend's backup man
stood nervously behind the tractor parked in
the middle of the road, shifting from one foot
to the other as he tried to make the WWI
vintage rifle in his hands seem a bit less obvious.
We were near the top of Hasan Dag, one of
the tallest mountains in North Central Anatolia.
Our rafting trip on the Kizilirmak River had
ended a day early after losing three of our four
paddles. So we decided to try and find the dirt
road up over Hasan Dag that showed on our
aeronautical charts.
"What are you doing up here?" our new
friend now demanded. "Why didn't you stop
in the village? I'm the mayor and you're supposed to ask me for permission before you
come up here! You shouldn't be here!" His
manner had changed immensely in the few
seconds since he had' given us the customary
Turkish welcome. He was now visibly shaking,
partly from nervousness and partly from the
near freezing cold of the late autumn afternoon
at 8,000 feet. I began to worry that the nervousness would spread to his henchman hiding behind the tractor.
"Wait a minute," we said. "There weren't
any signs. Why were we supposed. to stop in
your village? We were just driving on the
road,"

H

62

MICRO CORNUCOPIA, #39, Jan-Feb 1988

"You just are!" he replied. "Now give me
your ID cards. We're going back down to the
village and I'm going to call the Jandarma
(military police) and see what they have to say.
You start down and we'll be right behind you."
Jason started to say something back to the
mayor about this being a public place and we
could be here if we wanted, but Sarge and I
managed to shut him up. We pulled past the
tractor and the shivering young' moustached
man with the rifle twirler's gun and started
bumping down the sheep track that had led us
into this mess in the first place.
On the way down we discussed our
strategy. "Look," said Sarge to everybody, but
obviously pointed towards Jason, the resident
hothead, "he may be right and he may be
wrong, but out here HE'S the law. We'd better
be damn polite and do just what he says. I'd
appreciate if nobody talked back to him or
questioned his authority. I'm sure that he's just
as nervous as we are. Let's just tell him we're
sorry and we didn't know we had to ask permission. And DON'T show him our maps!"
Back down in the village, we were motioned
into a parking space that looked to be the flat
roof of somebody's mud and rock dwelling. As
the four of us unfolded ourselves from the little
Mercedes Jeep, the usual crowd of villagers
started to gather.
"Where are you from?"
"We're all Americans."
"Why are you in Turkey? Are you tourists?"
"No, we're working."
"Embassy?"
"No. Well, Sarge works at the embassy, but
work for the Development Foundation of
Turkey, Jason teaches theater at the Government Conservatory, and Rich is a freelance
journalist. He just came to Turkey a month ago
and we were out showing him around."
"You live in Ankara?"
"Yes."
"Why did you come out here?"
"Just to look around."
"How much money do you make??"
Mr. Mayor was still in trying to contact the
Jandarma from the only phone in town.

moustached friend with the antique rifle.
Mean~hile, the co~versation had lulled
and I decided to start it back up again.
The 1I0ther Side" Of Working Abroad
"Is that a Turkish-made rifle?" I
This is just one of many experiences
asked our moustached, parka clad
I've had since I left the U.s. to come to
guard.
"Yes."
Turkey just over two years ago. Most
"Made in Kirrikkale then I guess ... "
people who think of working overseas
think either of volunteer work-living in
"Yeah." I didn't feel like asking
where the bullets were made or where
a mud hut in a remote village teaching
he had been trained in handling guns.
the art of latrine digging to a bunch of
A man of about 50 years or so, wearilliterate pygmies. Or they think of oil
companies-living in a foreigners' coming a knitted cap that showed he had
made a pilgrimage to Mecca, and obpound somewhere in the desert of
viously of some importance in the vilnorthern Chad, making $150,000 a year
lage, stepped up to talk to me. "What
by working long hours in an inhospitable place with boring scenery
were you doing up there?"
"We heard that Hasan Dag was the
and nothing to do for recreation but
highest mountain around and we
wanted to see it up close."
"Well there's a road there, but knowing the correct turns is very critical,lI he
said, showing off his city vocabulary.
"You know, there's gold in these mountains. We thought you were up here
trying to steal some of it. There were
some Germans up here awhile back
trying to dig some up and now we're in
charge of protecting the mountain."
"Oh. So that's why you were worried! Well, we didn't even know there
was gold up here. You don't have to
worry about us. See, this jeep is new and
we're looking for high roads because we
wanted to, uh ..... "("Hey Sarge! What's
Turkish for 'check it out'?" A shrug of
the shoulders.) "We just wanted to see if
it's, a good car or a bad car." Sometimes
I don't say things very eloquently, but
most of the time I end up making myself
clear somehow.
The. mayor had come back from his
throw darts at fading pictures of the
office. "Nobody answered down at the
Ayatollah.
station, so I'm going. to take down your
There is a middle ground,. though,
names and your license plate number
and send it in to them."
and I think that the middle is where the
most fun is. It's no fun to be isolated to"Okay. Look, we're really sorry about
tally from challenging high tech work,
the trouble. We just didn't know we
but it's, also no fun tq completely
were supposed to ask permission."
"Don~t worry about it. If you come
'separate yourself from the local populaback, just stop in and see me. You can
tion. Why go to a foreign cou~try if
you're just going to pretend you're still
have dinner with us and then we'll go
in America?
together and I'll show you the mountain."
The work you do while you are overseas mayor may not be satisfying or
"That would be really nice. Welt
we'd better be going now, it's getting_ , educational, but the real satisfaction and,
education comes when you step out the
late. Nice to meet you all." We shook
hands with every adult male in the
door of your office into the streets of a
crowd of 20 or so that had now _sur- , city where all the signs are written in
Martian, the people speak in unintelrounded the jeep, climbed back in and
ligible staccato bursts of emotion, and
started down the rest of the trail leading
back to the main highway, waving our
the traffic is reminiscent of the, demolition derby at the Deschutes County Fair.
goodbyes to the mayor, the 78-year-old
Since I have just ended my two year
retired .railway -worker, some of the
contract with the Development Foundacutest little girls in the world, and our

tion of, Turkey, I thought it would, be
kind of fun to reminisce about my two
years living "in the middle" and maybe
let you in on a bit of the fun to expect if
you do the same.
I've been trying for days to find a
way of organizing all of this and have
had absolutely -no success. I guess the
best form of organization then is
"stream of consciousness." Here goes ...
Curiosity
In any country outside of Western
Europe, practically any local you meet is
going to be extremely curious about
you, where you're from, why you're
here, if you're married, how you can
stand being separated from your family,
how much you make. The normal questions.
The first words of Turkish that I
learned were in response to these questions. Within weeks I could field the
stock series of inquiries. Back in Ankara
after the fiasco on Hasan Dag, I popped
into a cab, in a hurry to get over to the
American Research Institute to install
the new winchester in their Multitech
PC:
"Say, you're not Turkish, are you?
Are you German? Sprechen Sie
Deutsch?"
"No, I'm an American. I don't know
German."
"Oh. Well you speak Turkish very
well. How long have you been here?"
"Two years."
"Very good for two years. Are you a
student? Or in the military?"
"No. I work for the Development
Foundation of Turkey."
"Ah, yes, the Development Bank of
Turkey."
"No, no, the Development FOUNDATION of Turkey."
"Oh, yes. Tell me, is there Develop-ment in Turkey??"
Small laugh. "Of course. Slow, but
it's there."
"What part of America are you
from?"
"I'm from Wyoming."
"Oh, yeah, Miami! I have an uncle
there!"
"No, no! Not Miami! WYOMING!"
"Yeah. Nice beaches there. And all
those women!! Do you like it here in
Turkey?"
/lYes I like it very much."
"What about the food? Are you accustomed to the food yet?"
/lYes. I love the food. Whenever
leave the country I miss it."
"Are you married.?"

,MICRO CORNUCOPIA, #39, Jan-Feb 1988

63

"No."
"Well, find yourself a nice plump
Turkish girl, get married and stay here."
"Nah, I don't want to get married."
"WHAT??? Is your family here?"
"No. They're in America."
"Where in Ankara do you live?"
"Gaziosmanpasa."
"Oh. How much money do you
make??"
This is the stock line of questioning.
No matter where you are, you can expect the same, with a few variations, like
"Which is better, America? Or
Turkey??" Or how about, "What do you
think of Turkish girls? They're beautiful,
aren't they?? Look at that one there!
Wow!!!" The cabbie nearly throws us
into the oncoming traffic as he stabs his
finger at a bulging heap of fat wrapped
in a black tent with a face that would
make Stephen Spielberg chuck his
cookies. "Right, right. Just beautiful."
And then there's always this one: "What
about this AIDS thing? Aren't you
scared ?????"
Some days I get tired of answering
the stock list. But then, just about when
I'm ready to start ignoring them, someone will throw in a new one: "Are
American girls really as loose as they
say in the papers????" Or even better:
"How long does it take to come to
Turkey from America by bus?"

up and befriend him, doing everything
possible to help him find his way. Sometimes they will even accompany the person all the way to his destination, or
even invite him to their house for tea.
On the other side of the coin, many
merchants consider a tourist an easy
mark. I have been offered carpets for
$1,000 that weren't worth more than
$300. One carpet dealer in the Covered
Bazaar in Istanbul told me that he charges tourists as much as he thinks he can
get out of them. He showed me a flatweave carpet worth about $400. "I sold
one just like this to a Swedish girl for
$1,500!" he said, quite pleased with himself. Remember: that's not cheating, it's
just good business.

Foreigner
At times it is una musing to be treated
as a foreigner. Growing up in a town
with a big tourist industry (Cody,
Wyoming), I learned to hate "pilgrims"
and "flatlanders" (both are local terms
for tourists, mostly of the Eastern and
Mid-west variety) nosing around with
their pink bermudas, stupid widebrimmed hats, and big telephoto lenses
hanging off the end of their Pentaxes.
Now the tables have turned; now it's
ME who's the outsider. I'm very conscious of that Canon hanging around
my neck. Many days I take it off and
leave it home. I like blending in with the
crowds, being unnoticed. I see much
more of the "real" Turkey that way.
In Turkey, being a foreigner is sometimes a big advantage. If you can call it
an advantage. Several times I have been
with a group of foreigners going into a
crowded restaurant and watched in embarrassment as the head waiter hustled a
table full of Turks into the street in order
to make room for us. If a foreign-looking
person is wandering around looking
lost, it is not uncommon for a Turk who
knows a few words of English to come

how hard I try, though, I still can't dress
enough like a Turk to disguise myself
completely. This leads to a situation that
annoys me more than anything else;
shopkeepers who insist on speaking to
me in English, German, French, or even
Serbo Croatian (Yugoslavian), ignoring
the fact that I am speaking back to them
in Turkish.
It's fine if they actually CAN speak
English, but nothing turns me off from
going into a shop faster than some
black-moustached young guy yelling
after me as I walk past his door, "Yes,
please, kind sir! I sell to you flying carpet! Yes, please!" If only I knew a few
more slang words that wouldn't start a
fight...
One of the most satisfying moments
of my entire stay in Turkey was when,
stranded in the Konya bus station in the
middle of a' cold, snowing, January
night, I struck up. a conversation with
the young man next to me. Due to his
clean-shaved head and lack of moustache, I could tell he was a soldier on
home leave.
"Got a light, brother?"
"Nope. Sorry, I don't smoke."

64

Speaking The Language
I enjoy speaking Turkish because it
makes me more of a local. No matter

Yes, please,
kind sir! I sell to
you flying carpet!
Yes, please!

MICRO CORNUCOPIA, #39, Jan-Feb 1988

"So where you going?"
"I'm on my way back to Ankara. I
just came from Aksehir and they told
me there were busses to Ankara from
here every hour all night. But now I'm
here and they say there aren't any more
busses until 4:30 a.m."
"Boy, that's pretty bad luck. I'm
going back to duty, myself."
We talked for at least 30 seconds
before he said, "Hey! You're not a Turk,
are you??"
I guess the black jacket and the darkness of the bus station helped some, but
I was really proud of my ability to blend
in then. For the next week it was my
favorite story-"How Laine was Mistaken for a Turk for 30 Seconds!"
The biggest barrier to having a really
educational and fun experience in any
foreign country is learning the language.
Once you have at least a functional
knowledge of the local tongue, things
really open up to you. You are no
longer just "one of those crazy Germans." You become a source of information about the outside world. And
while you're giving out information,
you might even get a bit back in return.
Gathering Information
We had given Jason's passport to the
gateman before we entered the construction sight of a new dam on the Kizilirmak River. While we were wandering
around we got curious about just how
deep this darn was going to be. How
much of the good rafting water
upstream was it going to destroy? On
the way out we decided to ask the
gateman.
"Excuse me, but do you know when
this dam will be completed?"
"Well, they've been working on it
now for awhile and, one of these years,
yeah, one of these years, not this year
maybe, but they've been working on it
and, uh, well maybe 1989, uh 76, 90 ... ,
maybe in 1988 they might finish it, but
we're not really sure right now. There's
some Rumanians here though, and
they've been working on it..."
"How deep is it going to be?"
"Well, that's not really too clear at
this point just how deep it's going to be.
Because it's not finished yet, you know,
we can't really say just exactly how
deep it will be. But they've been working on it, these Rumanians, you know,
and, well, when they finish it then it'll
start to fill up and then maybe we'll be
able to get some idea of just how deep it
will be. But at this point it's just not
really too clear."

"Oh. Uh, thanks."
But just try asking the same guy the
maiden name of the mayor's older
brother's second son's wife's mother ...
Sometimes it's kind of tough to get
the kind of details you want out of a discussion. The problem is that the local
people aren't necessarily all that interested in what you are interested in. They
also sometimes have different points of
view.
"What's the river like downstream
from here?"
"It's very dangerous! All kinds of
rapids and things! You aren't thinking of
going down it in THAT thing, are you?
You'll die if you do!"
"Is this the road to Ermenek?"
"Are you kidding?!? There isn't any
road to Ermenek from here! You can't
get there from here!"
At another stop on the same road. "Is
this the road to Ermenek?"
"Yes, but you'll never make it in that
thing, you'd need a jeep or something."
"Ever been to Ermenek yourself?"
"No, but there are some truck drivers
who go there all the time. They told
me."
Work
Unless you happen to own majority
stock in Microsoft, you're going to have
to work while you're overseas to avoid
starving. In many cases that may mean
readjusting your idea of what an acceptable job is. It's not that there aren't computer jobs, it's just that they usually
aren't quite as high tech as you'd be
used to, especially if you're into systems
software, firmware, or hardware design.
Most of the requests I get from
people here in Turkey are not at the
level of, "I need you to design an optical
chocolate chip counter for my cookie
making machine." They are more like,
"I've got this friend who owns a printing company. Why don't you help me
convince him that he should switch to
desktop publishing and then we can
share the consulting fee to set up his
system." Or maybe, "Laine! We're in a
real bad spot! We can't figure out how
to make Word Perfect do a flush right
margin! You've got to get over here
right away!!!" The level of computer
literacy just isn't as high here.
You shouldn't expect to come to a
developing nation and find a job writing
ROM BlOSs for PC clones or designing
control boards for automatic chicken
feed mixers. All of those kinds of things
are done in Western Europe, the u.s.
and Japan and then sent here as finished

products. Computer work over here is at
a more grassroots level.
Just to give you an idea, here are
some examples of jobs that I have discussed with various people (leaving out
the ones which were just daydreams):
• Set up direct communications between a typesetting machine and
an IBM and write software to
translate from one data format to
another.
• Design a database for a TurkishEnglish dictionary and make
reports that output directly to
typesetting.
• Translate
several
software
products into Turkish, including
menus, manuals, hyphenation,
sorting, etc.
• Assist in the selection and installation of a computer system and
software for a small archaeological
library.
• Modify the firmware of various
output devices to allow printing
all characters in the Turkish alphabet.
• Assist in getting a distributorship
for a certain brand of laser printer
for a Turkish computer company.
• Set up a database of the archives
for one of the largest museums in
the world.

Of course, most of these jobs only
show themselves after you are already
in a country. You could just buy a plane
ticket and hope that you found something once you got there, but I wouldn't
recommend it. I would suggest calling
the consulate of the country or countries
you are interested in and asking for information; a few copies of the local
English-speaking newspapers would
help. If you have a friend who is already living overseas, that can be a big
help; they might know of an opening
that you could fill, at least temporarily.
Another way to "get in" to the job
market of a foreign country is as an
English teacher. Native English speakers
are always in high demand. If you are
lucky enough to have a teaching certificate, you can try your luck at the international teacher's hiring conference held
every year at Iowa State University in
Cedar Falls.
If you're really anxious but can't
seem to find the right connections from
stateside, just take a vacation and hop
on a plane. When you get there, pick up
all the local newspapers. Search in the
phone directory for any company dealing with computers. Try to find some
expatriates and get yourself invited to
happy hour at the British or Canadian
Embassy. You might even try talking to

r-----------~

'
~U
i ::::'.::1::.:::::',C:::'th:d'f:~~ o:,dng"::::~::.:Od UN.:::T:~~~deot thi ng I II
I
I ~l~:!:r~~;;l~i~~ ~i;:i~~i ~~~~:iJ,~~: g~ ";~!;!:£::~~~:.~~: I
t3
Now the FULL .oarce code for TUDD r •• cal i I avai lable for the I ail-pc I
WHAT, you are still trying to debug without 80urce code? But why7 Sourcf'
Code Generator8 (SCG~8) provide completely commented and labeled ASCII

ever did lee ••• 11
pournelle, BYTE

TURBO Pascal (IBH-PC) •••••••••• $ 67.50

I
I
$==
II All product.r::::- --fuji -yguarante.d. O'a' format .•"( ).

r '"
OG VI

Anonymoua,

The following are general purpoae dila88embler8:
_Masterful Disa8sembler (Z-80) t. $ 45.00
UNREL (relocatable fUes) (8080) $ 45.00

,

~

~!~~HC/C~::~------;~;;;~;t~:~dli~--~--;~5~expires

Total

a<.

I

Q

II
II,'

I

(
"Th. Cod.

s"

(typ,

au.teu'"

=:_..:o~~~~~_~~~:~~_~~~~~~_~~~~~~~~_

).'

I

....................................

CP/M and TURBO Pascal Are tradel1larks of Dl gl tAl Research & Borland lnt

t

III

Reader Service Number 31

MICRO CORNUCOPIA, #39, Jan-Feb 1988

65

the U.s. Embassy, but don't expect too
much.
If you work at making yourself, your
qualifications, and your intentions
known, you might just find a job. If you
do, cancel your return ticket and call
home to have your stuff shipped over. If
not, at least you got a vacation out of it.
Wages
The biggest commodity you have to
sell is advice. Don't sell it short, either. I
have the habit of feeling guilty about
charging for words and thoughts. That's
bad. If I keep it up, I could starve.
While it is true that you shouldn't let
yourself go for free, you should also
keep in mind that pay is all relative. For
instance, I found it quite easy to survive
in Ankara on $200 a month (plus housing). Of course, I didn't live like most
foreigners did, but I was comfort~ble;
and when vacation time came around, I
had plenty of money saved up to buy
stupid playthings like computers and
river rafts.
One thing to be careful of: in some
countries (e.g., Nigeria) it is illegal to
take more than a certain amount of local
currency out of the country. Make sure
you check into the local laws and insist
on having everything over the limit paid
into a foreign account. If the local
economy is unstable, try to keep as little
money in local banks as possible. If you
get a local account, try to get a dollar account or a sterling account.
My own Turkish bank account is in
the top drawer of my dresser (or sometimes in the front pocket of my suitcase).
At times I let it dwindle to nothing. If
you are in a country with a political
situation not as stable as Turkey,
though, you might consider always
keeping enough cash on hand to buy a
ticket out of the country just in case
things get uptight. Or at least have a
credit card with a high credit limit.

worthless for the first couple months.
You'll be freaked out from the strange
food, strange people, strange music,
strange language. In the meantime,
you're still getting paid.
As long as you're writing up a contract anyway, make sure of a few other
things:
(1) Full medical insurance that covers
you anywhere in the world.
(2) Housing of a guaranteed standard, with telephone, heating if necessary,
constant supply of water (if possible),
washing machine, etc.
(3) Adequate vacation time each year
(Le.,. at least one month). If you're going
to be working in some strange place,
you may as well take the time to see it.
(4) Double check that your moving
expenses and airfare will be paid both
ways.
Never assume anything, always have
it written and signed.

things that have happened to me lately,
just wanting to be a storyteller. But it
looks as if the whole thing was designed
to convince you to give a try at working
overseas. Maybe, in some unconscious
way, it was. I know that I wouldn't
have missed the last two years for anything. Matter of fact, I'm looking forward to more of the same.
If any of you are currently working
in some wild, uncharted country, or if
you end up doing so in the future, I'd
love to hear about it. (Editor's note: So
would Micro C.) I'm always on the
lookout for new opportunities.
Meanwhile, if there are any college
seniors out there who are interested in
having a couple years of excitement
before getting a "real" job, drop me a
line (in care of Micro C) telling me what
you're interested in and what kind of
qualifications you have. Maybe I can
rustle something up for you here.

Good Luck, Jim
I started out writing this just to let
you all in on some of the freaked out

A Program For Internationals
Since the topic of the month is working in foreign countries, I thought I

Figure 1 - Printer Output Translation Program
;***************************************************************************
;*~ EPSPRN - a program to translate some IBM foreign characters to
**
;**
Epson foreign characters.
**
;**
To use, include the line , EPSPRN' in AUTOEXEC.BAT
**
;**
CAUTION - does not work correctly with graphics programs!!! **
;**
**
;**
To assemble:
MASM EPSPRN;
**
LINK EPSPRN;
;**
**
EXE2BIN EPSPRN
;**
**
REN EPSPRN.BIN EPSPRN.COM
;**
**
ERASE EPSPRN. EXE
**
;**
;**
**
Laine
Stump,
October
11,
1987
;**
**
;**
**
;**
Permission granted to do whatever you damn well please with
**
;**
this program.
**
i***************************************************** **********************
CODE

segment 'CODE'
assume cs:code
FIRSTBYTE
equ
this byte
ORG
START:

.:JMP

100h
INIT

;between here & LASTBYTE remains res.

;init code is at end so we can get rid of it.

;**********************************************************************

Contracts
If you're being hired from the U.s.,
you'll probably be required to sign a
contract guaranteeing that you'll work
for a minimum amount of time, usually
one or two. years. This is to protect the
company's investment in you. Usually
they will pay your airfare and moving
costs from the U.S. and, if you finish the
contract, they will pay the costs back as
well.
There is another expense that is often
overlooked-adjustment time. Unless
you are working in an office full of
Americans, you will be completely

66 MICRO CORNUCOPIA, #39, Jan-Feb 1988
- - - - _._------

XLATTABLE
equ
this byte
XLTLEN
equ 8
inumber of bytes in each xlation string
structure is:
IBMCHAR, up to 8 char xlation string terminated w/OFFh
currently set up to do characters important to Turkish alphabet
unfortunately there is no way to properly do an undotted small "i"
change to. fit your requirements
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB

80h,'C' ,8,',' ,OFFh,O,O,O,O
81h,lBh,'R' ,2,'}' ,1Bh,'R' ,O,OFFh
83h,'a' ,8,'A' ,OFFh,O,O,O,O
87h,'c' ,8,',' ,OFFh,O,O,O,O
8Dh,lBh,'R' ,6,'~' ,1Bh,'R' ,O,OFFh
8Eh,'A',8,'A',OFFh,O,O,O,O
94h,lBh,'R' ,2,' I' ,1Bh,'R' ,O,OFFh
98h,'I',8,"",OFFh,O,O,O,O
99h,lBh,'R',2,'\' ,1Bh,'R' ,O,OFFh
9Ah,lBh,'R' ,2,']' ,1Bh,'R' ,O,OFFh
9Eh,'S' ,8,',' ,OFFh,O,O,O,O
9Fh,'s' ,8,',' ,OFFh,O,O,O,O

C
u
a
c
i
A
0

I
0
U
S
s

would include a little assembly language
program that catches all printer output
and translates from IBM standard
foreign characters into Epson's "alternate character set" foreign characters.
See Figure 1.
The program is a TSR that installs itself over interrupt 17 (hex, of course)
and searches through a table to look for
a match for every character that is output. If a match is found, it sends a string
of 1 to 8 characters to the printer in
place of the original character. Usually, a
command is sent to switch to an international character set, print the character,
and switch back.
You can use it in other ways,
however; notice how I do c:: (C with
cedilla) by printing "C"H,". You may
even want to switch to graphics mode·
and output a bit pattern (although that
could cause problems if your program
switches to italics, subscript, or NLQ). If
you need more than 8 characters in the
translation strings, just change the number XLTLEN (and make sure you add
the correct number of filler bytes to
every entry in the table!!).
You'll notice that at certain times I ignore the translation. This was necessary
because I found that sometimes the
program was translating things like
horizontal position parameters and
graphic byte counts. My method of telling when to not translate is by no means
thorough. What is needed is a state
machine that exactly mimics the Epson
printer command set. If anybody is ambitious enough to do that, send me a
copy!
Next issue I'll show you a simple
method
of
adding
international
keyboard input to your Pc. In the meantime you can hold down the alt key
while using the keypad to type the
decimal number associated with the
character you want. For example, to get
a, just push down and hold alt, type
"128" on the keypad, then let up on alt.
Unless you have a cheap, rotten
Taiwanese BIOS ROM, you should get a
a! If not, just hang around and I'll show
you a few tricks.

P.S.
The River Trip down the mighty
Goksu was truly incredible. I can't
describe it properly with words, though.
You'll just have to come see the slides at
the next SaG.

A Reliable PC/Xl Compatible
For The
Corner Stone of Your Products

Announcing The SLY40·XT

The SLY40-XT is a small (4-114" by
9-1/4"), four layer card featuring
all of the PC/Xl mother board
functions. The board simply plugs
into a passive back plane or
SLICER'S 10 slot bus board.
o
o

•
•
•
•
o
o
o

•

High Integration - Composed of just
17 Low Power CMOS ICS
NEe's 8 MHZ V40
One Megabyte of Zero Wait State RAM
Up to 64K of ROM
8087 Co-Processor Socket
Customized Serial Port
Standard Keyboard Connector
Slicer's Own Bios, Source Code Included
Ideal For Tough Industrial, OEM and
Portable Applications
American Made and Fully Supported
by Slicer

Ask About Our Complete line of Computer
Products and Accessories!
Mas1e r Card. Visa. Check. Money Order. or C.O.D.
Allow tour weeks for delivery.
Prices subJect to change without notice.

NOTE NEW ADDRESS & PHONE NO.

Slicer Computers Inc.
3450 Snelling Ave. So.
Minneapolis. MN 55406
612/724·2710

SLICER'" Telex 501357

•••

SliCER UD
PC and Xl Are Trademarks

0'

international Business Machines

Reader Service Number 19

MICRO CORNUCOPIA, #39, Jan-Feb 1988

67

DB OA6h,'G',8,'-' ,0FFh,0,0,0,0
DB OA7h,'g',8,'-' ,OFFh,O,O,O,O
DB 0
;end of table sentinel

;G
;g

;**********************************************************************
INTl7h equ
INTl70fs
DW
INTl7Seg
DW
PREVCHAR

this dword
?
?

DB

0

;**********************************************************************
INTSERV:
OR
JNZ
CMP

MOV
JNE

CMP

JZ
CMP

JZ
CMP

JZ
CMP.

JNZ
INTSERVOO:
MOV
INTSERVOl:
JMP

U.S. Postal Service Statement of ownership. managoment and c:iraJlation (Required by 39 U.S.C. 368S) lA.
Tltle of Publicatioo: MICRO CORNUCOPIA
IB.Publication Number: 0747-S87X 2. Date ofF'iling: 93()'87 3. Frequency of Issue: Bi-moothly 3A. Number of
Issues Published Annually: 6 3B. Annual Subscriptioo
Price: $18.00 4Locatioo of Known Office: ISS NW
Hawthorne, Bend. Oregon 97701-2917 S. Location of
the Headquarters or General Business Offices of the
Publishers: ISS NW Hawthome, Bend. Oregon 977012917 6:Name and Complete Address of the Publisher.
Editor. and Managing Editor: Publisher: David J.
Thompsoo ISS NW Hawthorne, Bend, Oregoo 977012917: Editor: David 1. ThOOlpsoo ISS NW Hawthome,
Bend. Oregoo 97701-2917; Managing Editor: David 1.
Thompsoo ISS NW Hawthorne, Bend, Oregoo 977012917 7. Owner: Micro Comucopia. Inc. PO Box 223.
Bend. Oregon 97709-0223; David J. Thompson 1259
NW Iowa. Bend. Oregoo 97701-1001; Sandra S.
Thompsoo 1259 NW Iowa. Bend, Oregon 97701-1001 8.
Known Boodholders. Mortgagees. and Other Security
Holders Owning or Holding 1% or More of Total
Amount of Boods. Mortgages or Other Securities: Nooe
10. Extent and Nature of Grculatioo: Average Number
of Copies Each Issue During Preceding 12 Months A.
Total Number of Copies Printed: 20,536 B. Paid CiIculation: l)Sales Through Dealers and Carriers. Street Vendors. and COWltcr Sales: 6,5S6 2)Mail Subscriptioo:
8.m5 c. Total Paid Circulation: 15,231 D. Free Distribution by Mail, Carrier. or Other Means. Samples. CoolplimentarY, and Other Free Copies: 3.49S E. Total Distribution: 18.726 F. Copies not Distributed: I)Office
Use, Left Over. Unaccounted. Spoiled after Printing: 860
2)Retums fr

;get the original INT l7h vector

;save to call later

LEITERS
(Continued from page 4)
sumed the worst-that many other
shareware programs were so listed. In
fact, it's not as bad as I thought. But I
hope your next catalog will make the
difference very clear. Thanks for your
attention.
Neil J. Rubenking
Member, Board of Directors
Assn. of Shareware Professionals
300 Page St.
San Francisco, CA 94102

Editor's note: Points well taken. I attended the Shareware Conference last winter
and so I'm well aware of the problems faced
by the shareware industry. We're changing
the public domain column to "Shareware"
and we've corrected the catalog: Sorry for
the mistake.
Computers In Bend?
I recently received issue #37 of your
magazine as a sample copy. You should
have solicited sooner. After living in
Puyallop, Washington, and being raised
in Yakima, it's difficult to understand
how Bend, Oregon, (and I've been there)
would become the home of a decent
computer publication.
Maybe your readers already know
the history of the magazine and its staff,
but I would certainly be interested to
see it in print. How does one make a
living programming in Bend or
anyplace close to it? Is there anyplace
close to Bend?
It's been a long time since I've spent
so much time with a single issue of a
magazine. I'm currently considering
Desktop Publishing for another business
venture and found your article very informative. Having been an assembly
language programmer for over 21 years
with strong Pascal skills, "Taking The
Plunge Into C" almost makes me want
to look at the Lets-C compiler I won.
"Intro To Database Programming"
confirmed the methodology I've used in
dBase applications. The Culture Corner
was great and the EMS article was very
informative. The shareware articles were
of great interest as I'm considering distribution of several of my financial applications as shareware.
A word of warning to those considering programming the DMA controller
(see "DMA Control On The PC"). It's
very easy for a data buffer in memory to
cross a 64K page boundary. Therefore,
the beginning and ending addresses of

the data buffer should be checked to be
within the same memory page. Very interesting things happen when they are
not.
Ken Zaremba
Zaremba Enterprises Ltd.
12215 Irwin Way
Boulder Creek, CA 95006

Editor's note: Yes, Ken, there are computers in Bend, we brought them with us.
No, Bend isn't near anywhere, that's why
we're here. As for how we got here? We're
here because we like it here. Finally, you're
right, we should do a history of Micro C.
Perhaps for next issue's Culture Corner.
DMA Feedback
I found the complementary copy of
your issue #37 absolutely wonderful. I
delighted not only in its avoidance of
such pressing issues as printing multicolored directories and securing your
recipes from prying eyes, but also in its
inclusion of some down-to-earth
hardware control. At last, a magazine
that helps the electronics novice do
something substantial with that hunk of
metal and silicon that sits mutely on his
desk.
Having spent the last few months
figuring out how to get a digitizer to
write directly to the memory of an IBM
PC, it was with special interest that I
discovered the article by Larry Fogg,
"DMA Control On The pc." He is
grossly understating the case when he
says that this subject can be confusing. It
can be downright mystical, and his was
one of the most concise and exacting
descriptions of this Great Mystery of the
PC that I have seen.
Being naturally nit-picky, I can't
resist finding one small fault with the
article as it stands. In its discussion of
registers, the article states that the DMA
page registers for channels 0-3 are at addresses 80h to 83h, respectively.
Actually, addresses 81h, 82h, and 83h
map to channels 2, 3, and 1. Channel 0
is at address 87h. I guess this is just
another of IBM's attempts to keep us
from turning to more boring pursuits,
like skydiving.
Eric J. Pilger
Institute for Astronomy
2680 Woodlawn Dr.
Honolulu, HI 96822

C issue #37 that IBM had taken the
liberty of violating the 2 msec refresh
spec of the dynamic RAM chips. It just
didn't sound like the usual conservative
IBM engineering.
It didn't occur to me until the next
day that you had said, "We know that it
takes 512 DREQOs to refresh all of
memory ..." Not quite. I recall working
with 4116 16K X 1 chips that had 128
rows requiring refresh. When 4164s
came along, most manufacturers gimmicked them to also require only 128
refresh cycles.
I remember doing an upgrade of an
Atari 400 from 16K to 64K, replacing the
4116s with Micron Technology 4164s.
The poor Atari would work for a moment, then lose its mind. It turns out
that the Atari controller cycled only AO
through A6 for 128 refresh cycles and
the Micron SpuDRAMs were among the
few 4164s requiring 256 cycles. Other
4164s worked fine.
To get to the point, beginning with
the first popular 4116s (and even into
the 1 Meg chips), manufacturers have
maintained the refresh requirement of
128 rows per 2 msec. As the number of
rows requiring refresh has doubled with
each generation, the total time to refresh
all rows has also doubled. The seven
plus msec that you figured for 512
cycles actually turns out to be, surprise,
a bit less than two msec for each 128
cycles.
The good news is that I think it's a
great idea to adjust the refresh timer to
. squeeze out a few more milliMIPS. It
hasn't seemed to make my clone the
least bit nervous. I enjoyed the rest of
the DMA article very much, and learned
a great deal about the subject.
I have one question. I know that the
IBM manuals are the definitive source
for technical information, but I don't
have the hundreds of bucks for a complete set. The schematics that came with
my clone are microscopic. Is there some
other source?
Gary Crowell
2014 W. La Palma
Anaheim, CA 92801

Editor's note: We don't know of another
source for the main board schematics. Sams
may have a book out now. Several folks
wrote in pointing out the error in the
refresh discussion. Thanks.

More DMA Comments
I was very surprised to read in Micro

•••

MICRO CORNUCOPIA, #39,Jan-Feb 1988

69

All Aboard The ARC
SHARE
WARE
Tony Barcellos teaches mathematics at American
River College in Sacramento and has a T-shirt that
By Anthony Barcellos says "ARC" on it. He is also Sacramento PC's
P.O. Box 2249
software librarian and editor of Sacra Bllle, its
Davis, CA 95617-2249
monthly newsletter.
(916) 756-4866

OU have a nifty public domain or
shareware utility you want to send to a
friend. Since both of you have modems,
this should be easy, right?
In the olden days, the program you wanted
to share was most likely a tiny public domain
. utility in a single disk file. Today the programs
we exchange are dominated by shareware, and
most of these comprise collections of companion files. Thus the delivery of the nifty
program becomes a tedious transmission of
filel, file2, file3 ... , until the job is done.

Y

In Single File
Computer users didn't put up with that for
very long. The "library utility" LU came along
as a means of lumping multiple files into a
single "library" file. Now you could send
everything in a single transmission.
Of course, this single transmission might
take a very long time, since the one lumpedtogether file could be a pretty large lump.
"Squeeze" programs were used to compress
the files before they were merged by LU into a
library.
Thus there developed the routine known so
well to software librarians and bulletin board
fans: squeeze the files, library the files, upload
the library, download the library, break up the
library, "unsqueeze" the files. All of us had a
suite of programs like SQZ, NUSQZ, LU, LU86,
USQ, ALUSQ, etc., to squeeze, library, and unsqueeze program files. You won't be surprised
to learn that the proliferation of utilities for
these purposes led to numerous improvements-and, of course, incompatibilities.
All Aboard The ARC
Then Thom Henderson of System Enhance-

70

MICRO CORNUCOPIA, #39,Jan-Feb 1988

ment Associates (SEA) had a better idea. Why
not create a single utility program that would
take care of the entire process. In a break with
the past, Henderson called his libraries
"archives" and SEA's program was released in
March, 1985, under the name ARC.
ARC took the shareware world by storm.
Electronic bulletin boards across the country
embraced the new standard. LU headed for the
shelf. The .ARC extension blossomed on the
BBS download directories. While I still keep
copies of LU and LU86 in my utility collection
for handling old files with the outdated library
extension (.LBR), today's utility of choice is
ARC.
Of course, soon there would be other ARCtypal programs with their numerous improvements. (And-uh oh!-incompatibilities.)
Everybody Into The Pool
ARC's sudden primacy did not remain unchallenged for long. SEA had unknowingly
launched a revolution, and those that rushed to
its standard brought along a few new ideas of
their own.
The first skirmishes of the ARC revolution
were fought on the bulletin boards where
SYSOPs who clung to LU criticized ARC's performance. Indeed, as the LU partisans fell back,
ARC failed to move in quickly enough and
some of the abandoned territory was seized by
swiftly moving clones.
Phil Katz of PKWARE is the author of
PKARC and PKXARC, archiving and archive
extraction utilities, respectively. PKXARC was
his initial release, intended to speed the process
of pulling files out of an archive. Written in assembly language, PKXARC left ARC in the
dust. SYSOPs and software librarians appreciated Katz's five-fold speed advantage and
PKXARC became well-established.
SEA Changes
ARC evolved by stages into version 5.20,
released late in 1986 with improved performance and enhanced compression algorithms.
The program currently comes in the form of an
executable file that is itself an archive. It can be

found in software libraries and on BBSs
as ARC520.COM. When executed (just
enter "ARC520" at the DOS prompt),
the program performs a self-extraction,
generating the files ARC.EXE (the actual
ARC program) and ARC.DOC (the
user's manual), ARC.TXT (a word from
our sponsor), and ARCE.COM (a special
archive extraction utility).
The documentation for ARC is quite
good, detailing the program's numerous
options. ARC can, of course, add to or
delete files from an archive. It can update archive files (adding missing files
or overwriting existing files with newer
versions), freshen them (updating only
files that are already archived, adding
no new ones), display text files (without
extracting them), execute archived
programs (without extracting them), and
'list archive contents. Other options

you're transmitting a file long-distance,
and size is time!)
The "stowage factor" shows the degree to which a file was reduced. In the
given example, overall file size fell by
28%.
Raising The Standard
Not content to confine its efforts to
high-performance archive extraction,
PKWARE introduced its first version of
PKARC in August, 1986. Yet another assembly language speed demon, PKARC
was offered (accompanied by PKXARC)
as a complete alternative to ARC.
Both PKARC and PKXARC are now
at version 3.5 and are distributed as a
self-extracting executable archive file
called PKX35A35.EXE, released in April,
1987. Upon entering "PKX35A35" at the
DOS prompt, you are presented with the

Figure 1 - ARC Generated Archive, Time: 9 Min. 15 Sec

----

llama

I!A.DRS12 •EXE
MTNCALC .EXE

Length

RESPONSE
SETSCRN. COH
SET SCRN.EXE
SNAPSHO'!' •CCH
SWC0H12.COM
SWLPT12.COH

15091
119463
1792
4520
114695
128
896
14573
5120
6144
2048
22433
10752
3584
5120
13056
1024
70
6415
5444
340
349

Total

353057

CAL. OAT

CALENDAR. CCIII
DISlWlIL.ZXZ
DOZEN. BAT
DOZEN.TBL
rILZCOMI? • EXZ
GXZY.EXZ
LOCA'l'E. EXZ
ORDER.
P90.EXE
PC SOR.T.EXE
PRi I'ILE. £XE
RDii.EXE
READ.ME

22

-stowage

Crunched
Crunched
Crunched
Packed
Crunched
Packed
Crunched
Crunched
Crunched
Crunched
Crunched
Crunched
Crunched
Crunched
Crunched
Crunched
Crunched
Packed
Crunched
Crunched
Crunched
Crunched

govern the file storage format, the way
files are archived ("added" with the
original file remaining or "moved" with
nothing left behind), and archive integrity.
The "verbose" file-listing option
produces a detailed list of archive contents. (See Figure 1.) The "stowage"
column identifies the packing routine
used by ARC in adding a file to the ar-.
chive. Files can be "stored" (added
without
compression),
"packed,"
"squeezed" (no longer supported in the
most recent version of ARC), or
"crunched." As a file is examined before
archiving, ARC determines which compression algorithm will produce the
smallest archive. (Time is money when

sr

Size now Date

en=n-==="

2"
82'
26'
28'
34%
32t
5It
2"
35'
41'
44'
5It
32'
5'
20'
23'
1"
18%

12621
89499
1097
4360
84343
24
667
10493
3399
4187
1004
16474
7091
2135
2906
6503
701
67
5176
4209
283
289

28'

257528

17'
26'
39'

'"

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

JUn
JUn
JUn
JUn
JUn
JUn
JUn
JUn
JUn
JUn
JUn
JUn
JUn
JUn
JUn
JUn
JUn
JUn
JUn
JUn
JUn

.run

Time
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87
87

1:00a
1:00a
1:00a
1:00a
1:00a
1:00a
1:00a
1:00a
1:00a
1:00a
1:00a
1:00a
1:00a
1:00a
1;00a
1:00a
1:00a
1:00a
1:00.
1:00.
1:00.
1:00a

cae
5CC6
3231
CD2B
829B
1BC2
40BA
609B
CD43
B582
A861
1'648
3455
D91C
0951'
C2Z1
8568
7963
3D03
SADI'

1'3A1
156C
AB9A

files
PKARC.COM,
PKARC.DOC,
PKXARC.COM,
PKXARC.DOC,
PKXARC}R.COM,
MAKESFX.COM,
PKSFX.DOC, and README.DOC. The
.DOC files are the expected user's
manuals. The MAKESFX utility is used
to create self-extracting archives and is
explained in PKSFX.DOC.
PKARC offers enhanced file compression as well as a drastic performance
edge over ARC. A collection of ButtonWare shareware utilities called Baker's
Dozen provided guinea pigs for a performance comparison of ARC versus
Phil Katz's alternatives. The ButtonWare
programs totaled 353,057 bytes and
completely filled a standard 360K floppy
disk. The files were copied to a hard

disk for the performance tests.
The archive illustrated in Figure 1
was created by ARC in 9 minutes and
15 seconds on a standard IBM PC with a
hard disk and a clock speed of 4.77
MHz. On the same system, the identical
files were archived by PKARC in 1
minute and 27 seconds. PKARC also
achieved a 30% reduction in overall file
size versus only 28% for ARC. (See
Figure 2.)
PKXARC beats the pants off ARC on
the file-extraction side. While ARC disassembled its Baker's Dozen archive in 5
minutes and 30 seconds, PKXARC took
only 1 minute and 2 seconds to dismantle the similar archive created by
PKARC. (PKXARC required an additional 5 seconds when used on the archive created by ARC.)
Upward, Ever Upward
SEA and PKW ARE have both been
careful to maintain compatibility with
earlier releases of their utilities. For its
part,
PKWARE
has
consistently
produced programs that adhere to the
archiving standards set by ARC. In
release 3.5 of PKARC, however,
PKWARE for the first time goes beyond
ARC by introducing a compression algorithm not yet supported by SEA. Like
LV and its variants of olden days (that
is, two years ago), archives now suffer
from incompatibility.
The
"verbose"
archive listing
produced by PKARC for the ButtonWare programs (Figure 2) shows the
stowage method that PKWARE calls
"squashing." ARC chokes on archives
that contain squashed files and issues a
message suggesting that perhaps you
need a new version of ARC. (ARC
responds this way any time it sees an
unfamiliar archive format.)
PKARC also permits the user to annotate archives with brief descriptions
of their files. While this feature does not
directly conflict with ARC, the comments are invisible to the SEA program,
Phil Katz warns that PKARC-created
comments will be lost if an archive is altered in any way by ARC.
H PKWARE and SEA continue to
diverge in their implementations the
user is in for trouble. Fortunately,
PKWARE has provided an "old
compatibility" option to disable filesquashing and preserve ARC-compatible archive formats. If you forget to
invoke this option, however, you can
send someone an archived file that he
can't extract (just as I did when I transmitted my first Micro C column).

MICRO CORNUCOPIA, #39, Jan-Feb 1988

71,

(Editor's note: Tony's first piece was a lot
more interesting after we finally
decompressed it.)
Buerg To The Rescue
Just in case squashing becomes
popular, SEA now distributes Vernon
Buerg's ARCE extraction utility with
ARC. Better known for his excellent
LIST program, Buerg is a craftsman
whose tools should be welcome in
anyone's utility room. He's included
"unsquashing" in ARCE so that

and customized
programs. Contact:

versions

of

its

PKWARE, Inc.
7032 Ardara Avenue
Glendale, WI 53209
PKWARE requests a $20 contribution
for use of either PKARC or PKXARC. A
$45 registration fee entitles you to a diskette with the next release of both
programs and their companion files.
Remember to report the version you're

Figure 2 -.PKARC Generated Archive In 1 Minute, 27 Sec.
ri1.1UUU1

Length

Method

Sbe

Ratio

Date

~iae

BA..DRB12.ZXE
ftD'CALC.ZXE
CAL.DAT
CA:LERDAR. CON
»IS1ttr.rIL.ZXE

15091
119463
1792
4520
114695
128
896
14573
5120
6144
2048
22433
10752
3584
5120
13056
1024
70
6415
5444
340
349

Crunched
Squashed
Crunched
Pack.d
Squashed
Packed
Crunched
Crunched
Crunched
Crunched
Crunched
Crunched·
Crunched
Crunched
Crunched
Squashed
Crunched
Packed
Crunched
Crunched
Crunched
Crunched

12414
85411
1097
4375
80206
24
666
10240
3285
4006
1005
16111
6965
2135
2913
6564
701
67
5165
4185
283
289

18%
29l1r
39%
4%
31%
82%
26%
30%
36%
35%
51%
29%
36%
41%
44%
50%
32%
5%
20%
24%
17%
18%

06-01-87
06-01-87
06-01-87
06-01-87
06-01-87
06-01-87
06-01-87
06-01-87
06-01-87
06-01-87
06-01-87
06-01-87
06-01-87
06-01';'87
06-01-87
06-01-87
06-01-87
06-01-87
06-01-87
06-01-87
06-01-87
06-01-87

01:00:00
01:00:00
01:00:00
01:00:00
01:00:00
01:00:00
01:00:00
01:00:00
01:00:00
01:00:00
01:00:00
01:00:00
01:00:00
01:00:00
01:00:00
01:00:00
01:00:00
01:00:00
01:00:00
01:00:00
01:00:00
01:00:00

248107

30%

--------

DOZU.BA~

DOZEN. ':rBL
I'ILECOMP .ED
Q1tEY.EXE
r..ocAD.EXE

ORDER
P90.EXE
PC SORT.EXZ
paN rILE. EX&:
RDm.EXE
RUD.HE

RESPONSE
COX
SCRN. ED
SNAPSHOT .CCM
SWCOH12. COX
SE~Sc.RH.

8J:~

sw:r.P~12.COH

·0022

353057

PKWARE archives can be imported into
SEA environments.
Whether this portends new features
in ARC isn't clear. We'll just have to
wait for version 5.3. In the meantime,
devoted ARC users will find that ARCE
is also a performance demon and much
faster at file extraction than ARC itself.
The Passengers On The ARC
ARC can be obtained directly from:
System Enhancement Associates, Inc.
21 New Street
Wayne, NJ 07470
for $50, which includes a program disk
and printed documentation. If you obtain ARC from a software library or BBS,
you must remit a license fee of $35
before using the product in a commercial or government environment. Contact SEA for details on site licenses and
commercial distribution.
PKWARE also offers site licenses,
volume discounts, commercial licenses,

72

cae
5CC6
3231
C:02B
829B
1BC2
40U
6D9B
c:043
B582
M61

1'648
3455
»91C
0951'
c2E1
85GB
7963
3»03
SADI'
r3Al .
156C

AB9A

using when sending in your registration
fee.
Vernon Buerg can be reached in Daly
City, California, or contacted via his
Fido BBS.
Vernon Buerg
456 Lakeshire Drive
Daly City, CA 94015
BBS: (415) 994-2944, FidoNet 125/4

References
The actual compression algorithms
used by ARC and PKARC are quite
complicated. The SEA documentation
refers to articles which contain the
details. Also, the March, 1987, issue of
Dr. Dobb's Journal contains extensive
benchmarks on the performance of ARC
and its competitors.
Button, Button, Button ...
I picked Jim Button's Baker's Dozen
as the test subject for my archiving experiments because I just recently put it

MICRO CORNUCOPIA, #39, Jan-Feb 1988

into the Sacramento PC softWare library.
In a way, Baker's Dozen harks back to
the small, single-purpose utilities that
used to pepper theBBS landscape. Although ButtonWare concentrates on fullfledged application packages like
database managers and word processors, the Baker's Dozen grab-bag of
utilities adds a nice dash of spice to the
company's offerings.
On the Menu
Baker's Dozen comes with a menudriven front-end that the steady user
will soon abandon. As the documentation admits, the menu is "only intended
to get you started. Normally you should
run Baker's Dozen programs by themselves." However, it's a good way to get
a first look at what the ButtonWare
utilities can do for you.
BttnCalc. Is your application too
small to justify Lotus 1-2-3 or SuperCalc? Then try the ButtonCalc one-page
spreadsheet from ButtonWare. You can
save and reload your work, of course.
Calendar. Yet another calendar
program. But this isn't an appointments
calendar. It's a programmable date
calendar that pops a display into the
corner of your screen. Use the cursor
keys to page through the various
months. Make the program resident
(one of its options) and find out any
date at any time from within any
program.
DiskUtil. Need I say more? Nibble on
bytes to your heart's content. Hop from
file to file or directory to directory.
Render your FAT. Raise files from the
dead. Not for children or first-timers.
FileComp. Fed-up with the wimpy
DOS COMP command? Button's
program will compare two text files and
display the line numbers of unique
lines, the unique lines themselves, or a
map of matching line numbers or lines;
it can ignore spaces in its comparisons.
GKey. Get all the keyboard information you want: key number, scan code,
hexadecimal and decimal ASCII values.
Locate. Another descriptive name.
Find files wherever they may be lurking
or even find all files containing a
specified text string. You can make the
text search insensitive to case.
P90. This is a "sideways" printing
program for Epson-type printers. Where
did that name come from? "Print 90
degrees."
PC_Sort. Use command-line options
or let the program prompt you for up to
four fields by which your file should be
sorted. Ascending, descending, case sen-

sitivity, column offsets, and field lengths
are all under your control. (Vernon
Buerg has a wonderful sorting program
called SORTF that you might also be interested in. It makes the DOS SORT filter look sick.)
Pm_File. Redirect printer output to a
file. (How did this get left out of DOS?
That's what I'd like to know.) Make a
program that demands a printer feel
right at home on a printerless PC-or
capture information you'd rather have
on disk than on paper.
RDir. Remove a subdirectory and all
of its contents, including lower subdirectories.
Set_Scrll.
Choose
your
screen
foreground, background, and border
colors. Requires ANSI.SYS.
Snapshot. A screen-grabbing utility
that can be made resident. Works only
with text screens.
SWCOM12. Swap COM ports land
2. (What else is there to say?)
SWLPT12. Yet another utility to swap
LPTl and LPT2. (If you're one of the few
people with three active parallel ports,
then you might prefer LPT3SWAP.COM
from HullSoft, which moves all three
ports in a cycle. It's available for
downloading from various BBSs 'in
Sacramento and San Francisco.)
As usual, ButtonWare has another
solid product that will benefit users.
While some entries in the Baker's Dozen
are old hat, the collection as a whole is
very nice. You can also trust ButtonWare products to be free of major bugs
and easy to use. Baker's Dozen fits firmly into this ButtonWare tradition. The
registration fee for the Baker's Dozen is
$59.95. Add $5 for shipping and
Washington state residents must include
8.1 % sales tax.
Jim Button
P.O. Box 5786
Bellevue, W A 98006
Toll free: 1-800-JBUTTON

•••

MAllBASE SYSTEM™
ProductIvity Software
for DBase/Wordstar/Ventura Publisher
• Letters/forms/contracts. Production. Record keeping. Grouped/repeated
work, variations • Secretarial or professional use • Meeting management • Desktop
input • dBASE file organizer • Develop your own specialized system with no programming • Constant or on-the-fly formatting • Stackware with standard programs

Painless construction of general letters, customized contracts, tabbed tables for
Ventura Publishers, etc; from dBASE II or III files. Use any version dBASE & Wordstar/MM.
Track meeting participants; contracts; business letters; automatically make action
summaries. Over 5 years of practical development. Never again type anything twice.
MS/PC-DOS, but also an Apple II CPM-Softcard version (not 7),5114 disks.

--FEATURES - 1. Use any dBASE file & fields up to 214 (charactel1 or numeric):
2. Automatically track outgoing multl-copy lettel1 &variants:
3. Select any fields at run time for letter Integratlon. adjacent fields for block text
4. Branch to alternate lettel1 In a single mall merge pass then summarize regional actions:
5. Copy any fields to subsequent records, either old or newly appended, for letter/contract producUon:
6. Make consistent "structure extended" data dictionaries In dB format for transparent systems management;
7. Produce correctly tabbed 2. 3, or 5 col. tables for Ventura Publisher from any dB HIe;
B. Other dB file management & producUon utilities: 2 col. Harvard Publisher tables, (other wp's on requost):
9. On-disk documentation: manual: tutorial: examples: letter/contract skeletons. Hardcopy manual S12 extra:
10. Use to customize Invoicing systems, meeting management operations without programming.
• NOT COpy PROTECTED
• Mail order only, $10 secondary sales rebate
• Money order or personal check (allow ten days to clear).
SEND TO:

HARGER I.N.T.
P.O. Box 20, Grand Central Station
JKT Pouch
New York, New York 10163

ONLY

$45

dBASE II & dBASE III are trademarks of Ashton Tate, Wordstar & Mailmerge are trademarks of MicroPro. Apple II is a trademark of
Apple Computer Inc. Softcard, MS-DOS & Microsoft are trademarks of Microsft Corporation, CP/M is a trademark of Digital Research
Inc. PC DOS is atrademark of International Business Machines Corporation. Ventura Publisher is atrademark of Univation Inc. Harvard
Publisher is a trademark of Software Publishing Corporation.
. Reader Service Number 26

~
.

_

I

Why are serious PC software developers

demanding ... .

.!.

..

~1V111L·

~
Because Show Me! is the NEW "must have" tool for today's PC programmer.
With this memory-resident, file-windowing utility, see your productivity soar as you view as
many as four files at once instantly (in ASCII, EBCDIC or hexadecimal) at the touch of a key.
• escape that caged-in feeling while programming in Turbo Pascal, Turbo Prolog,
Turbo C, Turbo BASIC, QuickBASIC 4.0, dBASE, BASICA, and similar
programming environments, and work with up to four additional program files at
once -- complete with copy & paste, print, and search capabilities
• view multiple source and listing files in up to four windows while using CodeView,
DEBUG, SYMDEB, and other debuggers -- great for assembly programming!
• peek at any ASCII file including Wordstar document files and easily paste all or part
of a file into virtually any program that accepts keyboard input
• visually compare files side-by-side in simultaneously scrolling windows
a find your files in the built-in directory window

Order Show Me! today for only $39 (+$5 S/H)!
To order call toll-free 800-634-3122
Visa and MasterCard accepted • 3D-day satisfaction guarantee • Not copy protected
~

Ask about So Help Me!, a flexible, context sensitive help screen driver. Add fullcolor help screens to all your programs - royalty free - for only $79!

Serengeti Software • P.O. Box 27254 • Austin, Texas 78755 • 512-345-2211
Show Me! & So Help Me! trademarks Serengeti Software: Borland Int'I, MicroPro, Ashton-Tate & Microsoft trademarks acknowledged.

Reader Service Number 27

MICRO CORNUCOPIA, #39, Jan-Feb 1988

73

CP/M Notes

Speedy CP/M
Now that there are several super fast CPUs
running the 2-80 instruction set, I would like to
see a thorough comparative review of the systems that use them (SemiDisk's DT-42,
Micromint's SB180FX, and High Tech
Research's Ultraboard).
As a Kaypro owner, I welcome these
developments in the CP1M arena and hope
that they don't get overshadowed by the lemming-like rush to the MS-DOS ocean.
Douglas C. Campbell
17 McMaster Ave.
Toronto, Ontario
Canada M4V 1A8

Editor's note: We're interested in recent CP/M
developments, also. Read on for more information.
Ultra board Status
I spoke with Bill Nesting of High Tech
Research recently to see how they were
progressing on their 2280 board for the
Kaypro. They've solved some problems they
had been experiencing with the NCR video
chips. However, the NCR chips aren't quite up
to the performance Bill wants. He's talking
with Hitachi and will make a decision soon. A
change to the Hitachi chips would add $50 to
the Ultraboard's price.
An interesting addition to the Ultraboard is
Advanced Concepts Engineering's hard disk
controller. This option adds another $99 to the
price.
Production quantities of the new "bug free"
2280 are expected by the first of the year. If
High Tech goes with the NCR chips, they hope
to be producing boards in November. A switch
to the Hitachi chips would delay production
until January 1. In that case, all boards should
contain the new 2280. If boards are produced
before the updated CPU is available, High Tech
Research will do upgrades for $40.
High Tech Research
1135 Pine Street #107
Redding, CA 96001

74

MICRO CORNUCOPIA, #39, Jan-Feb 1988

800·446-3220
800-446-3223 (CA)
Micro C Staff
Kaypro Keyboard Fix
During a very humid time of the summer,
my Kaypro 11-83 keyboard began to misbehave.
Every other key on the third row (beginning
with TAB) went crazy. At first I thought it must
be the excess humidity. After running a
dehumidifier for a while things improved-but
only temporarily. A visual check of the
keyboard circuit board showed nothing amiss,
so I began to think about shelling out for a new
one. (That was before Kaypro announced the
$20 deal on its surplus keyboards.)
But before sending for a new keyboard, I
gave it one more try. I disassembled the
keyboard, removing the dozens of little brass
screws which hold the printed circuit board to
the keys. I gave the circuit board a thorough
cleaning with a spray can of cleaner-degreaser
and inspected it closely. On that suspect third
row of keys, I found the culprit. Little green
crystals of corrosion were shorting traces
together and causing the keyboard to issue
bursts of garbage.
To restore the keyboard to operating condition, I used a tiny jeweler's screwdriver to
scrape away the corrosion-very carefully, of
course. An orange manicuring stick would
work well, too.
When I was sure all the corrosion was gone,
I reassembled the keyboard. On powering up
the old Kaypro, everything worked properly
and I have had no further problems. A local
computer repair technician told me that most
flaky keyboards can be fixed this simply.
Joseph I. Mortensen
4214 Chelsea Ct.
Midland, MI 48640

•••

CP/M: Some people love it, others love to hate it, but most still use it. Its users complain that most software
companies have abandoned it. Very true, yet ~ haven't! We've been selling the ConlX software line for
many years; we developed it, we market it, and we support it - completely! What?1 You haven't tried It?
Saving the best for last, eh? Don't wait! Support your CP/M software company - try ConlX for as low as $10J
What's more, you could even get lucky and receive your entire order FREEl See details below.
ConlXTM
Operating
System

ConlXTM
Programming
System

An extensive upgrade for 48K+ CP/M 2.213.0 and equivalent systems.
Provides professional capabilities with blinding speed, as often found on
high-end UNIxn' machines. Installs easily in just minutes to add over 100
new built-in commands and features while maintaining 100% compatibility
with all your existing software! Includes VO redirection, aliases, improved
user area access, auto-searching, PF Keys, Screen Paging, Print Spooler,
Archiver, New SysCalls,... Eliminates many points of user frustration
with CP/M. Uses only 1/2K TPA, 0-27K disk minimum.
Included FREE with commented source is the Pull-Down Menu System,
a user-friendly interface to ConiX. Loads with a single keystroke!
ConlX is the greatest, most powerful8-bit upgrade, with speed and
capabilities that are so incredible it's bringing users back to CP/M!
A structured programming language for ConlX extends CP/M SUBMIT
capability. Adds conditionals, loops, subroutines, labels, nesting,
interrupt processing, error traps, and debugging facilities. DeSign
intricate menu systems and command-automation shells. Also includes
a special source-code ·compiler" that provides string and numeric
variables. An absolute mustfor CPIM power-users and developers!

ConlXTM
library Vol. I
XCC Utilities

Over 25 utilities for ConlX written in the shell language, including
hierarchical directories with overlay -adds pathname capability to
existing software, interactive debugger, move/copynink multiple files,
print files with pagination, review disk files for deletion, unerase disk
with stats, full-screen TYPE, and more. Source code included!

ConlXTM
Shareware
Version

Anew Shareware version of the ConlX O.S. includes our regular
distribution software less the Archiver, On-Line Manual, Menu source
code, and some satellite utilities. ConlX Shareware is available through
CHI for just the cost of the diskette and shipping, or on-line via many
popular bulletin board systems. Register by purchasing regular Con IX.

ConlXTM
Disk Manual
Version

To reduce the cost for those who want to purchase only the ConlX O.S.,
we are offering the complete software package with documentation
provided on disk. The disk manual has each chapter stored in individual
files, excluding the Chapter Summary, Chapter Reference, and Index
sections that come standard in our regular typeset manuals.

That's right! Every 100th order processed by our computer will be shipped with a
Credit Certificate for the total purchase price or $100, whichever is lower. This
credit may be used toward a future purchase from CHI, or may be redeemed for
cash w~hin ninety (90) days of receipt. Your odds are an incredible 1in 100!
Offer applies only to private individuals and non-profit institutions ordering directly from CHI. Orders placed
by PO or purchased for commercial use are not eligible. To enter, certify eligibility by signing order form.
Product Trademarks - CP/M: Digital Research Inc., ConlX: Computer Helper Industries Inc.• UNIX: AT&T Bell Labs.

Reader Service Number 6

MICRO CORNUCOPIA, #39, Jan-Feb 1988

75

The Kaypro 4-84 Internal
Modem

G. R. Blowers

We were somewhat hard pressed for a Kaypro
column this issue when, 10 and behold, this terse
treatise on the Kaypro's modem came in on our
RBBS. The original file was dated April, 1984, but
the information is timeless.
For those of you doing interesting things with
your Kaypros: think about submitting an article to
Micro C. We'd like to see what you're up to.

his article documents. the internal
modem in the Kaypro 4-84. I got the information by decoding the relevant
parts of ST.COM (provided on the
CP /M disk). Some of the code comes straight
from ST and some is code that I used to test the
various modem functions.
The 4-84's modem is not a smart type (not
Hayes compatible). It consists primarily of two
TI chips-an FSK modem, and a dialer. All
programming and filtering must be done by the
user. The modem makes use of both a parallel
and a serial port. Each of these ports must be
programmed.

T

Port Locations
The parallel port lives at 21h, with its command port at 23h. You'll find the serial port at
ODh, and its command/status port at OFh. The
modem appears to use the normal modem CTC
port of OOH, which needs to be set up for 300
baud (outp(O,5». I'll divide this discussion into
four parts: port bit usage, initialization, modem,
and dialing.
I don't intend to decode ST any further than
I already have. All I want, or need, is enough to
put the internal modem through its paces. Although I can find no copyright notice in
ST.COM, I presume Kaypro considers it
proprietary. Therefore: No commercial use may
be made of this information without prior written consent from Kaypro Corporation.
Parallel Port Bit Usage
The low nibble (bits 0-3) of the parallel port
(21h) is used for dialing. Place the number (not

76

MICRO CORNUCOPIA, #39, lan-Feb 1988

the ASCII) here when dialing. During modem
use, send this nibble a OAh.
Bit 4 sets the dial mode, reset (zero) for tone
and set (one) for pulse. It must be set during
modem operation. Bit 6 specifies off! on hook.
A reset bit 6 means off-hook and set means onhook. Setting bit 7 commands the dialer to do
its thing.
Serial Port Bit Usage
On to the serial status/command port at
OFh. Read Register 0 (RR#O) behaves normally
except for bit 5. Bit 5 seems to be used for ring
detection. It looks at DCD (Data Carrier
Detect).
See Figure 2 for initialization of write
registers 0-4 (WR#0-4).
In WR#5, RTS (Request To Serid) and DTR
(Data Terminal Ready) are important. Setting
RTS enables the modem. With RTS set and
DTR reset, the modem goes to originate mode.
The combination of RTS set and DTR set gives
the answer mode.
The serial data port lies at ODh.
Initialization
The CPU must be initialized to 1M2 and interrupts must be enabled. Then load the interrupt vector, and finally, enter the interrupt service routine. Although the code could be
anywhere, I chose to use the page 0 restart
area. See Figure 1 for the CPU initialization
code and Figure 2 for port initialization.
Modem Use
Figure 3 contains code for operating the
modem. The dialing routine (Figure 4) comes
from ST.COM. I found that a delay was needed
between numbers. The code assumes that
register A contains a valid number. Remember,
this is not the ASCII representation of the number, but the actual binary number, zero through
nine.
All filtering and selection of tone or pulse
mode dialing must be done prior to entering
the dialing loop. I won't go into the detection of
carrier or switching to the modem mode as
they are straightforward. Normal conventions

Figure 1- CPU Initialization

Improve
Your

;this routine (until RET) must be called during initialization
;of the main program.
The whole thing must be loaded prior to
;being called.
0008
0009
OOOB
0000
OOOE
OOOF
0010
0012
0013

XOR
LO
IM2
EI
RET
DB
OW
EI
RET I

A
I,A

;set A to 0
;hi byte of interrupt vector
;PIO set up to use IM2 only
;enable them

00
0012H

;skip to make next hit even
;vector to next word on interrupt
;do nothing interrupt service
;go back where we were

Manual

Dexterity

Figure 2 - Port Initialization
outp(OX23,OXOF);
outp(OX23,OX87);

/* set port to output mode
/* enable interrupts

outp(OX23,OX10);
outp(OX21,OX4A);

/* set low byte of interrupt vector */
/* initialize port
*/

New Desktop
Services From
Micro C

*/
*/

outp(OXOF,Ox18);
/* I used the "normal" SIO initialization
outp(OXOF,l);
/* rather than the one in ST.COM except
outp(OXOF,O);
/* for WR#S */
outp(OXOF,3);
outp(OXOF,OxC1);
outp(OXOF,4);
outp(OXOF,Ox44);
outp(OXOF,S);
outp(OXOF,Ox68);
/* this is abnormal, but from ST.COM
call(Ox08,0,0,0,0); /* this calls the CPU initialization
/* I didn't use it during trial runs /* an oversight on my part and it
/* appeared to work without it. But to
/* be on the safe side it should be
/* included

*/
*/

*/
*/
*/
*/

*/
*/
*/

Figure 3 - Modem Operation Code
/* the following take the modem off-hook
/* delays a bit
/* makes parallel port ready for modem work
/* selects WR#S
/* selects modem in originate mode outp(OXOF,OXEA)
/* this function would set answer mode and finally
/* go to terminal mode of YAM
outp(OX21,OX4A); /* code to go back on-hook (hangup)
outp(OX21,OXOA);
sleep(l);
outp(OX21,OX1A);
outp(OXOF,OXOS);
outp(OXOF,OX6A);
term() ;

*/

*/
*/

*/
*/
*/
*/
*/

Figure 4 - Dialing Code
LO
IN
AND

OR
RES
OUT
SET
OUT
RES
OUT

C,A
A, (021H)
OFOH
C
7,A
(021H) ,A
7,A
(021H) ,A
7,A
(021H) ,A

; put it in C for later
;get present value of port
;strip low nibble
;put number to be dialed in proper place
;lower dial command
;put it out
;raise dial command
;put it out
;lower dial command
;put it out

for Rx character available and Tx buffer
empty apply. Be sure to include
timeouts for no answer or carrier.
I hope that this helps you write the
necessary patches to the standard
MODEM programs. I don't intend to
carry it any further than possibly customizing a version of YAM (Yet Another
Modem program).

•••

~Oq1;II!
JuEg 14 - Jufy 16
'Bend, Oregon

You've no doubt followed our
trials and tribulations as we've
come to grips with desktop publishing.
Now that we have the magazine
under control we're branching out,
sharing our expertise with those of
you struggling with manuals, ads,
newsletters, whatever.
We'll design a style sheet for
you, then take your (ASCII,
WordStar, WordPerfect, or other)
text, illustrations, and listings, from
disk, paper, or our RBBS and put
them together. What you get in
return are pages ready for the print
shop. And you'll get them for less:
usually 1/5th the price of the oldfashioned graphics services. (Of
course when it's time to revise the
piece, the old-fashioned methods
aren't even worth considering.)
Services Include:
• Graphic Design
• Graphic Production
• 300 dpi Proofing
• 300,1270,2540 dpi Final Art
• Illustrating
• Scanning
• Schematic Drafting
• Technical Editing
• Proofreading
For more infonnation, contact
Carol Steffy or
David Thompson
Micro Cornucopia
PO Box 223
Bend Oregon 97709
503-382-8048

MICRO CORNUCOPIA, #39, Jan-Feb 1988

77

Technical Tips

Ventura Fix
As both a programmer and a desktop
publishing specialist, I have been following with great interest the continuing
saga of Micro Cornucopia's adventures
with Xerox Ventura Publisher. I think
your descriptions of Micro C'5 implementation of Ventura are among the
most informative and best-written articles that I have read on desktop
publishing (and as research director of a
desktop publishing training center, I
read a lot of articles on the subject).
In the November/December issue
(#38), your article "Laser Printers,
Typesetters, and Page Description
Languages" covered some problems you
were having with screen fonts in version
1.1 of Ventura. These problems can be
fixed quite easily.
Ventura provides screen fonts only
for the "common" text sizes (Le., 10, 12,
14, 18, 24, and 36 point). Text in other
point sizes may look rough and may
create problems in positioning the cursor, as you have found. New screen
fonts can be created using DOS's
DEBUG utility. The procedure is as follows.
First, locate a screen font file close to
the type size of the new screen font you
wish to create. For example, to create an
11 point screen font, you might use the
existing 10 point screen. font. Font files
will probably be found in the directory
\ VENTURA unless you have extensively
modified Ventura's default directory
structure.
Screen font files are usually named
IBMETxxI.EGA, where xx is the point
size. The extension will be EGA in most
cases, even if you are using a
monochrome graphics adapter.
Copy the existing screen font file to a
file with the new size in its name. To
create an 11 point screen font you would
copy IBMETI0l.EGA to IBMETllI.EGA.

78

Now use DEBUG to modify the new
file as follows:
DEBUG IBMETl11.EGA
-d

-e 0102
Debug will display .OA-change it to OB
-w

-q

You can use the above procedure to
create as many new screen fonts as you
need for the point sizes which you normally use. Be aware, however, that each
screen font in the system will reduce the
memory available for text and graphics.
And more screen fonts could slow down
the program if the text and graphics
have to be swapped in and out of the
smaller memory space.
I hope this has been of some help and
keep up the good work.
Steven H. Terry
Director, Research Center
Electronic Directions Group
21 East Fourth St.
New York, NY 10003

32 Bit Bugs
Some vendors are shipping machines
which contain an Intel 80386 CPU that is
reliable only with 16-bit software. Last
spring Intel reported a defect in many of
their already manufactured 32-bit 80386
CPUs, The defect affects only 32-bit multiplication. Software which uses 32-bit
multiplication instructions may give incorrect results. However, all software
written for the 16-bit processors will run
flawlessly on the 386 CPUs in question.
Today very little software uses the
386 instruction set, so not many users
will be affected. Anyone who buys a 386
machine expecting to run 386 software

MICRO CORNUCOPIA, #39,]an-Feb 1988
- - - - - _.._ - - - - - - - - - - - - -

on it may want to check their CPU
before the warranty expires. The
restricted chips are marked, "16 BIT
S/W only." An Intel rep told me the
machine vendor should make good on
it. My vendor knew of the problem and
agreed to send a replacement. I wonder
how many won't discover the problem
until 32-bit software hits the market?
Richard Navas
Computer Software Creation
P.O. Box 4305
Bellingham, WA 98227

Low Level Hard Disk Format
A number of folks (ourselves included) have been stymied lately by
rude computer behavior during low
level hard disk formatting. When using
DEBUG to execute the ROM-based formatter on the hard disk controller, the
system goes bye-bye. The OMT! controller, and possibly others, exhibit this unfortunate behavior.
The solution to this problem lies in
the fact that the formatter's code begins
at C800:6 rather than the customary
C800:5. So, if your system hangs when
you enter G=C800:5, try the following:
• Invoke DEBUG
• Enter "G=C800:6"
• If the format program comes up,
you're on your way.
Micro C Staff

•••

ORDERFORM
POSTAGE-PAID SELF-MAILER
Tear out, fold, and staple both ends if check is enclosed.

THE

MICRO

TECHNICAL

JOURNAL

MICRO CORNUCOPIA
..-.----..-__-_---- PC Graphics
,...
.. .......

.

_ _ _ 11 _ _ _ _ _

...............

...

COl1trullll'lKSynchronm.l'

Sl!'noil Chlpl With A

~~~~E~~~ .

.11)nIJ~IJlli

.

DISKS

0 MS DOS 5%" 0 MS DOS 3%"
Other
Specify Disk # and size

o

Save
24% Off
the
newstand
price

OTHER
TOTALS

OTHER PRODUCTS

Back Issues, T-shirts... specify size

D

w
a:
w

GRAND
TOTAL

::I:

a:

.-i1i

D
D

To Place Your Order Immediately

CHECK ENCLOSED

CALL: 1-800-888-8087

u.s. funds drawn on a U.S. bank, please

VISA

D

9-5, M-F, Pacific Time

MASTERCARD

I I I I I-I I I I I-I I I
Are you a current Micro C subscriber?

.

Cl

Yes

1-1.....___.._1I...... I /
Ll

No

Expires

NAME ................................................................................ .
COMPANy ........................................................................... .
ADDRESS ........................................................................... .
39

CITY ..................................... STATE ................ ZIP ............... .
79
-------'=---~.

"---

THE

MICRO

TECHNICAL

JOURNAL

MICRO CORNUCOPIA
IjJ:r_11]3ii33il!jtIJ#IiJ_1iJIJ

JAN./FEB.1988

ISSUE NO. 39

Write in the reader service numbers

NAME _ _ _ _ _ _ _ _ _ _ __

of any advertisers from whom you
would like to receive free information.

COMPANY
ADDRESS __________________
CITY
STATE _ _ _ _ _.....
ZIP_ _ _ __

---------------------------------------- FOLD HERE ------------------------------------~~

111111

NO POSTAGE
NECESSARY
IF MAILED
INTHE
UNITED STATES

BUSINESS REPLY MAIL
FIRST CLASS PERMIT NO. 19 BEND, OR

POSTAGE WILL BE PAID BY ADDRESSEE
THE

MICRO

TECHNICAL

JOURNAL

MICRO CORNUCOPIA
P.o. Box 223
Bend, OR 97709-0223

~----------------------- FOLD HERE ----------------------------------------~~---

C Language Issue
• C Shootout: A Review Of The Newest C Packages
• Turbo C/Turbo Pascal

C~mparison

• Source Level Debugger For Turbo C
• Programming the TMS 34010 Graphics Processor: Tricks And Deceptions
• Programming·With Microsoft Windows
• More Parallel Processing
STAPLE TO CLOSE
80

MICRO CORNUCOPIA

ISSUE 11 (8/81)
Power Supply
RAM Protectlon
Video Wiggle
112 PFM.PRN
16 pages
ISSUE #2 (10/81)
Parallel Print Driver
Drive Motor Control
Shugart Jumpers
~:~~p~rage Above PFM
16 pages
ISSUE #3 (12/81)
4 MHz Mods

~~~iWo:~t~~dem 7

Reverse Video Cursor
FORTHwords Begins
16 pages
ISSUE #4 (2/82)
Keyboard Translation
More 4 MHz Mods
Modems, Lync, and S10s
Undoing CP/M ERASE
Keyboard Encoder
20 pages
ISSUE #5 (4/82)
Word Processing
Two Great SpeUs
Two Text Editors
Double Density Review
Scribble, A Formatter
20 pages
ISSUE #6 (6/82)
BBI EPROM Progr-ammer
Customize Your Chars

~~r~gf~~gR~ate
24 pages
ISSUE #7 (8/82)
6 Reviews Of C
Adding 6K of RAM
Viewing 50 Hz
On Your Own Begins
24 pages
Issue #8 (10/82)

SOLD OUT
ISSUE #9 (12/82)
BBIl EPROM Program
Relocating Your CP/M
Serial Print Driver
Bi~ Board I Fixes
Bnnging Up WordStar
Cheap RAM Disk
32 pages
Issue #10 (2/83)

SOLD OUT
Issue #11 (4/83)

SOLD OUT

ISSUE #12 (6/83)
256K for BBI

~~~~:lf

Up BBII
Look at Wordstar
Double Sided Drives for BBI
Packet Radio
5MHz for Kaypro
40 pages

ISSUE 113 (8/83)
CP/M Disk Directory
More 256K for BBI
Mini Front Panel
Cheal' Fast Modem
Nevaaa COBOL Review
BBI Printer Interface
Kaypro Reverse Video Mod
44 pages

ISSUE 114 (10/83)
BBIl Installation
The Perfect Terminal
Interface to Electronic Typewriter
BBI Video Size
Video Jitter Fix
Slicer Column Begins
Kaypro Color Graphics Review
48 pages

ISSUE #15 (12/83)
Screen Duml' Listing
Fixing Serial Ports

~~Xmt 1:~l~::r~e

ins
Upgrading Kaypro 11 to 4
Upgrading Kaypro 4 to 8
48 pages

ISSUE #16 (2/84)
Xerox 820 Column Restarts
BBI Double Density
BBIl 5"/8" Interface Fix
Kaypro ZCPR Patch
Adding Joystick To Color Graphics
Recovering Text From Memory
52 pages

ISSUE #17 (4/84)

X~dc~~~~izer
Kaypro Morse Code Interface
68000-Based System Review
Inside CP/M 86
56 pages

ISSUE 118 (6/84)
Kaypro EPROM Programmer
lIO Byte: A Primer

~:li~[TrO~!:~1fel Interface

Business COBOL
60 pages

ISSUE #19 (8/84)
Adding Winchester To BBII
6 MHz On The BBI
Bulletin Boards
Track Buffering On Slicer
4 MHz For The 820-1
64 pages

ISSUE #20 (10/84)
HSC 68000 Co-Processor
DynaDisk For The BBII
Serial Printer On BBI Sans 510
Cheap & Dirty Talker For Kaypro
Extended 8" Single Density
72 pages
ISSUE #21 (12/84)
Analo~ To Digital Interface
Installmg Turbo Pascal
Low Intensity BBI Video
Turbo Pascal, The Early Days
80 pages
ISSUE #22 (2/85)

~~~o:d8~~~Ie:a~o~ f:lth~-~TD Bus
Reviews Of 256K RAM Expansion
In The Public Domain Begms
88 pages
ISSUE #23 (4/85)
Automatic Disk Relogging
Interrupt Driven Senal Pnnter
Low Cost EPROM Eraser
Smart Video Controller
Review: MicroSphere RAM Disk
Future Tense Begins
86 pages
ISSUE #24 (6/85)
C'ing Into Turbo Pascal
8" Drives On the Kaypro
48 Lines On a BB!
68000 Versus 8Ox86
Soldering: The First Steps
.88 pages
ISSUE #25 (8/85)
Why I Wrote A Debugger
The 32-Bit Super Chigs
~~fui~Irng The 32 32
RS-232C: The Interface
104 pages

Issue #27 (12/85)

SOLD OUT
ISSUE #28 (2/86)
Pascal Runoff Winners
Rescuing Lost Text From Memory
Introduction To Modula-2
First Look At Amiga
Inside The PC
104 pages
ISSUE #29 (4/86)
Speeding Up Your XT
Importin~ Systems From Taiwan
Prototypmg In C
C Interpreters Reviewed
Benchmarking The PCs
104 pages
ISSUE #30 (6/86)
PROLOG On The PC
Expert Systems
Logic Programming
Building Your Own Logic Analyzer
256 K RAM For Your 83 Kaypro
PC-DOS For Non-Clones
104 pages

ISSUE #31 (8/86)
RAM Resident PC Speedup
Practical Programming In Modula-2
Unblinking The PC's Blinkin' Cursor
Game Theory In PROLOG and C
104 pages
ISSUE #32 (10/86)
Public Domain 32000:
Hardware and Software
Writing A Printer Driver For MS-DOS
Recover A Directory By
Reading & Writing Disk Sectors
96 pages

ISSUE #33 (12/86)
ISSUE #26 (10/85)
Inside ZCPR3
Two Megabytes On 051-32
SOGIV

B's_6~sr~~~~~Eli~i~~main
Graphics In Turbo Pascal
104 pages

C~~~~l~no~;~tper Motors
Introduction To Fractals
The Secrets Of MS-DOS, From
Boots To Device Drivers
Poking About In The System
With Turbo Pascal
96 pages

ISSUE #34 (2/87)
Design~g With The 80386
Build A Simple Oscilloscope
A Cheap 68000 Operating System
A Concurrent Operating System
Recovering Directories And FATs
·96 pages
ISSUE #35 (4/87)
BUilding An 8-channel Temperature
scanner
Designing an Expert System
Teaching Your PC To Beep
Who's Making Great Hard Drives?
Learning Assembly Language
96 pages
ISSUE #36 (6/87)
Build A Midi Interface For Your PC
Designing A Database, Part 2

¥I!~~P;sV?e~~f ft~-DOS Vs 3.X
Digital To Analog Conversion, A
Designer's View
96 pages
ISSUE #37 (9/87)
Desktop Publishing On A PC
Build Your Own Hi-Res Graphics
Scanner For $6.00, Part 1
Designing A Database, Part 3
Controlling AC Power From Your PC
ExpandedMemory On The PC/XT/AT
U~~~k~ible Power Supply For
96 pages
ISSUE #38 (11/87)
Parallel Processing
Laser Printers, Typesetters
And Page Definition Languages
Magic in the Real World
Build a Graphics Scanner
for $6.00, Part 2
Writing a resident program
extractor in C.
96 pages

MS-DOS UTILITIES
This is software we can't do without.
We've written some of the software ourselves, the rest has been carefully
selected from the thousands of public domain and shareware programs in the
Micro C library. We think you'll enjoy these special programs as much as we have.
A vail able in 2 formats:
360K MS-DOS (514") •••••••••••••••••••••••••••••••••••••••• $8.00 each ppd.
720K MS-DOS (31,2") •••••••••••.•••••.••.•••.•.••.•••••••••• $8.00 each ppd.
Micro Cornucopia Subscriber (U.S. only) Special Rate . . . . . . . . . .. $6.00 each ppd.

#MSI
Essential Utilities
This is it-the essential utilities disk for copying, transferring, viewing, squeezing, unsqueezing, finding, and organizing files.
SWEEP allows wildcard tagging and mass file copying, jumps, relogs drives,
and lots more.
LU, LDIR-A complete Novosielski library utility, LU creates a library file of
files.
WHEREIS-This is one of the niftiest 2K programs in the public domain. Lets
you find files in subdirectories. Very handy for keeping-track of those files that try
to get lost.
SQUEEZEIUNSQUEEZE-Complete file squeezing and unsqueezing utlities let
you conserve disk space.
WASH-Forerunner of SWEEP, WASH is a menu-driven file utility that views
files very quickly. It isn't as flexible as SWEEP, but it's faster.
LS-Written in C (includes source), LS is a UNIX-style directory program written by R. Edward Nather.
BACKSCRL-A bi-directional scrolling utility, BACKSCRL buffers screen
scrolling so you can recall with a few simple keystrokes data that's been saved
from the screen. Read BACKSCRL.DOC for a thorough explanation of setup.

#MS2
Cheap Assembler
Disassembler, RAMdisk
CHASM-Written by David Whitman, CHASM is a subset of MASM and fits into 64K. It's good for writing short subroutines to call from BASIC, or for just learning 8088 assembly-language.
It allows you to define labels, but doesn't support macros.
ASMGEN-A disassembler written by J. Gerbach and J. Damke, ASMGEN will
generate 8086, 87, or 88 code. It's MASM-compatible, and output can be directed to
the console or to a disk file. Handles up to 64K files. Includes a long doc file.
MEMBRAIN-Creates a file named 'MEMBRAIN.SYS', a DOS device driver for a
RAM disk drive.
FSPOOL-This neat little program redirects output to a diskfile. Very handy for
creating a file from DEBUG.
UNWS-A menu-driven BIT7 of the DOS world. Resets bit 7 (which has been set
high in some characters in WORDSTAR), turning your WORDSTAR doc files into
standard ASOI files.
DEBUG.DOC-A file of tips on using DEBUG. Good for the beginner.
".ASM-These source files for SDIR, RAMDISK,. -and UNWS will
really help you get your feet wet in assembly language
programming. Or if you already know the. ropes, you
can improve these programs.

#MSS
Util, ST, PC-WINDOW, Z
Z.EXB-Move about hard disk directories.
PROTEcr-Make sure that your .exe and .com files-cannot
be erased by the erase command.
UTIL-moves files between subdirectories, sorts directories,
redefines the keyboard, lets you type directly to your printer, pipes
.
output, and lots more.
PCWINDOW-A semi-sidekick, PCWINDOW combines notepads,
multiple timers, ASOI reference code and other features.
DOSEDIT-A simple editor for DOS commands.

-

...

-.. ".

------~---

#MS25
Ultra Utilities

#MS37
Disk Utilities

The three Ultra Utilities programs will allow you to map disks, unerase
files, format non-standard disk, interrogate sectors, and much, much more.
This is a very useful set of utilities (a poor man's NORTON). Many
hours of work and frustration can be avoided by learning them, so have
at it.

We think this disk will satisfy at least some of your curiosity about
MS-DOS systems programming. We've included lots of assembler
source code, so dig in.
SCAV finds and marks bad blocks on both floppies and hard disks.
WHEREIS finds files anywhere within a directory structure.
DIAGS-Special serial, parallel, and video diagnostics for the Pc.
Use this excellent program to explore your system.
ASYNC-Loadable asynchronous device driver for MS-DOS.
LPTX intercepts BIOS interrupt 17, the line printer interrupt. It
redirects the output of LPTl, LPT2, or LPT3 to a disk file. All three may
be active at the same time.
DOS1, ROLLDOS1 & 2, DRIVER & DRIVER1-Stop wondering how
device drivers really work and explore these tutorials. Good examples
of character device drivers aqd de-bugging techniques.
STUFIT stuffs your least used files into the inner tracks of the disk.
This frees the outer tracks for work space and speeds access times
considerably.

COVER prints out directories in compressed format to be pasted on
floppies.
CRC67-Finally, an MS-DOS cyclic redundancy checker (CRq that
works (Fast!). Checks CRC values for files against a previously
recorded list of CRC's.
DISKORAY checks floppy rotation speed and allows stepping of the
••.!ad.
DISKPARK parks the heads of all hard disks in your system using
the innermost track.
DISKWIPE-Be careful. This completely erases a disk, including the
formatting.
FDATE allows editing of the time and date stamp on DOS files.
FILES-A very complete directory program.
MOVE2-Intelligent COPY routine.
REFRESH rerecords data on a disk. It does 12 retries on reads and 2
on writes so it may be able to recover those "bad" sectors.
SDIR-Version 5.0 of the super directory program.
SST-Just what every busy hard disk needs. SST reorganizes files
into contiguous sectors on the disk. This really speeds up disk accesses.
TIMEPARK parks the heads on a running hard disk after a user
specified amount of time without accesses.
WD·. ·-Everything you always wanted to know about Western
Digital's WD1002S-WX2 hard disk controller. Also information on
optimizing its performance with the Seagate ST225 drive.
WHEREII searches for one or more files through all the directories
on a specified drive. Supports wild-cards:

#MS36
General Utilities

#MS39
Modula-2 Compiler

BATMAKER helps create .BAT files. Perfect when using FIND on all
.TXT files, for instance. Very handy.
BWVID lets you see what is happening on the screen when you have
a color graphics card (CGA) and a monochrome monitor.
CED is called a Command line EDitor but it's far, far more than that.
Includes macro definitions, control of DEBUG, repeating and editing of
previous commands, etc.
. .
DEBUG. DOC is a simple but very handy qUick reference gUide to
DEBUG.
EXPAND and SHRINK are detab and entab utilities.
PC-STAT-Reports system information-memory available, drive
status, etc.
PC-TEST is similar to Norton's speed test, but its test takes longer
and it doesn't report such wildly optimistic speed figures.
POPALARM is really neat. It's a memory resident alarm clock that
reminds you to do what you'd otherwise prefer to forget.
RECALL remembers the last 50 DOS commands. Commands may be
edited and/or reexecuted.
REMIND-This is a daily black-book that stores its data on disk.
SCR·.·-Utilities for creating batch files which incorporate screen
images. This is a great extension to MS-DOS batch capabilities.
FILTERS-The remaining files are classics from the Software Tools.
book. One of the real attractions of these filters is that they come with
assembly language source.

This disk contains an excellent shareware implementation of
Modula-2 from Fitted Software Tools. It sports an integrated editor,
linker, and make utility. Requires 5121< of RAM.

#MS27
System Primer

#MS40
More Utilities
BOOTDUMP-Gives information on the currently logged drivesector size, sectors/track, of heads, etc.
BOX-Boxes text displayed in a batch file. Includes C source.
KBBUFF-Extends type ahead buffer by 160 characters.
KOLOR-Sets foreground, background, and border colors from the
DOS prompt.
LURUN-Executes programs within an LBR format library file.
NJRAMD1~Sets up RAMdisk in EMS or EEMS memory.
OV14~Overview is a great file manipulation program. Somewhat
like XTREE but much faster since it doesn't read in the entire directory
structure unless necessary. Includes source.
REBEEP-Beeps until a key is pressed. Quite useful for batch files.
SIMCGA-Excellent utility which allows CGA programs to run on
Hercules systems.
WAITN-Use in batch files to pause a specified amount of time.

'*

For Technical Help:
(503) 382-8048 (9 a.m.-noon, PST, M-F).

Order today from:
MICRO CORNUCOPIA

I.·.~· ;1 P.Op:~~:-!!d:!~~:OO?;:~~~::709 [EBl

mou
oml!l
omm

,

Dots, Lines, And Fills:
Programming The EGA

TIDBITS,
By Gary EnJsminger
1912 Haussler Dr.
Davis, CA 95616

Gary's been wishing for EGA graphics ever since
he got his X16. Now that he's got it, what can he do
with it? Use it, what else? Herein you'll find out
how he writes EGA graphics routines.

lthough the EGA (enhanced graphics
adapter) has been coloring the monitors
of some PC users for over three years
now, I've just gotten 'round to learning
how to use it. For those of you coming into the
game late, the EGA is a sweet step up from
CGA, with most of the Hercules adapter's
resolution. In enhanced mode (16), its resolution is 640 by 350 pixels, 64 colors, 8 by 14 cells
(or characters), and 256K RAM which will support up to 8 graphic pages).

A

Figure 1 - Modes
1!c:A

'lzt/

Mod.

Qr~h

0
1
2
3

'l
'l
'l
'l

4, 5

Q
Q

Adapter

e
I:

e

I:

e,l!

e,l:

6
7
13

'l

II

Q

14

Q

e,l:
e,l:

15
16

Q
Q

II
I:

Color.
16
16/64
16
16/64
4
2
4
16
16
4
16/64

a...olution
320
320
640
640
320
640
720
320
640
640
640

By
By
By
By
By
By
By
By
By
By
By

200
350
200
350
200
200
350
200
200
350
350

The colors are fine, the text is fine-but
cheap, the EGA system isn't. Mine (Daetech
adapter and TVM color monitor) ran about
$560 at McTek, the best price I could find in the
Bay Area. (But I expect you folks traveling even
further west could make a better deal.)
Not The First Thing, But. ..
Not first, but early on, I decided to learn
how to program the adapter. I've been itching
to add some colorful bells and whistles to my
programs for ages, so I began to delve.
.The first problem (as usual) was lack of information. The Daetech manual is a surprising-

84

MICRO CORNUCOPIA, #39, Jan-Feb 1988

ly interesting 80 pages of details, but a tutorial
it isn't. It references the IBM Personal Computer Seminar Proceedings, the EGA Chip Set
Data Sheet, and a BYTE article from 1985 written by FORTHer Richard Wilson.
The Wilson article, "Programming the Enhanced Graphics Adapter," is excellent, and
filled with gems like, "Unfortunately, programming the EGA is not a trivial task. The
hardware has a complex, sophisticated, and
somewhat idiosyncratic architecture, but it is
rarely obvious from the technical documentation just what all that complex hardware does."
Naturally, Wilson had me interested, and
got me as far as reading and writing a pixel in
assembly language. Not bad, but I wanted
something a little gentler.
So I headed to the UC library, the Walden
bookstore, and a few of my other favorite hangouts to rustle up a little more presentable information.
From these outlets and Osbourne/McGrawHill publishing, I netted several good sources,
including Advanced Turbo C, by Herbert Schildt,
and Advanced Graphics in C, by Nelson Johnson.
"Advanced" anything that I can read is flattering.
Modes, Masks, And Programming
In order to make sense of this discussion,
you need to know at least a little about modes,
colors (that's easy), addresses, registers, interrupts, lines, ports, masks, pointers, offsets, and
pixels.
Modes are built into PC-DOS in 16 flavors
(see Figure 1). A few CGA and Monochrome
modes work only with those respective adapters; but the EGA, in general, can emulate most
CGA and monochrome adapters in "their"
modes, making it an all-purpose adapter.
You can use the PC-DOS MODE command
to change some modes, but not the ones created
especially for the EGA. To change those you'll
need a programming language equipped for
the low levels. I used C, changing the mode by
calling BIOS interrupt 10 hex (it's intended for
this and similar video purposes). Set the AH &

AL registers and call it:
void set_mode
int mode;

Figure 2 - Times
MOde Bcreen Bl.e
14
16

640 By 200
640 By 350

rlll 1/2
Screen
47 .ea.
80 .ea.

DIRECT 14
DIRJ:CT 16

640 By 200
640 By 350

15 .ea.
25 .ea.

(mode)

BIOS
BIOS

union REGS r;
r.h.al = mode;
r.h.ah = 0;
int86 (OxlO, &r,

Sy.t.m -- 80186-ba.ed iC (0 KHs)
&r);

Once we've set the mode, we can
draw by turning pixels on and off. A
point is a pixel (actually the nearest
pixel to the coordinates of the point)
turned on. A line consists of points. A
box consists of lines. A bar is a filled
box.
We can tell the EGA"which pixels to
turn on and off by calling the BIOS or by
talking to the EGA directly. The first
method is easier; the second is more efficient.
In the first, we write a function much
like the one we just wrote (above). Once
again we call interrupt 10 hex (using the
C system function int86) after setting
register values:
void bios_dot(x,y,color)
int x, y, color;
union REGS r;
r.h.ah
12;
color;
r.h.al
y;
r.x.dx
r.x.cx
x;
int86 (OxlO, &r, &r);

And that simply is all the low-level
details you have to know-call the BIOS
to set the mode; call the BIOS to write
the pixels. Every other drawing algorithm (including the ones that plot for
days those elegant fractals) depends on
dots (or points or pixels).
Which brings up a point. How fast is
a function which calls the BIOS? In this
case-not very. Whatever it takes at the
system's level to save us the trouble of
handling a task directly, takes time.
When we use the BIOS we gain
simplicity (or even capability) and lose
efficiency. (If you want to skip ahead to
the results-Figure 2-you can see just
how the trade works.)
A more efficient method of drawing
points bypasses the BIOS and calls the
EGA directl y by sending a function
number
to
the
EGA's
INDEX
REGISTER, which is a port.
The EGA's display buffer begins at
address AOOOOOOOL. Specific memory

locations are offsets from this address.
(For those of you who can relate to the
CGA or Hercules adapters-the eGA's
display buffer can be found at B8000000,
and the Hercules at BOOOOOOO.
The display resolution can vary (see
Figure 1) up to a maximum of 640 by
350 pixels. We address video memory,
though, in bytes. See the base equation
in Figure 3 to write a point directly to
EGA memory.
The EGA display buffer corresponds
to a page, or screen. The display buffer

Figure 3 - Write a Point to Memory

'define TRtJZ -1
'define EHABLE o%Or
'define lJU)ZXR.EG Ox.3CZ
'define VAL1UtQ Ox3cr
Idefine OOTINDEX (index, vzal)
(outp(INDJCCRZQ, lndox);\
outp (VALR.J:Q, val);)
'define EGA BASE O%AOOOOOOOL
'define WXDTB 80L
'define XHAX 63g
'define ~ 34g
1* for mode 16; 199 for mode 14 *1
'define XMIH 0
'define 'XMIN 0
'define XORIT 0%80

(

un.igned char ma.k - 0%80,
exi.t color;
char far *ba.e;
if

(%

<

II y <

XMlH
YKIH

II

%

>

II y >

return;

ba.e - (char far *) (EGA BASE +
«lonq)y * WIDTH + «long)x 1
8L») ;
ma.k

»-

x , 8;

void line (.tart_%, atartJ,
end_x, eOOJ, color)
int atart_x, .tartJ, end_x,
endJ, oolor;
(

int
int
int
int

t, di.tanoe;
%err - 0, yerr - 0,
delta_x, deltaJ;
incx, incy;

delta x - end x - atart %;
Get the-change In X *1
de1taJ - endJ - atart..,)";
Change ln y *1

1*
1*

if (delta x > 0) incx - 1; 1*
If a chanqe; ina or *1
ebe if (delta % - 0) incx0; 1* decrement i. *1
el.e incx - -1;
if (deltaJ > 0) incy - 1; 1*
Same for y *1
el.e if (delta..,)" - 0) incy - 0;
el.e !nay - -1;
delta x - ab.(delta x);
1*
or Y Changing faat.r? *1
deltaJ - aba(deltaJ);
if (delta_x > deltaJ) di.tance
- delta x;
el.e di.tana. - deltaJ;

X

X!mX
DIU)

Lines And Such
The code in Figure 4 is a version of
Bresenham's integer-based algorithm for
drawing lines. I think the code (adapted
from Advanced Turbo C) is self-ex-

Figure 4 - Line Using Mem Writes

'inalude <.tdio.h>
linalude 

point mem(%, y, color, orxor)
int X;y, color,orxor;

stores values for the screen beginning at
the upper left-hand corner, the point
(0,0). A byte offset is equal to the
HEIGHT (the y coordinate) times the
WIDTH of the screen plus the xcoordinate divided by 8 (bits). Base is a far
pointer to this location.
We set and reset the INDEXREG and
VAL REG registers with the macro OUTINDEX. The code in Figure 3, adapted
from Advallced Graphics in C, will draw
points very quickly in modes 14 and 16.
A little more modification (moving the
reset out of the function and into
main()) will speed it up considerably if
you're drawing and filling complex
shapes and such.

for (t - 0; t <- di.tance

t++) (

+ 1;

mem~int(atart_x,atart..,)",color,O%l

OO'.rINDI!X(O, color);
OOTINDZX(l,EHABLZ);
OOTINDZX(8,ma.k);
OOTIHDZX(S,0%l8);

8); 1* ilot point. *1

%err +- delta %;
yerr +- delt'aJ;
if (%err > d1.tanoe)
%err -- di.tance;
.tart % +- 1ncx;

}

OOUNDZX (0, 0);
OOUNDZX (1, 0);
OOTINDZX(8,TaOE);
OOUNDZX (3, 0);

-

1f (yerr > d1.tance)
yerr -- di.tance;
lItartJ +- incy;
}

)

MICRO CORNUCOPIA, #39, Jan-Feb 1988

85

Figure 5 - Draw Line Using BIOS
void bioa_line (Kart_x, atart..,.,
end_x, end..,., color)
int atart_x, KartJ, end_x, endJ,
color;
(

1* regi.ter *1 int t, diKanoe;
lnt xerr - 0, yerr - 0, delta_x,
delta..,.;
int inez, iney;
delta x - end x - atart x;
deltaJ - endJ - atartJ;
if (delta x > 0) inez - 1;
e1&e if ('d.l.ta x - 0) inez - 0;
elae inez - -1;

plana tory, but you can delve deeper into
Bresenham's method by perusing either
of these fine books.
Figure 5 brings Tidbits toward a conclusion by using points and lines to fill
boxes. The only difference between the
two fill functions is how they draw dots
(indirectly via the BIOS or straight to the
adapter). Fills take time, of course, even
. on ATs and the like, and gave me a
chance to test the functions.
Out Of Here
Figure 6 is the main testing function.
I filled BIOS boxes and direct write

iE (deltaJ > 0) inay - 1;
e1&e iE (delta..,. - 0) iney - 0;
elae inay - -1;

•••

Figure 6 - Main Test

delta x - aba(delta x);
delta:Y - aba(deltaJ);
if (delta_x > delta..,.) diKanae delta x;
elae diKaDce - de~taJ;
for (t - 0; t <- diatance
t++) (

boxes in modes 14 (640 by 200) and 16
(640 by 350). The results, as I said, are in
Figure 2.
In sum (on my system), direct writes
to the EGA display buffer (bypassing
the BIOS) are a little better than three
times faster than· BIOS writes. The 640
by 200 display (which isn't quite as
fancy) fills up a little less than twice as
fast as the 640 by 350. The slow-mo
BIOS was a lot more noticeable.
I'm out there, it's 4 a.m., and that's
Tidbits.

main ()
{ int x,y;

+ 1;

bioa_dot(Kart_x,KartJ,color);
xerr +- delta x;
yerr +- delta:Y;
iE .(xerr > diKance)
xerr -- diKance;
atartx +- inez;
)

iE (yerr > diKance)
yerr -- diKance;
atarty +- inay;
)

1* I'ILL bozea *1
void Eill_boz (atart_x, atart..,.,
end_x, endJ, color)
int atart_x, atart..,.,
end_x, end..,., color;

)

aet mode (14);
1* or 16 *1
printf ("ndbita 39 teK - hit any key to Kart");
getch() ;
for (x - 0; x < X!aX; ++x)
bioa dot(x,100,3);
1* to croa. the acreen *1
for(y - 0; y < 'DmX; ++y)
bio. dot(320,y,4);
1*
*1
getch() ;for (x - 0; x < »lAX; ++x)
mem-POint(x,105,7);
for (y - 0; y < 'DmX; ++y)
mem-POint(325,y,9);
getch() ;
printf("lItart") ;
fill boz(0,0,649,99,4);
printf (" atop") ;
qetch() ;
printf("Kart") ;
bioa fill(0,100,649,199,3);
printf (" atop") ;
getch() ;aet mode (3) ;
1* rea.t text mod. *1

(

1* regiKer *1 int i,begin,end;
begin - atart x < end x ? atart x
end x;
end - atart-x> end x ? atart z
end_x;
Eor(i-begin; i<_nd; i++)
line(i, KartJ, i,endJ, color);

1* nLL uaing the BIOS *1
void bioa_fill (Kart_X, at art..,.,
end_x, end..,., color)
int atart_x, atart..,.,
end_x,endJ,color;
(

1* regiKer *1 int i, begin, end;
begin - atart x < end x ? .tart x
end_x;
end - atart x > end z ? atart z
end_x;
Eor(i-begin; i<_nd; 1++)
bioa_line(i,KartJ,i,endJ,eolor);

86

See Micro C
At The West Coast
Computer Faire
We'll Enjoy Seeing You
Come and meet some of the Micro C crew at the West Coast Computer Faire,
April 7 -10. We'll have magazines, T-shirts, and ads for sale. Plus we'll be glad to
talk about article ideas or anything else. Our booth is (tentatively) #951.

MICRO CORNUCOPIA, #39, Jan-Feb 1988

You're Looking At
The Best
Advertising
Bargain In The
Industry I~
1111 ' -___

When You Advertise In Micro
C You Get:
• A knowledgable audience. Advertisers say they can tell
immediately when they get an order from a Micro C
reader. Our readers are better informed than the readers of
any other publication, including Byte.
• An audience that misses nothing. No matter what size
ad you pick, your message won't get lost in Micro C.
Over 90% read every word and every ad in every issue.
• An active audience. Many advertisers report more sales
from their Micro C ad than from their ad in any other
magazine, regardless of price, regardless of audience size.

• The lowest cost per thousand readers of any journal.
Compare our rates with Byte, Dr Dobbs, Computer
Language... with any other magazine. Then compare total
readership. Micro C is the one place where you can do
serious advertising on a budget.
For rates and deadlines, and other fun particulars,
call Laura Logan at:

503-382-8048

Micro C - Serious
Advertising On A Budget

The "thoughtful" alternative
from SemiDisk.
Designed around the 64180 microprocessor,
the DT-42 is loaded with more of all the features
you need: More speed, more memory, more
ports and more TPA!
How did we fit all these features on one 5.75"
by 8" single-board computer?
• 9.216MHz 64180 Microprocessor (runs Z80 programs)
• 512K DRAM, Zero wait states, fully populated.
• Three RS232C serial ports (Standard baud rates to 38,400)
• One Centronics parallel printer port
• WD2793 disk controller (up to 8 drives, SD, DD or High
Density, 3%", 5%", and 8" drives)
• SASI channel for hard disk controller (software provided)
• Many popular disk formats supported
• Requires only +5V @ 1 amp.
• ZRDOS/ZCPR3 with exclusive "Hyperspace" operating
system, offering 57.5K TPA (NOT 48K like some others. No
8 bit is bigger!!) Richard Conn's ZCPR3, The Manual
included free!
• Provisions for real-time clock and on-board terminal options.
• Socket for 28-pin EPROM.

Compare! You won't settle for less.
Or slower. Or smaller.
DT-42 Computer
TMP (on-board terminal)
SmartWatch
Z-system software
ZAS & Debuggers
8MB disk emulator wi SCSI
Battery backup for above

$
$
$
$
$
$
$

499
100
50
50
25
2049
150

Call or write for more
information or to place an order.
..

THE MICRO TECHNICAL JOURNAL

Micro Cornucopia

'

'

,

.

SemiDisk
11080 SW Allen Blvd., Beaverton, OR 97005

(503) 626-3104
Reader Service Number 18
MICRO CORNUCOPIA, #39, Jan-Feb 1988

87

CALL FOR FREE CATALOG

AROUND THE BEND

ffI

TEXT TO SPEECH BOARD!

(Continued from page 2)

::>

PC/XT COMPATIBLE. MAKE YOUR COMPUTER TALK!

~~------------------------------------------------~

~

W

A VERY POWERFUL AND AMAZING SPEECH CARD. USES THE NEW GENERAL
INSTRUMENTS SP0256-AL2 SPEECH CHIP AND THE CTS256A·AL2 TEXT TO SPEECH
CONVERTER.
THIS BOARD USES ONE SLOT ON THE
MOTHERBOARD AND REQUIRES A COM
SERIAL PORT. BOARD MAY ALSO BE USED IN A
STAND ALONE ENVIRONMENT WITH ALMOST
ANY COMPUTER THAT HAS A RS232 SERIAL
PORT. FEATURES ON BOARD AUDIO AMP OR
MAY BE USED WITH EXTERNAL AMPS.
DEMONSTRATION SOFTWARE AND A LIBRARY

~

TION AND SCHEMATICS ARE ALSO INCLUDED.

a:

Z

o

c..
::>
>
c..

o

U

~ ~NUd~D~~%R~?S~~~-r'E~EFI~.lL'tfo~U~~:T~~
~

~

NEW!

a:

~~\C~

$69 95

C\l~\

ASSEMBLED
& TESTED

a:~. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .~

ct

NEW! IC TESTERI $149.00

c

SIMILAR TO BELOW EPROM PROGRAMMER. PLUGS IN TO YOUR PC OR XT. TESTS

::

~CS~~~~~LE~~~~:(N~J's~~'ci~l~loXs~~~~~sc~g~~ft.~JJ::J'I~~~~g~rf~~~·~~~~ I

W

~

DETERMINE PART NUMBERS OFMOST UNMARKED AND HOUSE NUMBERED DEVICES
WITH SIMPLE MOD. THIS UNIT CAN ALSO TEST6.4K AND 256K DRAMS! WITH MANUAL
AND SOFTWARE: $149. PERFECT FOR SCHOOLS.

i

::::i

~~------------------------------------------~
o
PC/XT EPROM

c

en
a:

::>

PROGRAMMER

u.

$169

o
o

C/)

*

ASK ABOUT
OUR NEW
PAL
PROGRAMMERI

*

*

LATEST DESIGN PROGRAMS UP TO 4 DEVICES AT ONE TIME FEATURES EASY
TO USE MENU DRIVEN SOFTWARE THAT RUNS UNDER PC OR MS·DOS. * USES AN
INTELLIGENT PROGRAMMING ALGORITHM FOR SUPER FAST (8X) EPROM
BURNING. * THIS PLUG·IN BOARD ATTACHES TO AN EXTERNAL MINI CHASSIS
CONTAINING 4 TEXTOOL Z.I.F. SOCKETS.
NO PERSONALITY MODULES
REQUIRED AUTOMATIC VPP SELECTION: 12.5V, 21V, OR 25V. EPROM DATA CAN
ALSO BE LOADED FROM OR SAVED TO A DISKETTE. PROGRAMMING SOFTWARE
SUPPORTS: 2716,2732, 2732A. 2764. 2764A. 27128. 27128A, 27256. 27256A, 27512. AND
~~~A~lSSEMBLED AND TESTED. BURNED. IN WITH MANUAL. $169 WITH

::!:

a:
W

~

W

*

*

J:
~

o

~
~

~

*

*

JUST RECEIVED. SAME AS ABOVE PROGRAMMER, BUT PROGRAMS 8 UNITS AT ONE
TIME· $299.

..,

m~------------------------------------------~
Digital Research Computers

::>
C/)

C/)

W

-'

P.O. BOX 381450 • DUNCANVILLE, TX 75138 • (214) 225-2309

ct
~ I-=TE==R=-=M"::S:-:"':"A-=-dd7""$==3:-::.00:=-"po-s7ta-ge-.7.W:":"'"e-p-ay--=-ba-=-la-n-ce-.-=O"'rd:-er-s-u-nd7""e-r$::-::1~5-a-=-dd~7==5~¢-=-ha-n-=d::-Un-g....N~o--l
-'

'C.O.D. We accept Visa and MasterCard. Texas Res. add 6-1/4% Tax. Foreign orders
(except Canada) add 20"10 P & H. Orders over $50 add 85¢ for Insurance.

ct

Reader Service Number 32

XEROX 020-1 AND 020-2 ITEMS
Reconditioned, Assembled and Tested
820-1 8" COMPUTER SySTEM . . . . . . . . . . . . . . . . . . . . . . $330.00
5 1/4" COMPUTER SYSTEM . . . . . . . . . . . . . . . . . . . . . $350.00
820-2 8" COMPUTER SYSTEM . . . . . . . . . . . . . . . . . . . . . . $395.00
5 1/4" COMPUTER SYSTEM. ............ .......
5.00
820-1 COMPUTER MONITOR (COMPLETE).....
..$125.00
820-2 COMPUTER MONITOR (COMPLETE
,qON. LLER)$195.00
820 COMPUTER MONITOR (NO MAI,
,I'~......... $ 85.00
45.00
820-1 MAIN CO

TARO . . . . . . . . . . . . . . . . . . . . . $ 50.00
20.00
70.00
30.00
820·~FLOPPY CONTROLLER BOARD ................. $ 95.00

FULLY~P"
BOARDS, AS IS (NEED REPAIR)$
820-2~~
C PUTER BOARD . . . . . . . . . . . . . . . . . . . . . $
~nlYY P PULATED BOARDS, AS IS (NEED REPAIR)$

DUAL 8" SSDD DISK DRIVES/ENCLOSURE (COMPLETE).$175.00
DUAL 8" DISK DRIVE CABINET (NO DRIVES) ........ $ 75.00
5 1/4" DUAL DISK DRIVE CABLE .................. $ 20.00
8" DUAL DISK DRIVE CABLE . . . . . . . . . . . . . . . . . . . . . . $ 35.00
RS-232 CABLES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $ 10.(10
LINE CORDS .•..•...•.•... ea.$3.00
zao·s 6MHz •.•....•...... ea.$3.00
ZaO'H aMHz •...........•. ea.$9.50
5 1/4" DSDD DISKETTES .•• ea.$ .60
a" SSSD DISKETTES ....... ea.$1.25
DC300A DATA CART .. USED ... 2/$5.00

E2I COMPUTER PRODUCTS
2273 AMERICAN AVE. D8
HAYWARD, CA
94545
(415) 786-9203

TERMS: Pre·payment, COD, Visa/Mastercard. California residents add sales
tax. Orders are FOB Hayward, CA .• Shipments by UPS Ground unless
otherwise requested. Prices and availability are subject to change
wi thout notice. All products are assembled and tested and have a 30 day
warranty unless otherwise stated. Call or write for curr~nt product and
price listing.
Xerox is a trademark of Xerox Corporatlon. CP/M is a
trademark of Diqital Research.

Reader Service Number 33

88

MICRO CORNUCOPIA, #39, Jan-Feb 1988

this data communications program automatically routes calls
via free phone lines into the most interesting systems in
government and industry. If the intrusion is discovered, the
program identifies itself as a CIA operative, leaves George
Bush's home number, and signs off. An especially good gift for
someone doing time.
(3) The Disputer. This computer was designed by VAl (Very
Artificially Intelligent) Corporation. The system takes the opposing side of any argument. If two sides are already taken,
the system creates a third. The latest model is powerful enough
to destroy any and all opposing ideas, especially new ones.
After producing the first working model, the company has
been unable to decide how to manufacture it.
On The Desktop Front
Local Apple dealers are insisting that Macs are the only
way to do desktop publishing. They have some interesting
sales points:
• IBMs are too hard to use. (Hey, these guys should know,
they were selling heavy iron until a local used car lot
folded. But they have a point and will continue to have
one until OS/2 or some other windows environment
catches on. Plus, the salesmen aren't interested in learning DIR and COPY.)
• Apple has better desktop software. (Not true, Ventura
Publisher and PC Pagemaker are certainly equal to, if not
ahead of, anything available for the Mac. But, the
Apple's DP stuff is very good and getting better.)
Mac has more powerful packages for creating, scanning,
editing, type, and graphics. (That's true and will probably continue to be true-at least until Adobe comes out
with a PC version of Illustrator.)
See the Desktop Graphics article in this issue for a look at
how we're dealing with graphics at Micro C.
Micro C's Seventh Annual Technical Forum
If you're tired of the same old technical forums with their
high prices, crushing traffic, crime, and three-piece-suits, then
plan to be in Bend July 14 through 16 for SOG VII. (Our
Seventh Annual Semi-Official Get-together.)
As usual, we'll have white water rafting (Thursday) followed by two days of technical talks at Central Oregon Community College. No dorms this year, they'll be closed for
remodeling, but we'll be glad to send you information on
motels and camping.
Want to speak? Call, write, or log onto the Micro C RBBS
(503-382-7643). Include a short outline and a two or three
paragraph description of your subject, your name, address,
day and evening phone. Special things await speakers (T-shirt,
afternoon raft trip ... ).
Many SOG VI attendees said they got more real information
than they received at any of the high-priced ($300+) conferences. Ask someone who's attended. They'll tell you.
Looking For Groups
Are you a member of a computer group whose members
should know about Micro C? Send us the name of the group
along with the name, address, and phone number of the
librarian or president and an estimate of the number of attendees. We'll send the group some copies of Micro C for their
library along with some subscription forms and posters to pass
out.

?'::w~::>:<<<' ..«.:~:.~::~~.~.:::::.:.'<:::.~:(.:::~::~>:<~.,<::~:..::(.: "'<::<:~:::~:'::':::>:<:(.:'::::"::'

And, for your help, we'll gladly send you any Micro C user
disk. Free. Along with our thanks.
Sinclair QL
I've received four letters after my request for QL feedback.
One of the letters contained two issues of the "Detroit Area
Times/Sinclair News" (DATSN). The newsletter covered:
vanishing newsletters, shrinking user groups, and disappearing
commercial outlets. It was a requiem mass quite familiar to
CP/M users.
DATSN reprinted a letter written to the Vancouver Sinclair
Users Group (hey, when letters get that hard to come by ... ).
"This man (Clive Sinclair) took the most sophisticated
microprocessor (68008) and completely ruined it by putting it
.in a QL. The only machine in the world that uses not hard
drives, not floppies, but mini 8-tracks. The display is weird, the
keyboard is weird, and the operating system is weird."
(Meanwhile, I understand that Quantum is closing out its
stock of QLs at $99 each. If nothing else, they're cheap. Awfully
cheap.)
The Active Core
Most systems are fortunate enough to have two types of
users. The first type is a hacker, innovator, fanatic. These are
the people who grabbed the first Apple lIs, the S-100 systems,
the Big Boards, even the early PCs.
They upgrade hardware, write utilities, and poke about in
the operating system. These are also the people who start users
groups, write newsletters, teach classes, run bulletin boards,
and put together software libraries. They are the founders and
officers, volunteers and instructors who make up the hearts of
local groups.
The second user is the appliance operator. He, too, owns an
Apple, an S-100 system, a Big Board (in the form of a Kaypro
or Xerox), or a PC: but he's a consumer, not a mover. He'll pay
the dues, take the classes, log onto the bulletin board, and attend the meetings. Occasionally, he'll even buy the doughnuts.
If a system is to become a financial success, the appliance
operators will have to outnumber the shakers 100 to 1. The
operators purchase most of the hardware, and add-ons, and
software. They're the ones who make manufacturers happy.
As a system matures, however, the shakers get itchy. Their
interests turn to new systems: just as they were once interested
in Apple lIs and Big Boards, they continue to be interested in
new systems.
The user group leaders, who spread the word, teach the
floundering, chair the meetings, and repair the systems, begin
moving on. Holes show up in the officer corps. For a while,
there will be new shakers to step in, but not forever.
Sure, there are names on the rolls, lots of names, but the organization has lost its heart. Eventually, attendance begins to
decline and the topic of discussion shifts from exploring an exciting new system to survival of the group.
If it's going to survive, it will have to change its focus: either
tackle an exciting new system, or become a food SIG. Either
way is food for thought.
On The Same Note
Morrow Owners Review (MOR), the bimonthly Morrow
magazine, is calling it quits. They're busy notifying all readers
that the December issue will be the last.
MOR had 4,000 readers in June, 1987. By September, the
subscriber base had dropped to 2,400. Meanwhile, the Morrow

1Tfu~

." ,'.'.

<:~«.:..,.,:.< .,":(.":':~"

.•.·

Navigation menu