SemiOT: Mourning for Classic Computing

From: Iggy Drougge <optimus_at_canit.se>
Date: Wed Aug 15 22:03:45 2001

Sean 'Captain Napalm' Conner skrev:

>It was thus said that the Great Iggy Drougge once stated:
>>
>> Jeffrey S. Sharp skrev:
>>
>> >I've always thought that one of the more simple assembly languages would
>> >be a great 'first language' for someone wanting to learn how to program.
>> >Who's with me?
>>
>> Most assemblers haven't got a PRINT statement, so, no, I don't think so.

> Depends upon the environment. Under AmigaOS you have RawDoFmt(), which is
>part of Exec and available to Assembly language programmers (and it works
>similar to C's printf()). Under MS-DOS you have INT 21h, funtion 9, which
>prints a text string (ended by a `$'). But all you really need is a way to
>print out characters, leaving printing of numeric values as a programming
>exercise. In fact, writing a printf()-like routine (no formatting, just
>stuff like `%d' and `%s') is fairly simple (6809 code):

Now I'm glad I spent some time in PCDragon's debugger this evening! =)

> **********************************************
> * PRINTF - a printf()-esque routine.
> * Entry: X - ASCIIZ string
> * U - user data stack
> * Exit: X - end of string
> * U - adjusted as data is used
> * A - 0
> ***********************************************

> PRFT50 LDA ,X+ ; get next character after %
> CMPA #'% ; %?
> BEQ PRTF20 ; if so, print it
> CMPA #'d ; print a decimal number?
> BNE PRTF51
> PULU D ; get value
> BSR DECOUT ; print it
> BRA PRINTF ; continue
> PRTF51 CMPA #'x ; print hex number?
> BNE PRTF52
> PULU D ; get value
> BSR HEXOUT ; print hex value
> BRA PRINTF
> PRTF52 CMPA #'s ; print string?
> BNE PRTF20
> PSHS X ; save current string
> PULU X ; get new string
> BSR PRINTF ; print it (oooh! recursion!)
> PULS X ; get old string
> BRA PRINTF
> PRTF10 CMPA #'% ; print data?
> BEQ PRFT50 ; if so, handle
> PRTF20 JSR CHROUT ; print character
> PRINTF LDA ,X+ ; get next character
> BNE PRTF10 ; if not NUL, continue
> RTS
>
> Now all that's left is writing CHROUT (or assume the system has such a
>routine), DECOUT and HEXOUT (HEXOUT is trivial, DECOUT may make some work).
>It's all a part of learning.

But you've just served to prove my thesis. A PRINT statement like this will
only scare the newbies away. I remember when I was just getting interested in
computers, nearly ten years ago, when a computer magazine (the great DMz) had
a feature on programming languages (you don't see features like that often
nowadays). Along with a short description of each language, there was an
example program which prompted the user for some data, formatted it and
printed it on the screen. We all know what that would look like in BASIC, most
would be able to whip up a C or Pascal program to the same effect, but the
(m68k) assembly program occupied the entire right column of the page it was
printed on. That certainly instilled a certain kind of respect for assembly
into my young, impressionable mind.
It was only a month or two ago, when a mate showed me how to make a silly
little raster flash effect on a C64 in a few lines of assembly that it finally
dawned upon me that it might not be all about black magic.
No matter how easy it might be to make a PRINT statement in 6809 assembly,
it's still a whole lot of lines compared to PRINT"HELLO WORLD!".

--
En ligne avec Thor 2.6a.
Iggy tipsar: Vill du l?sa en PDF-fil, men saknar l?sare, skicka den till
pdf2txt_at_adobe.com, du f?r den tillbaka som ren ASCII till din epostadress.
Received on Wed Aug 15 2001 - 22:03:45 BST

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:33:33 BST