* ========================================================== *
*  Thomas C. Penick   ID# 452 80 6040         Program key    *
*  EE319K Microprocessor Programming                         *
*  Instructor: Laurence                       Section   B    *
*  MC6811 Program Source Code  key.asm        Roster#        *
* ========================================================== *
*
* This program demonstrates the use of InString and OutString.
* You will have to make the SCI window active, press alt-7.
* This program runs so slowly at the default speed, you may
* want to press F8 to get it to run fast.
* In the SCI window the message "Type Something: " is displayed.
* Up to 19 characters are accepted and can be seen in the
* memory window.  When the Enter key is pressed the string
* is terminated and stored in the Str variable.  The message 
* "Hit Enter" is displayed.  When the Enter key is pressed,
* the contents of Str are played back in the SCI window.

      org  0          Globals go in Ram
Str   rmb  20         String variable
Zip   rmb  2          String variable
      org  $E000      Object code goes in ROM
Main  lds  #$00FF     Stack grows down from $00FF
      jsr  InitSCI    Initialize the SCI (subroutine)

Start ldx  #Greet     Load register X with the address of Greet
      jsr  OutString  Display message in SCI window
      ldx  #Str       Load register X with the address of Str
      ldab #19        Load register B with the max size of input
      jsr  InString   Receive a string from the SCI window
      ldx  #Enter     Load register X with the address of Enter
      jsr  OutString  Display message "Hit Enter" in SCI window
      ldx  #Zip       Load register X with the address of Zip
      ldab #1         Load register B with the max size of input
      jsr  InString   Receive a string from the SCI window
      ldx  #Str       Load register X with the address of Str
      jsr  OutString  Output the previously typed string to the SCI window

      jmp  Start      Return to the first operation

Greet fcb  CR
      fcc  /Type something: /
      fcb  EOT
Enter fcb  CR
      fcc  /Hit Enter /
      fcb  CR
      fcb  EOT
      org  $FFFE
      fdb  Main       Starting address after a RESET
      end
