Megalextoria
Retro computing and gaming, sci-fi books, tv and movies and other geeky stuff.

Home » Archive » net.micro.atari » structured assembler
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
structured assembler [message #282757] Thu, 16 January 1986 21:16 Go to next message
mykes is currently offline  mykes
Messages: 45
Registered: January 1986
Karma: 0
Member
Article-I.D.: 3comvax.350
Posted: Thu Jan 16 21:16:34 1986
Date-Received: Sun, 19-Jan-86 04:38:42 EST
Distribution: net
Organization: 3Com Corp; Mountain View, CA
Lines: 131
Xref: watmath net.micro.atari:2439 net.micro.cbm:1953 net.lang:2052 net.micro.amiga:1604

I would like to tell you folks about a couple of assembler/compilers
I wrote for a real nice structured programming language for the 6502.  
First, however, a little background.

I am a video game programmer with several years experience.  I also was
probably the 2nd person to use the Lattice 'C' compiler almost 10 years
ago (it wasn't for the 8086/88 family yet), so I have a bit of 'C' 
programming experience.  I have noticed a real absurd notion among some 
people that video game programmers are not "real" engineers, but I think
they are the cream of the crop.

In the last 3 years, I have written over 300K of 6502 code alone, not
even including 6809, Z80, 8086, and 68000 code I had to write.  On each
of these machines (ColecoVision, IBM PC, Commodore 64, Atari 800, Atari
VCS, etc.), a good program had to squeeze every cpu cycle, byte of RAM,
and byte of ROM out of every program.  Some of the machines were quite
crude; the VCS had 128 bytes of RAM and 4K of ROM; the ColecoVision had
maybe 4K of RAM and 16K of ROM, etc.  Some of the machines were actually
reasonable computers (C64, Atari 800) with lots of Ram and disk drives.

I think 'C' is a very good language for the average engineer (most of us
are average by definition), but is unusable for any application where
speed and code size are real critical.  I admit you can hand optimize, 
etc., 'C' programs to make them better, but such a program could never
be as fast or as small as a well written Assembler language program.  
'C' has its advantages, though, which every video game programmer would
like to take advantage of (speed of development, portability, etc.).

This brings me to BASM.  BASM is a compiler/assembler I bought for the
C64, when I was looking for development tools.  BASM was advertised as
a Basic Compiler, and the source strongly resembled BASIC.  However,
upon careful examination, I found that what BASM really is is a RATFOR
for 6502 assembler language (instead of fortran).  The idea intrigued
me, and I ended up using it for quite a bit of development.  The
biggest drawback of the language was that it was native to the C64, and
therefore horribly slow (100 Baud serial disk drives, echhh).

What does a RATFOR for 6502 assembler language look like?  Well, let's
look at an example:
-------------------

putchar=$ffd2		; C64 Rom kernel put char to screen routine

main
   for i = 1 to 100
      puthex i
   next i
   stop			; return to shell

 def puthex h
   lsr a : lsr a : lsr a : lsr a : tax
   putchar hextab,x
   let h and $0f : tax
   putchar hextab,x
   return
 enddef puthex

hextab data "0123456789abcdef"

  end

The above example will print the numbers 1 to 100 in hex.  If you can
read 6502 code (after all, it is the simplest of all major micros), you
will recognize some assembler language syntax (lsr a   tax   etc.).
BASM lets you mix high level constructs (while, for, if then else, etc.)
with assembler language to form a very elegent ('C' eat your heart out)
compact program.  BASM seems to have all of the major advantages of 'C',
yet it generates code nearly as well as anyone can by hand.

This leads me to some questions that I have for all the UNIX gurus out
there.  Is 'C' really portable, or is UNIX pretty tough to port anyway
(by pretty tough, I mean a few months' work)?  Are other applications
written in 'C' really portable?  (I bet most are near impossible to
port from UNIX to the 8086).  Is it worth it for portability to have
programs that run at half the speed (or less) than the computer is
capable of (or will it matter if they make computers go fast enough)?
Or does it make more sense to use a language that fits the architecture
of the target machine (faster smaller code)?  Is time better spent porting
code that is not optimized for the target (but works) or is that time better
spent making a more optimized program for the target?  Does anyone else
besides me notice that the IBM PC AT runs rings around UNIX in any
environment I have seen it (PDP-11 and VAXes) - MS DOS is written in
assembler language?  Does anyone care how big their programs are?
Does anyone care how big the runtime libraries are (BASM has no
runtime library period)?

Should it matter that a language called Action (similar to BASM) on a
toy Atari 800 can compile a megabyte of source code (a little overstated)
in the time any 'C' compiler I have seen can compile "Hello, World"?
Is portability a reality?  I can port a BASM program from the C64 to
the C128 to the Atari 800 to the Apple II faster than a 'C' program can
be ported from Unix to the IBM PC, and we are talking about 20 MILLION
machines.  Will a 'C' program ever be ported from the Amiga or ST to
anywhere else (the Amiga OS has maybe 400 functions not supported by
Unix)?  How many are worth porting the other way?

I have not been trying to flame 'C', which is a Ratfor for PDP-11 assembler
language, so please nobody take this as a personal attack against some
hallowed institution.  What I have been trying to do is provide some
food for thought for those of you out there who want to write compilers.
The world needs more Modula and Pascal and 'C' compilers like we all
need another hole in the head.  How about using 'C' to bootstrap a
new language that fits a machine's architecture reasonably.

I shudder to think of a highly structured 'C' program spending the
majority of its time pushing and poping registers, passing arguments,
and returning a whole byte (or word or more) for a true/false condition.
It seems to me that all this time could be spent running someone else's
program - allowing more programs to run (and faster).  However, one of
these days, disk drives will be real fast, and Ram will be real fast,
and the CPUs will run at gigahertz clock speeds - then who cares (we all
will even then...).

Have a heart, this stuff is my opinion, and my observations (I am entitled
to my own opinion), and send any death threats, etc. directly to me via
mail.

Mike Schwartz @ 3Com Corp.

P.S. BASM was originally developed for the C64 and Atari 800 computers
by Computer Alliance of Granada Hills California.  I wrote a functional
equivalent of BASM for the IBM PC (generating 6502 code), then wrote
a superset of it (included macros, and other bells and whistles).  All
three compilers accept straight assembler language as input.

8086 BASM:
 def strcpy .s1, .s2
   mov si,s2
   mov di,s1
   while [si] -> [di] <> 0
 enddef strcpy
Re: structured assembler [message #282818 is a reply to message #282757] Sun, 19 January 1986 20:34 Go to previous message
cramer is currently offline  cramer
Messages: 5
Registered: January 1986
Karma: 0
Junior Member
Article-I.D.: kontron.463
Posted: Sun Jan 19 20:34:00 1986
Date-Received: Thu, 23-Jan-86 08:29:48 EST
References: <350@3comvax.UUCP>
Distribution: net
Organization: Kontron Electronics, Irvine, CA
Lines: 58
Xref: watmath net.micro.atari:2493 net.micro.cbm:1958 net.lang:2058 net.micro.amiga:1652

[color=blue]>  This leads me to some questions that I have for all the UNIX gurus out[/color]
[color=blue]>  there.  Is 'C' really portable, or is UNIX pretty tough to port anyway[/color]
[color=blue]>  (by pretty tough, I mean a few months' work)?  Are other applications[/color]
[color=blue]>  written in 'C' really portable?  (I bet most are near impossible to[/color]
[color=blue]>  port from UNIX to the 8086).[/color]

A project I am leading wrote 12000 lines of C in about four months on
a VAX running Berkeley 4.2 UNIX.  Then we tried to port it to the IBM AT
running PC-DOS and Microsoft C V3.0.  Six hours after we started moving
the source over, it ran.  Perfectly.  Is this portable?

[color=blue]>  Is it worth it for portability to have[/color]
[color=blue]>  programs that run at half the speed (or less) than the computer is[/color]
[color=blue]>  capable of (or will it matter if they make computers go fast enough)?[/color]

Ask all those companies that right now are wishing they could move their
8088 assembler language programs over to the Atari.

[color=blue]>  Should it matter that a language called Action (similar to BASM) on a[/color]
[color=blue]>  toy Atari 800 can compile a megabyte of source code (a little overstated)[/color]
[color=blue]>  in the time any 'C' compiler I have seen can compile "Hello, World"?[/color]
[color=blue]>  Is portability a reality?  I can port a BASM program from the C64 to[/color]
[color=blue]>  the C128 to the Atari 800 to the Apple II faster than a 'C' program can[/color]
[color=blue]>  be ported from Unix to the IBM PC, and we are talking about 20 MILLION[/color]
[color=blue]>  machines.  Will a 'C' program ever be ported from the Amiga or ST to[/color]
[color=blue]>  anywhere else (the Amiga OS has maybe 400 functions not supported by[/color]
[color=blue]>  Unix)?  How many are worth porting the other way?[/color]
[color=blue]>  [/color]

One of the reasons that the Atari ST uses GEM is because GEM provides
a consistent interface for application programs, and GEM works on the
IBM PC family as well.

[color=blue]>  I have not been trying to flame 'C', which is a Ratfor for PDP-11 assembler[/color]
[color=blue]>  language, so please nobody take this as a personal attack against some[/color]
[color=blue]>  hallowed institution.  What I have been trying to do is provide some[/color]
[color=blue]>  food for thought for those of you out there who want to write compilers.[/color]
[color=blue]>  The world needs more Modula and Pascal and 'C' compilers like we all[/color]
[color=blue]>  need another hole in the head.  How about using 'C' to bootstrap a[/color]
[color=blue]>  new language that fits a machine's architecture reasonably.[/color]
[color=blue]>  [/color]

What we need are 'C' compilers that WORK!  Microsoft V3.0 is real good.
It is the only C compiler for the PC family I have seen that is trustworthy
and useable.  I just wish it was available for the Atari.

[color=blue]>  I shudder to think of a highly structured 'C' program spending the[/color]
[color=blue]>  majority of its time pushing and poping registers, passing arguments,[/color]
[color=blue]>  and returning a whole byte (or word or more) for a true/false condition.[/color]

Sounds like you are objecting to structured design.  Maybe building
video games structured design isn't important because video games, while
complicated, aren't subject to the levels of maintenance and enhancement
that other products are.  (If it doesn't do what you expected when you
move the joystick, you can just define a new "rule" for the game).

[color=blue]>  Mike Schwartz @ 3Com Corp.[/color]
[color=blue]>  [/color]
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: What?
Next Topic: GEM Write or any other decent word processor for the Atari
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Apr 19 17:18:04 EDT 2024

Total time taken to generate the page: 0.02030 seconds