home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / articles / archives / limanews.exe / ASSM_2.TXT < prev    next >
Text File  |  2006-10-19  |  6KB  |  99 lines

  1. ORIGINALLY PUBLISHED IN LIMA NEWSLETTER JANUARY 1994
  2.  
  3.                                Assembler Executing #2  
  4.                                   By Bob Carmany 
  5.  
  6.      I reckon that it is time for another installment of my continuing
  7. adventures into A/L programming.  Fortunately, most of this early material is
  8. fairly easy to understand.  I think we examined the concept of registers and
  9. number conversion the last time so I'm going to look at how A/L statements are
  10. written.  For the time being, the structure of the statements is all I can
  11. handle!  Back to the book! 
  12.      It says that A/L statements can have up to four fields.  Strangely enough,
  13. not all of them have to be present in a statement.  In order, they are: Label,
  14. Op(eration) Code or Directive, Operand, and Comment.  A label, the book says,
  15. is only required when you want to refer to a statement from another statement.
  16. I reckon it is sort of analogous to a CALL statement in XB -- a group of
  17. statements that make up a routine.  At least that's the sense of it that I can
  18. discern!  A label can be from 1 to 6 characters in length and the first
  19. character must be a letter (A to Z).  A label is the first entry in a statement
  20. and each statement can have only one label.  Logical enough!  I think that I
  21. can understand this! 
  22.      The next part of an A/L statement is the Op-Code or directive.  That tells
  23. the program what operation to perform on the third field.  A simple Directive
  24. is MOV for move word.  Any of the Op-Codes can be used but they must be spelled
  25. correctly (of course).  Even my foggy mind can understand that! 
  26.      The third field is the Operand field -- the item to be manipulated by the
  27. Op-Code.  There are some rules to follow with this lot as well.  Whew!  Talk
  28. about structured programming!!  More than one operand must be seperated by a
  29. comma and spaces can only appear in an operand if they are between a pair of
  30. apostrophies (the A/L equivalent of parentheses). 
  31.      The last field is the Comment field.  That is a freelance entry to explain
  32. what the statement was supposed to do --- and I emphasize SUPPOSED TO!  It can
  33. extend to the end of the line. 
  34.      There are some general rules about the form of A/L source code.  Each of
  35. the fields must be seperated from the other by at least one space.  By
  36. convention, the fields are generally aligned when they are written.  Oh yes,
  37. you can add general comments to your programs by using the asterisk "*" at the
  38. beginning of the line.  It functions as a REM statement in XB. 
  39.      Although any text editor that outputs a D/V 80 file can be used to create
  40. source code, the best that I have found is F'WEB in the ASMode.  All of the
  41. tabs have been fixed and the word-wrap has been turned off.  In addition, the
  42. code is saved without the tab settings.  I find it very easy to use when I'm
  43. about to "borrow" a bit of source code from an article somewhere.  I haven't
  44. gotten far enough with this stuff to write my own code yet! 
  45.      Ok, let's see what a line of A/L source code might look like.  This is for
  46. structure only so I have just picked some stuff out of the book: 
  47.  
  48.  
  49. START  MOV  @@A,R0 Move A to Register 0 
  50.  
  51.      Here you have a Label, Op-Code, Operand, and Comment field. 
  52.  
  53.      Now, it is time to take a look at a comparison between XB (which I
  54. understand) and A/L (which I don't).  This example is a bit primitive but it is
  55. about all that I can muster right now. 
  56. .NF 
  57. .NA 
  58.       
  59.  
  60. 100 DATA 1,7   Defines the two data items 1 and 7 
  61. 110 READ X,Y   Assigns the value 1 to X and 7 to Y 
  62. 120 Z=X+Y      Adds X and Y to get the value of Z 
  63.                 
  64.      The same program in A/L would look something like this: 
  65.       
  66. X      DATA  1      Assigns the name X to the value 1 
  67. Y      DATA  7      Assigns the name Y to the value of 7 
  68. Z      BSS   2      Reserves 2 bytes of memory for the value Z 
  69.        MOV   @X,R0  Moves X to work Register 0 
  70.        MOV   @Y,R1  Moves Y to work Register 1 
  71.        A     R0,R1  Adds Register 0 to Register 1 
  72.        MOV   R1,@Z  Moves the sum to Register 1 replacing  
  73. *                        the number there 
  74.  
  75. .FI 
  76. .AD 
  77.      Bloody amazing!  I learned how to add 1 and 7 in a program.  Watch out Ron
  78. and Tony --- I'm on the way!! 
  79.      All you have to do from here is run the source code through the Assembler
  80. and you have a D/F object code file that you can LOAD AND RUN.  Type in the
  81. input filename, an output filename and, after pressing <FCTN-6> the ASSEMBLER
  82. EXECUTING message appears.  If you are lucky, you get a "0000 ERRORS" message
  83. when the Assembler is through. 
  84.      That would be a new experience for me!  Even on stuff that I thought that
  85. I had typed in accurately from a printed copy I usually get "double digit"
  86. errors!  I once typed in about 300 or so lines of source code directly (I
  87. thought) from a couple of issues of MICROpendium.  It took me two days just to
  88. get the typos corrected in that mess!!  After all of that, the silly program
  89. wouldn't even run.  You can imagine how "happy" I was about that!  Just wait
  90. until I start writing my own programs --- triple digit errors may not be out of
  91. the question! 
  92.      So far, I have to admit that A/L isn't nearly as difficult to understand
  93. as I thought that it would be.  Of course, I haven't really started to do any
  94. substantive programming.  I've managed to display a few bits of text on the
  95. screen and manipulate some numbers here and there but nothing that would
  96. qualify as a program.  We'll have to see what the next month will bring! 
  97.      .PL 1 
  98.  
  99.