Page 1 of 2
ASCII character set
Posted: Thu Aug 09, 2018 6:25 am
by Kris1978
I'm using Merlin-Pro on AppleWin 1.27.0.0 emulator (Enhanced Apple IIe)
The following code:
ORG $8000
CTR EQU $06
HOME EQU $FC58
COUT EQU $FDED
START JSR HOME
LDA #$FF
STA CTR
LOOP LDA CTR
JSR COUT
DEC CTR
BEQ END
JMP LOOP
END RTS
when assembled and run it with >8000G< for the first time, it produces the result in the first picture below.
If I type >8000G< one more time, it produces the result in the second picture.
Why in the first time, I can't see all the range of ASCII characters? (lowercase etc.)
Why in the second time, I see "MORE" characters than 255? (256-1) I mean, "blank characters" are the Control characters but if you count them, the total exceeds the 255.
(Blinking characters are printed just fine but you can't see them on the photos)
By the way, the above code is taken from the book Assembly Lines, page 30. It was intended (as far as I know) for an Apple II computer and for the original Merlin Macro Assembler.
Does it has to do with the Merlin-Pro I'm using or it's just an internal (programming) fault of the emulator I'm using?
Merlin-Pro runs on different resolution than the Monitor. Maybe this creates that problem?
I'm confused! Please, help!
P.S. Do I have to consider buying an original Apple II computer from e-bay?

Re: ASCII character set
Posted: Thu Aug 09, 2018 8:59 am
by BigEd
If some of those unprintable characters are having an effect: such as clearing the screen, homing the cursor, tabbing... perhaps that would explain what you see? It's not unusual to start printing from character 32 instead of from zero.
On many systems, if you poke the bottom 32 characters to character screen memory (if there is such a thing) you will find there are characters designed for them. But the standard print-to-output routine won't print them, because it interprets them.
BTW, I'm glad you attributed the code! It has a rather awkward branch-around-a-jump which seem unnecessary in this case.
Re: ASCII character set
Posted: Thu Aug 09, 2018 3:23 pm
by barrym95838
$FDED is vectored, and usually has multiple layers of "services" wedged into it, listening for and responding to control characters between $80 and $9F. Even the "uncooked" version at $FDF0 does this a bit, ringing the bell for $87 and giving us a new line for $8D, among a couple of others.
If I run your program on an older ][, it prints something similar to your second example, the same result every run. Why your system acts slightly differently the first time through is a bit puzzling, and would require further investigation on my part when I get some time.
Re: ASCII character set
Posted: Fri Aug 10, 2018 6:30 am
by Kris1978
Hmmmm....
$89 = (Tab) which means it skips columns (how many columns? 4? 6?)
$8D = (Return) which means the cursor goes to the beginning of a new line
Well, yeah, that would partially explain why the number of "blank characters" exceed the number 32 as it was normally expected. For a complete explanation though, is there a place where I can read about each one of the control characters how they're interpreted by the routine $FDED (COUT)?
Re: ASCII character set
Posted: Fri Aug 10, 2018 3:13 pm
by barrym95838
You're definitely on the right track to understanding. A "complete explanation" may be a bit difficult, because $FDED is really nothing more than a spring board to the first of a chain of output device handlers, each one with its own control character interpretation. The most common output device handlers are for the Disk ][, the 80-column card, the printer and the modem, but the possibilities are practically endless. On the 8-bit Apples I know, the (default) end of that chain is $FDF0, so you can disassemble and study that portion of the monitor ROM. Note that there are differences in the $FDF0 code as well, depending on whether you're using a ][, ][+, IIe, IIc, or IIgs. You can even change the equate in your program from $FDED to $FDF0, and see if the output is a bit more consistent.
Good luck on your adventure! I am not an expert on the subject, but I hope that I gave you a path to pursue, and that I didn't confuse you with any misinformation.
Re: ASCII character set
Posted: Fri Aug 10, 2018 4:49 pm
by BigEd
Here's a version of the Red Book which contains a disassembly.
Edit: fixed up URL, I hope. Thanks!
Re: ASCII character set
Posted: Fri Aug 10, 2018 5:17 pm
by barrym95838
Your link didn't come through cleanly, Ed. Here's
my attempt.
P.S. This is the original monitor ROM, shipped with the original ][, and is packed full of little tricks to save a byte of precious ROM here and there. An example:
Code: Select all
FC2C: 49 C0 ESC1 EOR #$C0 ESC-@?
FC2E: F0 28 BEQ HOME IF SO, DO HOME AND CLEAR
FC30: 69 FD ADC #$FD ESC-A OR B CHECK
FC32: 90 C0 BCC ADVANCE A, ADVANCE
FC34: F0 DA BEQ BS B, BACKSPACE
FC36: 69 FD ADC #$FD ESC-C OR D CHECK
FC38: 90 2C BCC LF C, DOWN
FC3A: F0 DE BEQ UP D, GO UP
FC3C: 69 FD ADC #$FD ESC-E OR F CHECK
FC3E: 90 5C BCC CLREOL E, CLEAR TO END OF LINE
FC40: D0 E9 BNE RTS4 NOT F, RETURN
FC42: A4 24 CLREOP LDY CH CURSOR H TO Y INDEX
...
Here, Woz has a high-bit-set ASCII code in A and a set carry, and wants to act on eight different possibilities (@, A, B, C, D, E, F, other). He does it in 22 bytes, without a single CMP # ...
Re: ASCII character set
Posted: Fri Aug 10, 2018 5:41 pm
by BigEd
Thanks!
Re: ASCII character set
Posted: Sat Aug 11, 2018 7:57 am
by Kris1978
Is there a text editor for Windows that supports syntax highlighting (among other goodies) for Merlin assembler?
Re: ASCII character set
Posted: Sat Aug 11, 2018 8:09 am
by BigEd
Re: ASCII character set
Posted: Sat Aug 11, 2018 8:18 am
by Kris1978
Thank you BigEd. Though the xml file you put a link is for 68k assembly. Something for the 6502?
Re: ASCII character set
Posted: Sat Aug 11, 2018 8:20 am
by BigEd
I didn't see anything, but I imagine modifying the 68k would be a good way to start with a Merlin 6502 mode.
Re: ASCII character set
Posted: Sat Aug 11, 2018 8:28 am
by Kris1978
I didn't see anything, but I imagine modifying the 68k would be a good way to start with a Merlin 6502 mode.
So there isn't any ready made solution....I have to create it....
Re: ASCII character set
Posted: Sat Aug 11, 2018 8:42 am
by BigEd
I think you probably will - but it shouldn't be too difficult.
Re: ASCII character set
Posted: Sat Aug 11, 2018 9:57 am
by Kris1978

Yeah....SHOULD not be too difficult..... I don't know anything about XML and I'm a n00b in 6502 assembly. Yes, it should not be too difficult.....
