LISTING3.TXT

From Atari Wiki
Revision as of 23:59, 16 December 2023 by Olivier.jan (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
**********************************************************************
*                                                                    *
*                68000 ASSEMBLY COURSE ON ATARI ST                   *
*                                                                    *
*                   by The Fierce Rabbit (from 44E)                  *
*                                                                    *
*                             Second series                          *
*                                                                    *
*                            Listing number 3                        *
*                                                                    *
**********************************************************************
          INCLUDE    "B:\START.S"

          MOVE.L     #MESSAGE,-(SP)        introductory message
          MOVE.W     #9,-(SP)
          TRAP       #1
          ADDQ.L     #6,SP

TOUCHE    MOVE.W     #7,-(SP)   waiting for a keypress
          TRAP       #1
          ADDQ.L     #2,SP
          SWAP       D0         to get the scan code

          CMP.W      #1,D0      escape?
          BEQ        FIN        yes so bye bye
          CMP.W      #$3B,D0    comparing to F1
          BLO        TOUCHE     below therefore not valid
          CMP.W      #$44,D0    comparing to F10
          BHI        TOUCHE     above therefore not valid

* The key is valid
          LEA        TABLE,A0
          SUB.W      #$3B,D0    to get a number from 0 to 9
*         MULU.W     #2,D0      ATTENTION! why the star beginning??
          MOVE.W     0(A0,D0.W),D1
          MOVE.W     D1,-(SP)
          MOVE.W     #2,-(SP)
          TRAP       #1
          ADDQ.L     #6,SP
          BRA        TOUCHE

FIN       CLR.W      -(SP)
          TRAP       #1
*--------------------------------------------------*
          SECTION DATA
MESSAGE   DC.B       27,"E","PRESS A FUNCTION KEY",13,10
          DC.B       "ESCAPE TO EXIT",13,10,0
          EVEN
TABLE     DC.W       "A","Z","E","R","T","Y","U","I","O","P"
          SECTION BSS
          DS.L       256
STACK     DS.L       1
     END

Back to ASM_Tutorial