home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / amiga-flight / programs / control.asm < prev    next >
Assembly Source File  |  1977-12-31  |  5KB  |  131 lines

  1. *****************************************************************************
  2. ***                            CONTROL.ASM                                ***
  3. ***                                                                       ***
  4. ***    Author : Andrew Duffy                                              ***
  5. ***    Date   : January 1993                                              ***
  6. ***    Desc.  : This program demonstrates how to control the motor and    ***
  7. ***             heater using APPS_PORTA.                                  ***
  8. ***                                                                       ***
  9. ***                          ©XCNT, 1992-1994.                            ***
  10. *****************************************************************************
  11.  
  12.  
  13. *****************************************************************************
  14. ***                              Includes                                 ***
  15. *****************************************************************************
  16.  
  17.         include    "subrts.h"    Included by default anyway
  18.  
  19. *****************************************************************************
  20. ***                          Initialisation routine                       ***
  21. *****************************************************************************
  22.  
  23.         move.b    #APPS_MOTOR+APPS_HEATER,d0  Initialise the applications board
  24.         jsr    APPS_INIT    (using motor and heater)
  25.  
  26.         move.b    #0,APPS_PORTA    Turn everything off
  27.  
  28.         movea.l    #Instructs,a6    Print instructions
  29.         jsr    OUTSTR
  30.  
  31. *****************************************************************************
  32. ***                         Main control routine                          ***
  33. *****************************************************************************
  34.  
  35. Main        jsr    INCH
  36.         bclr    #5,d0        Convert to upper case
  37.         cmp.b    #'F',d0
  38.         beq    Mot_For
  39.         cmp.b    #'B',d0
  40.         beq    Mot_Bac
  41.         cmp.b    #'S',d0
  42.         beq    Mot_Sto
  43.         bset    #5,d0        Convert back to normal case
  44.         cmp.b    #'1',d0
  45.         beq    Heat_On
  46.         cmp.b    #'2',d0
  47.         beq    Heat_Off
  48.         cmp.b    #'.',d0        Was full stop pressed ?
  49.         bne    Main        If not then loop again
  50.  
  51. *****************************************************************************
  52. ***                         Turn everything off                           ***
  53. *****************************************************************************
  54.  
  55.         move.b    #0,APPS_PORTA    Turn everything off
  56.         rts            Exit
  57.  
  58. *****************************************************************************
  59. ***                        Motor forward routine                          ***
  60. *****************************************************************************
  61.  
  62. Mot_For        bclr    #6,APPS_PORTA    Clear bit 6 of Port A
  63.         bset    #7,APPS_PORTA    Set bit 7 of Port A
  64.         movea.l    #Forwards,a6    Output forward message
  65.         jsr    OUTSTR
  66.         bra    Main        Continue at main
  67.  
  68. *****************************************************************************
  69. ***                        Motor backward routine                         ***
  70. *****************************************************************************
  71.  
  72. Mot_Bac        bclr    #7,APPS_PORTA    Clear bit 7 of Port A
  73.         bset    #6,APPS_PORTA    Set bit 6 of Port A
  74.         movea.l    #Backwards,a6    Output backward message
  75.         jsr    OUTSTR
  76.         bra    Main        Continue at main
  77.  
  78. *****************************************************************************
  79. ***                        Motor stopped routine                          ***
  80. *****************************************************************************
  81.  
  82. Mot_Sto        bclr    #7,APPS_PORTA    Clear bit 7 of Port A
  83.         bclr    #6,APPS_PORTA    Clear bit 6 of Port A
  84.         movea.l    #Stopped,a6    Output stopped message
  85.         jsr    OUTSTR
  86.         bra    Main        Continue at main
  87.  
  88. *****************************************************************************
  89. ***                          Heater on routine                            ***
  90. *****************************************************************************
  91.  
  92. Heat_On        bset    #5,APPS_PORTA    Set bit 5 of Port A
  93.         movea.l    #On,a6        Output on message
  94.         jsr    OUTSTR
  95.         bra    Main        Continue at main
  96.  
  97. *****************************************************************************
  98. ***                         Heater off routine                            ***
  99. *****************************************************************************
  100.  
  101. Heat_Off    bclr    #5,APPS_PORTA    Clear bi 5 of Port A
  102.         movea.l    #Off,a6        Output off message
  103.         jsr    OUTSTR
  104.         bra    Main        Continue at main
  105.  
  106. *****************************************************************************
  107. ***                              Strings                                  ***
  108. *****************************************************************************
  109.  
  110. Instructs    dc.b    "Control.asm",13,10,"===========",13,10,13,10
  111.         dc.b    "Ensure that the Motor and Heater are switched on.",13,10
  112.         dc.b    "Press F to make motor go forwards, B to make motor go backwards, S to stop.",13,10
  113.         dc.b    "Press 1 to turn heater on, 2 to turn heater off.",13,10
  114.         dc.b    "Press full stop to quit.",13,10,13,10
  115.         dc.b    "Motor Status  : Stopped",13,10
  116.         dc.b    "Heater Status : Off",13,10,0
  117.         even
  118. Forwards    dc.b    27,"[9;17fGoing fowards  ",13,10,0
  119.         even
  120. Backwards    dc.b    27,"[9;17fGoing backwards",13,10,0
  121.         even
  122. Stopped        dc.b    27,"[9;17fStopped        ",13,10,0
  123.         even
  124. On        dc.b    27,"[10;17fOn ",13,10,0
  125.         even
  126. Off        dc.b    27,"[10;17fOff",13,10,0
  127.  
  128. *****************************************************************************
  129. ***                      End of file CONTROL.ASM.                         ***
  130. *****************************************************************************
  131.