dragon64 assembler: string I/O

Hardware Hacking, Programming and Game Solutions/Cheats
User avatar
heavyfranz
Posts: 6
Joined: Sun Sep 01, 2013 10:37 am
Location: Italy

dragon64 assembler: string I/O

Post by heavyfranz »

Hello forum!
I'm having fun with DREAM assembler on a real dragon64, some 6809 books and an old letter quality printer. I've learned quite to try to "invent examples" on my own. Now I'm trying to do a "simple string manipulation library", at the moment at the 2nd stage of input from keyboard and output on screen: I'm capable of getting a string from keyboard and printing it on the screen, via subroutine and memory and the first version of this program works. The problems arrive when I try to implement a more general library that permits user to select where the string has to be printed, on screen on or serial. At the moment I'm trying to have the same results of the first version,the input from keyboard and the output to screen but all I have is constant garbage at every run and at the end only my complete string. Could I ask you some help to let me figure out what's going on?
I've uploaded image with the code...sorry they are scan of the printed code from Dream...I can save code on cassette only with the /S command on DREAM or with a /PM command printing the code...so funny...so old style....so tedious to do....
If you have time to help me thank you in advance :)

PS: another thing I would ask you: from the book "inside the dragon", my main source, I've seen many constant char declaration; they don't work as expected with my program. I've found the one that works is
MYSTR FCC LENGHT+1,/STRING/,0


Attachment:
-first version of the program
first file
first file
CCI10092013_00002.png (306.95 KiB) Viewed 5054 times
- second version of the program: on the image there are the main and the newer version of the PRINTL subroutine. Other 2 subroutines remain the same of the first image
second file
second file
CCI10092013_00003.png (341.03 KiB) Viewed 5054 times
User avatar
tormod
Posts: 416
Joined: Sat Apr 27, 2013 12:06 pm
Location: Switzerland
Contact:

Re: dragon64 assembler: string I/O

Post by tormod »

Wow, that's real retrocomputing! Welcome to the forum, heavyfranz!

But reading an upside-down scan of a poor printout is a pain... I have surely gotten spoiled over the years, but any chance you can get it transferred to tape (or directly to a computer) and post some plain text here?

If you can save it to tape and record the sound as a WAV on a computer you can use XRoar to convert it to a data file, by saving or printing to a file.
User avatar
JeeK
Posts: 67
Joined: Fri Aug 16, 2013 10:45 am
Location: Vienna, Austria
Contact:

Re: dragon64 assembler: string I/O

Post by JeeK »

First I have to transform this "listings" just to be able to read it. Other may participate:
http://klasek.at/hc/string-io/
This style remembers to my decades old documention I had so far from my projects ... :)
The dragon on my side: http://klasek.at/hc/dragon/
User avatar
JeeK
Posts: 67
Joined: Fri Aug 16, 2013 10:45 am
Location: Vienna, Austria
Contact:

Re: dragon64 assembler: string I/O

Post by JeeK »

The string definitions looks strange to me, they don't match the string termination character idea.

Code: Select all

FCC 9,/STRINGA=/,0
FCB 0
I don't know the assembler you are using, but mine accepts only one parameter and takes the first character as delemiter character which is expected as terminator for the string. Other restricts the terminator char to dedicated set like ['"/]. Therefore everything is taken verbose, the real terminating byte comes from the FCB statement.
A test in my simulator prints ",/STRINGA=/,0" ...
The dragon on my side: http://klasek.at/hc/dragon/
sixxie
Posts: 1348
Joined: Fri Jul 18, 2008 8:36 am
Location: Hertfordshire
Contact:

Re: dragon64 assembler: string I/O

Post by sixxie »

That's how the official Motorola assembler worked, but DREAM accepts multiple arguments and instead limits what can be used as the delimiter. Saner approach if you ask me (and so I adopt that approach in my own assembler).
User avatar
JeeK
Posts: 67
Joined: Fri Aug 16, 2013 10:45 am
Location: Vienna, Austria
Contact:

Re: dragon64 assembler: string I/O

Post by JeeK »

sixxie wrote:That's how the official Motorola assembler worked, but DREAM accepts multiple arguments and instead limits what can be used as the delimiter. Saner approach if you ask me (and so I adopt that approach in my own assembler).
Ok, nice.
In this case

Code: Select all

FCC 9,/STRINGA=/,0
produces
09 53 54 52 49 4E 47 41 3D 00
If this is correct, the leading length byte is not needed at all, because the printing routine just counts on the end delimiter. I don't know how a 09 (horizontal tab) or other control characters influence the output. Even if not garbled, I would estimate it leads to something at least unexpected. :o
The dragon on my side: http://klasek.at/hc/dragon/
Sarah
Posts: 177
Joined: Wed Apr 13, 2011 3:36 pm
Contact:

Re: dragon64 assembler: string I/O

Post by Sarah »

Okay, a couple of thoughts from a quick glance:

1. I can't remember whether or not OUTCH ($800C) preserves the registers you're using (you need X, U and A preserved). Please check?
2. I didn't follow what GETLNE is doing with B. It didn't seem to be used until you decremented it. Maybe you want CLR 2,U before the SCHAR loop instead and remove the B stuff?
User avatar
JeeK
Posts: 67
Joined: Fri Aug 16, 2013 10:45 am
Location: Vienna, Austria
Contact:

Re: dragon64 assembler: string I/O

Post by JeeK »

Sarah wrote: 1. I can't remember whether or not OUTCH ($800C) preserves the registers you're using (you need X, U and A preserved). Please check?
Both OUTCH and INCH preserves the registers (just checked in the Dragon32 ROMs, probably this may hold for the D64 too).
Sarah wrote: 2. I didn't follow what GETLNE is doing with B. It didn't seem to be used until you decremented it. Maybe you want CLR 2,U before the SCHAR loop instead and remove the B stuff?
Luckily, in the combination GETLNE and PRINTL is used even if the length from GETLNE is broken, PRINTL doesn't need it.
The dragon on my side: http://klasek.at/hc/dragon/
Sarah
Posts: 177
Joined: Wed Apr 13, 2011 3:36 pm
Contact:

Re: dragon64 assembler: string I/O

Post by Sarah »

Yes, that's true.

Okay, moving onto the 'Example' listing, I think it's trying to output TXT2 using CR as a terminator instead of NULL. So presumably it runs off the end of the text and continues output until it finds the CR from the LDA #CR instruction.
User avatar
heavyfranz
Posts: 6
Joined: Sun Sep 01, 2013 10:37 am
Location: Italy

Re: dragon64 assembler: string I/O

Post by heavyfranz »

Hello!
Thank you for your replyies! They are a lot! I've had some problems getting the "topic approvation email" from yahoo. I need some time to understand them completely and truly follow the conversation and learn from it. First of all excuse me for the poor code listing printout...I would have to fix the code (yes I've print the last part in reverse becuse I'd like to have all code on the same face and I don't know how to impose tab at the start of each line during printing on DREAM, but I've something about it, maybe in the ALLDREAM manual only).
The "string explain request" part of the first message was not complete, I've hit "enter" on preview mode and the message was given to the forum instead of give a CR to the text...So the question is:

All the manuals ( Leventhal, Inside the dragon, Dream manual...) says that constant string had to be instantiated with
MYSTRING FCC /STRING/ or
MYSTRING FCC /STRING/,0 or
MYSTRING FCC LENGHT,/STRING/ ; lenght is without terminator or
(from example) MYSTRING FCC /STRING/
FCB 0
From what I've seen (I have not a monitor in my DREAM) the only construct that works is
MYSTRING FCC N+1,/STRING/,0
FCB 0
In all the other case seems that the terminator is not set, so the PRINTL routine go ahead, printing a "memory dump", until a NULL is read.
So I don't know if my "string declaration" is only "conservative", because I waste a byte storing a 0 after the 0 placed by the FCC directive, or if is "dangerous" because start "an evil mechanism that drive my program and my head crazy".

At the end of this message I'll run DREAM and I'll take a photo of the program output of the misworking code and I'll post it here. I would really thank you for your enthusiasm replying me. See you soon!
Post Reply