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

  1. *****************************************************************************
  2. ***                           CONSTRING.ASM                               ***
  3. ***                                                                       ***
  4. ***    Author : Andrew Duffy                                              ***
  5. ***    Date   : November 1992                                             ***
  6. ***    Desc.  : This program reads in a string from the keyboard          ***
  7. ***             (terminated by the character 'Term') and outputs it in    ***
  8. ***             the opposite case.                                        ***
  9. ***                                                                       ***
  10. ***                          ©XCNT, 1992-1994.                            ***
  11. *****************************************************************************
  12.  
  13.  
  14. *****************************************************************************
  15. ***                              Includes                                 ***
  16. *****************************************************************************
  17.  
  18.         include    "subrts.h"    Included by default anyway
  19.  
  20. *****************************************************************************
  21. ***                        Termination character                          ***
  22. *****************************************************************************
  23.  
  24. Term        EQU    13
  25.  
  26. *****************************************************************************
  27. ***                         Main control routine                          ***
  28. *****************************************************************************
  29.  
  30. Main        jsr    Messages    Print initial messages
  31.         jsr    GetString    Read string from keyboard
  32.         jsr    ConString    Convert string and output
  33.         rts            Exit
  34.  
  35. *****************************************************************************
  36. ***                          Messages routine                             ***
  37. *****************************************************************************
  38.  
  39. Messages    movea.l    #Instructs,a6    Print text and other messages
  40.         jsr    OUTSTR        Call OUTSTR routine
  41.         rts            Return to Main
  42.  
  43. *****************************************************************************
  44. ***                         GetString routine                             ***
  45. *****************************************************************************
  46.  
  47. GetString    movea.l    #Data,a0    Storage address
  48. _GetString2    jsr    INCH        Call INCH routine
  49.         jsr    OUTCH        Call OUTCH routine
  50.         cmp.b    #8,d0        Compare with Delete character
  51.         beq    Delete
  52.         move.b    d0,(a0)+
  53.         cmp.b    #Term,d0    Compare with Carriage Return
  54.         bne.s    _GetString2
  55.         jsr    CRLF        Call CRLF routine
  56.         rts            Return to Main
  57.  
  58. *****************************************************************************
  59. ***                         ConString routine                             ***
  60. *****************************************************************************
  61.  
  62. ConString    movea.l    #Data,a0    Restore Storage address
  63. _ConString2    move.b    (a0)+,d0
  64.         jsr    Convert.Case
  65.         jsr    OUTCH        Call OUTCH routine
  66.         cmp.b    #Term,d0    Check for a carriage return
  67.         bne    _ConString2
  68.         rts            Return to main menu
  69.       
  70. *****************************************************************************
  71. ***                        Convert.Case routine                           ***
  72. *** This routine will convert the case of alphabet characters only in d0, ***
  73. *** returning either a converted character or the original in d0.         ***
  74. *****************************************************************************
  75.  
  76. Convert.Case    cmp.b    #'A',d0        Check if character is => A ...
  77.         bge    _Con.Case1    ... go through to second filter
  78.         rts
  79.  
  80. _Con.Case1    cmp.b    #'Z',d0        Check if character is <= Z ...
  81.         ble    _Con.Case3    ... must be capital so convert
  82.  
  83.         cmp.b    #'a',d0        Check if character is => a ...
  84.         bge    _Con.Case2    ... go through to a third filter
  85.         rts
  86.  
  87. _Con.Case2    cmp.b    #'z',d0        Check if character if <= z ...
  88.         ble    _Con.Case3    ... must be lower so convert
  89.         rts
  90.  
  91. _Con.Case3    eor    #$20,d0        Convert character
  92.         rts
  93.  
  94. *****************************************************************************
  95. ***                            Delete routine                             ***
  96. *** The delete key was pressed, delete last character on screen and       ***
  97. *** decrease address.                                                     ***
  98. *****************************************************************************
  99.  
  100. Delete        jsr    SPACE        Call SPACE routine
  101.         move.b    #8,d0        Put ASCII delete in d0
  102.         jsr    OUTCH        Call OUTCH routine
  103.         move.b    #' ',-(a0)
  104.         bra    _GetString2    Continue getting the string
  105.  
  106. *****************************************************************************
  107. ***                               Strings                                 ***
  108. *****************************************************************************
  109.  
  110. Instructs    dc.b    "ConString.asm",13,10,"=============",13,10,13,10
  111.         dc.b    "Type in a string of text to be converted to the opposite case.",13,10
  112.         dc.b    "Press <RETURN> when finished :",13,10,13,10,0
  113.         even
  114.  
  115. *****************************************************************************
  116. ***                             Storage Area                              ***
  117. *****************************************************************************
  118.  
  119. Data        ds.b    200
  120.  
  121. *****************************************************************************
  122. ***                      End of file CONSTRING.ASM.                       ***
  123. *****************************************************************************
  124.