RS232.DOC

(1 KB) Pobierz
4-Mar-84 23:52 Fr [75765,1670]
     Machine-code wise there are two routines here.  The first one 
changes the vector (numbers in parenthesis are decimal address 
conversions):

033C (828)  78        SEI
033D (829)  A9 03     LDA #$03
033F (831)  8D 15 03  STA $0315
0342 (834)  A9 49     LDA #$49
0344 (836)  8D 14 03  STA $0314
0347 (839)  58        CLI
0348 (840)  60        RTS

   When the program is run, this is the program that is called by 
SYS828.  This, then, redirects the interrupts through the next part and 
returns control to the BASIC program.  The program then wipes itself out
with a NEW statement (but the machine code it created is alive and well 
in the casette buffer).  The real star of the show is the next part:

0349 (841)  AD 9C 02  LDA $029C
034C (844)  A8        TAY
034D (845)  4D 9B 02  EOR $029B
0350 (848)  F0 0E     BEQ $0360
0352 (850)  A5 C6     LDA $00C6
0354 (852)  D0 0A     BNE $0360
0356 (854)  B1 F7     LDA ($F7),Y
0358 (856)  8D 77 02  STA $0277
035B (859)  E6 C6     INC $C6
035D (861)  EE 9C 02  INC $029C
0360 (864)  4C BF EA  JMP $EABF (VIC version)
0360 (864)  4C 31 EA  JMP $EA31 (64 version)

Line by line, here is what's happening:

0349  Load the RS-232 input pointer
034C  and save it in the Y register.
034D  Compare it to the RS-232 receive pointer
0350  and if it's the same (empty RS-232 buffer) then exit.
0352  Otherwise, load number of characters in keyboard buffer
0354  and exit if NOT 0 (buffer NOT empty).
0356  Use the RS-232 receive pointer and the Y register to find the
      next character from the RS-232
0358  and store it in the keyboard buffer.
035B  Tell the operating system there is a character in the keyboard
      buffer.
035D  Point the RS-232 buffer to the next character posistion.
0360  Jump to the normal interrupt routine entry point.

Zgłoś jeśli naruszono regulamin