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

  1. ORIGINALLY PUBLISHED IN LIMA NEWSLETTER SEPTEMBER 1994
  2.  
  3.                                Assembler Executing . . . 
  4.                                   By Bob Carmany 
  5.  
  6.      Ever onward!  The only problem is that I'm not exactly sure where we're
  7. headed.  I think that it might be down the fabled "primrose path".  So far,
  8. this hasn't been as bad as I had imagined.  I have actually been able to
  9. understand a good portion of what has been going on.  It may change soon, but
  10. for the present. . . 
  11. Ah yes, arithmetic instructions! All of that "good" stuff --adding,
  12. subtracting, multiplying, etc.  I think that I could do without this lot.
  13. After all, I never was all that good in mathematics in school.  Luckily, most
  14. of this lot deals with small numbers --the kind that you can use your fingers
  15. and toes to count.  Let's go ahead and get started! 
  16.  
  17. Name                     Op Code      Comments 
  18. ~~~~                     ~~~~~~~      ~~~~~~~~ 
  19.  
  20. Add Immediate            AI           Uses a register and immediate addressing 
  21.  
  22. Add Words                A            Any of the general addressing modes 
  23.  
  24. Add Bytes                AB           "       "       "       "       " 
  25.  
  26. Subtract Words           S            "       "       "       "       " 
  27.  
  28. Subtract Bytes           SB           "       "       "       "       " 
  29.  
  30. Increment                INC          "       "       "       "       " 
  31.  
  32. Increment by Two         INCT         "       "       "       "       " 
  33.  
  34. Decrement                DEC          "       "       "       "       " 
  35.  
  36. Decrement by Two         DECT         "       "       "       "       " 
  37.  
  38. Negate                   NEG          "       "       "       "       " 
  39.  
  40. Absolute Value           ABS          "       "       "       "       " 
  41.  
  42. Multiply                 MPY          Any general mode and a register 
  43.  
  44. Divide                   DIV          "       "       "       "       " 
  45.  
  46.      Most of these arithmetic operations are so simple that they scarcely need
  47. any sort of explanation.  That's good because if they were very involved I
  48. wouldn't be able to understand any of this next bit. 
  49.  
  50.      AI   R7,6      This loads the value 6 into register 7.   The Overflow and
  51.                     Carry bits are affected by additions (remember the JUMP
  52.                     operators last time?) 
  53.  
  54.      A    R1,R7     Adds two 16-bit numbers contained in registers 1 and 7.
  55.                     The sum is compared to zero and the Logical Greater Than,
  56.                     Arithmetic Greater Than, and Equal status bits are
  57.                     affected. 
  58.  
  59.      AB   @GIZMO,R7 This is the same as add words except that two bytes are
  60.                     added and the Odd Parity bit is affected. 
  61.  
  62.      Subtract words (S) and subtract bytes (SB) are the converse of their "add"
  63. complements.  The same status bits can be read and JUMP instructions can be
  64. used with them. 
  65.      The decrement and increment instructions use a constant to either
  66. increment or decrement a value by either one or two.  They affect the Carry and
  67. Overflow status bits and when the result is compared to zero, the Logical
  68. Greater Than, Arithmetic Greater Than, and Equal status bits are affected and
  69. can be read.  I found they they are commonly used in loops.  Remember that? 
  70.      Negate (NEG) is easy to understand.  The easiest way I found to figure it
  71. out was that it changed the sign of the value to the opposite.  For example, if
  72. R5 contained the value of -5 : 
  73.  
  74.      NEG   R5  would leave a value of 5 there instead. 
  75.  
  76.      Absolute Value creates the absolute value of a number.  The same bits as
  77. the previous examples are affected. 
  78.  
  79.      Multiply (MPY) and Divide (DIV) multiply and divide two 16-bit numbers to
  80. create a 32-bit product.  The second
  81. operand must be register direct addressing.  The 32-bit product spills over
  82. into two adjacent registers. 
  83.  
  84.      MPY  @GIZMO,R7  would put the most significant 16 bits into register 7 and
  85.                      the least significant 16 bits into register 8. No status
  86.                      bits are affected. 
  87.      Divide does the same thing except that the Overflow status bit is
  88. affected. 
  89.      There are still a bunch of instructions that I haven't encountered to a
  90. large degree but from time-to-time they appear in programs --usually the ones
  91. that Ron K and Tony write.  Luckily, I keep my trusty set of A/L books with me
  92. so I can read them whenever I find one of those "goodies".  As I encounter
  93. them, I'll try to explain each in turn. 
  94.      Now, for something easy --COPY.  This is easier than drinking a Tooheys!
  95. COPY is used to copy bits of source code that have been saved as seperate files
  96. on disk.  The stuff is moved in and assembled when the assembler executes (I
  97. might use that for a title). . . 
  98.  
  99.      COPY  "DSK1.PART1" 
  100.      COPY  "DSK1.PART2" 
  101.           etc. 
  102.  
  103.      This column sure causes a great thirst.  Its time for a glass (or four) of
  104. Black Opal Cabernet.  I found a supplier here in the States at long last! 
  105.      With all of the preliminaries out of the way, next time I'm going to take
  106. a whack at writing a sort program.  That ought to be interesting! 
  107.  
  108.