[comp.sys.apple] Peripheral Card I/O

tjohnson@pro-nucleus.cts.com (Terry Johnson) (06/04/89)

     I'm a beginning assembly language programmer and I am attempting to
learn how to use peripheral cards.  Currently I'm trying to learn by writing
"dumb" terminal program for my Hayes Smartmodem 1200A on my Apple enhanced
//e. This is what I have so far:

(ORG $300)

JSR $FC58    ; A weak attempt at neatness.  You'll see things get messier.
LDA #02      ; My modem is in slot 2.  This and the following instruction
JSR $FE95    ; do the same thing as "PR#2" or "2CTRL-P" (i.e. activate
             ; modmem).

JSR $FD6A    ; Lazy use of subroutine to get a line. This is where I type
LDY #$00     ; "AT DT XXX-XXXX return." Length of line is stored in X-reg.
*LDA $0200,Y ; Line stored starting at $200.  Get first character and put
JSR $FDF0    ; it on the screen so can at least see if I typed it right.
JSR $FDED    ; Also, send same character to the "current" output device
             ; (modem since JSR $FE95).
INY          ; Increment Y to get next character.
DEX          ; Decrement length of line stored in X.
BNE $30D (*) ; Get next character and repeat (BNE "*") until X-reg=0.
             ; Since the modem will execute the command sent to it's
             ; buffer once the return is sent that I typed at the end
             ; of the command string during the $FD6A subroutine, the
             ; result up to this point is that the modem dials the
             ; number and connects. Here's the problem-->

LDA #$02    ; I assumed that if I did a "IN#2" with this line and
JSR $FE8B   ; this line, input would come "from" the modem.
LDA #00     ; With this, "PR#0,"  I assumed that output from the modem
JSR $FE95   ; would go to the screen.  In other words, I assumed I would
BRK         ; see the introduction screen to the BBS that I was calling.

Was I ever wrong.  Remember that the reason I wrote this sloppy,
throw-it-together program was to experiment to see if I could get some
insight as to how these things work.  So allow me to apologize for
such an unprofessional and "far from elegant" program.  What is
required for this method to work?  Am I going about this totally wrong
due to some misunderstanding I have of PR# and IN#? Should I be using
PASCAL firmware protocol entry points that my manual mentions with
explainations incomprehensible to me?  Thanks zillions in advance for
any help since I haven't found many people in my area that are
interested, willing to help me or that know anything about the subject.

                                                Terry Johnson
                                                Biochem Student
                                                U.C. Riverside
                                                

) (06/06/89)

Network Comment: to #4236 by pnet01!crash!pro-nucleus.cts.com!tjohnson

I've programmed a few simple chat programs before, one for a Micromodem ][e
and a few for an external with Super Serial Card. I haven't ever used a 1200A
so this information may not apply.

As far as I can tell, you should use the Pascal entry to set it up. Otherwise,
it depends on how much you trust your card whether or not you use the
Pascal-IN and Pascal-OUT routines provided on standard cards.

I never trust the guys who make hardware. I dug in and found the Status bytes
on both modem cards and saw where it was "Receive Register" on one of the bits
of that byte. When I LDA Status  then AND #$xx (whatever the bit is for the
register) and then you BEQ xx or BNE xx depending on how the bit is set and
how the register will tell you there is a character in the buffer. When you
don't get a character in the buffer, then you check your own keyboard. If
there's something there, LDA $C000, BPL (back to check register). STA Write
register/read register. Sometimes they double as read/write in one byte.
When you do get a character then you LDA Write reg/Read reg then you print it
to your screen with either JSR $FDF0 or JSR $C307 (C307 is output for the Aux
80 column card). Then JMP to the status bit checker.

Notice how you must have a loop so you don't get stuck only waiting for input
from either keyboard or modem...Hope you can understand some of this and find
the right bytes in your firmware!

Jason Hughes
Lots of luck, I know I wish I had some help trying mine.
+-------------------------------- = --------------------------------+
!        Jason Hughes             :                                 !
!  ProLine: panther@pro-lep       :    "Nobody knows...(hic)...the  !
!   Postal: 5812 Abilene Trails   :     Tribbles I've seen...(hic)" !
!           Austin, TX 78749      :                                 !
+-------------------------------- = --------------------------------+

) (06/06/89)

Network Comment: to #4236 by pnet01!crash!pro-nucleus.cts.com!tjohnson

I've programmed a few simple chat programs before, one for a Micromodem ][e
and a few for an external with Super Serial Card. I haven't ever used a 1200A
so this information may not apply.

As far as I can tell, you should use the Pascal entry to set it up. Otherwise,
it depends on how much you trust your card whether or not you use the
Pascal-IN and Pascal-OUT routines provided on standard cards.

I never trust the guys who make hardware. I dug in and found the Status bytes
on both modem cards and saw where it was "Receive Register" on one of the bits
of that byte. When I LDA Status  then AND #$xx (whatever the bit is for the
register) and then you BEQ xx or BNE xx depending on how the bit is set and
how the vegister will tell you there is a character in the buffer. When }ou
don't get a character in the buffer, then you check your own keyboard. If
there's something there, LDA $C000, BPL (back to check register). STA Write
register/read register. Sometimes they double as read/write in one byte.
When you do get a character then you LDA Write reg/Read reg then you print it
to your screen with either JSR $FDF0 or JSR $C307 (C307 is output for the Aux
80 column card). Then JMP to the status bit checker.

Notice how you must have a loop so you don't get stuck only waiting for input
from either keyboard or modem...Hope you can understand some of this and find
the right bytes in your firmware!

Jason Hughes
Lots of luck, I know I wish I had some help trying mine.
+-------------------------------- = --------------------------------+
!        Jason Hughes             :                                 !
!  ProLine: panther@pro-lep       :    "Nobody knows...(hic)...the  !
!   Postal: 5812 Abilene Trails   :     Tribbles I've seen...(hic)" !
!           Austin, TX 78749      :                                 !
+-------------------------------- = --------------------------------+