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

  1. ORIGINALLY PUBLISHED IN LIMA NEWSLETTER MAY 1994
  2.  
  3.                                Assembler Executing . #5. 
  4.                                   By Bob Carmany 
  5.  
  6.      Off we go for another foray into the realm of A/L programming.  We are
  7. going to take a look at some of the instructions that allow you to switch
  8. program control from one segment to another or check and see if specific
  9. conditions exist (like our LOOP example in the last column).  Anyway, the first
  10. lot of material that we are going to look at are those instructions that
  11. compare one item to another. 
  12.  
  13. Name                Code      Comments 
  14. ~~~~                ~~~~      ~~~~~~~~ 
  15.  
  16. Compare Words       C         This compares two values and the comparison 
  17.                               affects the Logical Greater Than, Arithmetic 
  18.                               Greater Than, and Equal Status bits. 
  19.  
  20. Compare Bytes       CB        Same as above except with bytes instead of words 
  21.  
  22. Compare Immediate   CI        Same as above except that while the two previous 
  23.                               instructions used any of the general addressing 
  24.                               modes, this one compares a register to an 
  25.                               immediate addressing operand (it compares words) 
  26.  
  27. Compare Ones Corr   COC       Analyzes specific bits to determine if all are 
  28.                               ones.  If they are, it sets the Equal Status Bit 
  29.                               to one, otherwise it sets it to zero 
  30.  
  31. Compare Zeros Corr  CZC       Sets the Equal Status bit to one if the specific  
  32.                               bits are zero.  Both require two operands and the
  33.                               first one must be the address of the bit mask 
  34.  
  35.      Remember that all of these instruction affect one of the status bits of a
  36. word.  You will hopefully see how this comes together in this next bit.  I
  37. found that it wasn't as difficult as the whole thing was made out to be.  I
  38. reckoned when I read this stuff that when all of these comparisons were being
  39. made, there must be a reason for it and there must be a way to test the various
  40. status bits.  Remember the first article in this series?  Well, we are finally
  41. going to try and pull all of this together right now.  The way that we are
  42. going to do it is by looking and the Jump instructions. 
  43.      Jump instructions are just like the IF . . THEN stuff in Extended BASIC.
  44. They transfer control from one program segment to another if certain conditions
  45. are met (ie. the LOOP example in the last column).  By comparing words and
  46. bytes and setting and testing various status bits, we can re-run sections of
  47. the program or "call" in other pieces of code to be executed.  Yep, you guessed
  48. it --another of those bloody tables! This one should be a lot clearer than the
  49. others.  You might want to have the status bit table from the first article
  50. nearby just in case, though! 
  51.  
  52. Name                Code      Jump Conditions 
  53. ~~~~                ~~~~      ~~~~ ~~~~~~~~~~ 
  54. Jump if Equal       JEQ       EQ=1 
  55.  
  56. Jump if Not Equal   JNE       EQ=0 
  57.  
  58. Jump On Carry       JOC       CY=1 
  59.  
  60. Jump if No Carry    JNC       CY=0 
  61.  
  62. Jump if No Overflow JNO       OV=0 
  63.  
  64. Jump if Odd Parity  JOP       OP=1 
  65.  
  66. Jump if High        JH        L>=1 
  67.  
  68. Jump if High or Eq  JHE       L>=1 or EQ=1 
  69.  
  70. Jump if Low or Eq   JLE       L>=0 or EQ=1 
  71.  
  72. Jump if Low         JL        L>=0 and EQ=0 
  73.  
  74. Jump  Greater Than  JGT       A>=1 
  75.  
  76. Jump if Less Than   JLT       A>=0 and EQ=0 
  77.  
  78. Jump Uncond         JMP       Always regardless of status bits 
  79.  
  80.      The only limitation on the Jump instructions is that the target address
  81. can be no farther than 254 bytes behind the instruction or no more than 256
  82. bytes ahead of the instruction in the program.  You can jump to a name 
  83.  
  84.      JMP   GIZMO 
  85.  
  86.      or to an address 
  87.  
  88.      JMP   45623 
  89.  
  90.      or to an address relative to the instruction by using the dollar sign ($)
  91. to designate the Jump instructions address 
  92.  
  93.      JMP   $+16 
  94.  
  95.      where (in this case) +16 is the displacement in bytes relative to the
  96. address of the Jump instruction itself.  Clear?  I sure hope so! 
  97.      Getting this far in A/L took me a long time.  I have been at it for
  98. several months now and my output to date consists of a series of Limericks that
  99. present themselves on the screen.  Ah, but now I'm getting the hang of this
  100. stuff and the grandiose ideas for programs are starting to come forth (usually
  101. after a couple cold ones, though).  Next time, we will cover "COPY" and the
  102. arithmetic instructions.  Then, it will be off to the "wonderland" of A/L
  103. programming -- that should give Ron and Tony a few good laughs.  Like those two
  104. said to me --- Trust me, A/L is easy! 
  105.  
  106.  @
  107.