a E i - Commodore Is Awesome
a E i - Commodore Is Awesome
a E i - Commodore Is Awesome
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
ing this<br />
let Basic<br />
ire data<br />
I use an<br />
RS232<br />
idea.<br />
!link at<br />
11).<br />
es prom<br />
later<br />
actical<br />
•: best<br />
an be<br />
faster<br />
'ill be<br />
vill be<br />
code<br />
le the<br />
that<br />
Basic<br />
u any<br />
mory<br />
This<br />
ould<br />
(lore<br />
401<br />
'EN<br />
KE<br />
CH<br />
55,<br />
10,<br />
is<br />
is<br />
ts<br />
ir<br />
OBOO LDX #$02<br />
01302 JSR SFEC6<br />
OB05 JSR $FFE4<br />
0808 TAY<br />
01409 JSR $FFCC<br />
01-10C TYA<br />
OBOD BEQ $0812<br />
OBOF JSE $EFD2<br />
0812 JSR $1<br />
701315<br />
BEQ $0B00<br />
1- OBI 7 PHA; Save data<br />
013I8<br />
7<br />
LDX #$02<br />
OBIA JSR $FFC9<br />
OH E4IL)<br />
PLA<br />
OBI E JSR HEED2<br />
0821 JSR $FFCC<br />
0824 SEC<br />
0B25 BCS $01300<br />
Table 3<br />
The program uses the kernal<br />
jumptable calls so it should be valid for<br />
all of the machines.<br />
After the machine code has been<br />
placed in memory, the RS232 channel<br />
is opened with a file number of 2 (the<br />
channel number. If you change this<br />
Table 4<br />
LDA #$02<br />
LDX #$02<br />
LDY #$00<br />
JSR $FEBA<br />
LDA L$01<br />
LDX if NAME<br />
LDY # NAME<br />
JSR $FEBD<br />
JSR SEFC0<br />
Rest of code<br />
Character set translation<br />
All this should be fine for <strong>Commodore</strong><br />
to <strong>Commodore</strong> communications. It<br />
will also work with <strong>Commodore</strong> to<br />
IBM/BBC etc. comms but may yield<br />
strange results, the reason being that<br />
the <strong>Commodore</strong>s do not use standard<br />
ASCII codes. They use what is sometimes<br />
called PETSCII, the <strong>Commodore</strong><br />
PET being the first to use it. The<br />
most noticeable effect of this is that<br />
certain characters will appear on the<br />
<strong>Commodore</strong>'s screen as graphics<br />
characters. The solution to this is to<br />
insert some form of translation table<br />
or routine into the code. Since data<br />
RS232<br />
; Make channel 2 the current input device<br />
; Scan the RS232 buffer for I character<br />
; Save data<br />
; Clear the channel<br />
; Restore the date<br />
; If data is a null (a zero byte) then skip<br />
; Output valid character<br />
; Check for keyboard input<br />
; If none then recheck RS232<br />
; Make channel 2 the current output device<br />
; Restore data<br />
: Send byte to RS232<br />
; Clear channel<br />
; Force loop to check RS232 input<br />
you must change the two LDX<br />
instructions in the code) and the<br />
machine code routine called. Now the<br />
RS232 receive buffer does not get a<br />
chance to fill up so no data is lost. The<br />
OPEN statement could be replaced by<br />
the code in Table 4.<br />
; Channel 2<br />
; Device 2<br />
; Secondary Addr. 0<br />
; Set logical file<br />
; 2 chars in filename<br />
; Pointer to filename<br />
; Pointer to filename<br />
; Set filename<br />
; Open RS232<br />
,NAME:#B:24,0 ; Control and command register values (PLUS 4---<br />
.NAME:#13:24,5) (#13: <strong>Is</strong> the byte directive of my C64 and C128<br />
assemblers)<br />
flows two ways, a routine or table<br />
would be required for each of input<br />
and output.<br />
Two translation tables, each of 256<br />
bytes, are required to handle outgoing<br />
and incoming data translations. The<br />
following program builds the<br />
translation tables and the machine<br />
code into memory starting at address<br />
AD. It needs at least 600 bytes to<br />
operate in so you need only change AD<br />
to the address you require. This<br />
version is for the Cl28 (Program<br />
Translate).<br />
Program Translate<br />
Line 5: AD=start address:<br />
BR=Control reg: CR=command reg.<br />
Y O U R COMMODOREjanuary1987<br />
87<br />
Lines 10-100: Prepare tables<br />
Lines 111-113: Setup name of channel<br />
(register images)<br />
Lines 120-160: POKE receive table<br />
Lines 170-200: POKE transmit table<br />
Lines 210-230: POKE code to memory<br />
Lines 240-270: Adjust table references<br />
in code<br />
Lines 280-290: Adjust register image<br />
references in code<br />
Lines 300-310: Select lowercase and<br />
call routine<br />
Lines 330-370: Code data<br />
Table 5 shows the disassembled<br />
machine code (addresses are offsets<br />
from the start address):<br />
Basically, the operation is the same<br />
as before except:<br />
1. The channel is opened from machine<br />
code.<br />
2. Characters sent and received are<br />
translated.<br />
Note that the backslash (\)<br />
character received will be displayed as<br />
a pound sign. The CBM Charset does<br />
not have a backslash.<br />
Transferring files via RS232<br />
This is probably the most useful application<br />
of RS232; transferring data<br />
between unalike machines. It is<br />
possible to transfer programs between<br />
two entirely different machines.<br />
When using a 3-line interface, it is<br />
necessary to introduce some form of<br />
protocol into the software at both<br />
ends. This ensures that each machine<br />
understands exactly what the other<br />
intends to do.<br />
A typical protocol exchange would<br />
look like a conversation between the<br />
two machines:<br />
machine I: Are you there?<br />
machine 2: Yes.<br />
machine 1: Requesting data transfer.<br />
machine 2: OK,<br />
machine 1: Transferring data (block of<br />
data sent)<br />
machine 2: Received data.<br />
and so on. The "are you there", "yes"<br />
etc. messages are actually I byte<br />
control codes. Normal ASCII has 32<br />
control codes (codes 0-31). The actual<br />
usage varies from system to system and<br />
there are one or tvvo protocol standards.<br />
For your own use, you don't have<br />
to follow any set protocol AS LONG<br />
AS BOTH MACHINES ARE USING