ORIGINALLY PUBLISHED IN LIMA NEWSLETTER MAY 1994 Assembler Executing . #5. By Bob Carmany Off we go for another foray into the realm of A/L programming. We are going to take a look at some of the instructions that allow you to switch program control from one segment to another or check and see if specific conditions exist (like our LOOP example in the last column). Anyway, the first lot of material that we are going to look at are those instructions that compare one item to another. Name Code Comments ~~~~ ~~~~ ~~~~~~~~ Compare Words C This compares two values and the comparison affects the Logical Greater Than, Arithmetic Greater Than, and Equal Status bits. Compare Bytes CB Same as above except with bytes instead of words Compare Immediate CI Same as above except that while the two previous instructions used any of the general addressing modes, this one compares a register to an immediate addressing operand (it compares words) Compare Ones Corr COC Analyzes specific bits to determine if all are ones. If they are, it sets the Equal Status Bit to one, otherwise it sets it to zero Compare Zeros Corr CZC Sets the Equal Status bit to one if the specific bits are zero. Both require two operands and the first one must be the address of the bit mask Remember that all of these instruction affect one of the status bits of a word. You will hopefully see how this comes together in this next bit. I found that it wasn't as difficult as the whole thing was made out to be. I reckoned when I read this stuff that when all of these comparisons were being made, there must be a reason for it and there must be a way to test the various status bits. Remember the first article in this series? Well, we are finally going to try and pull all of this together right now. The way that we are going to do it is by looking and the Jump instructions. Jump instructions are just like the IF . . THEN stuff in Extended BASIC. They transfer control from one program segment to another if certain conditions are met (ie. the LOOP example in the last column). By comparing words and bytes and setting and testing various status bits, we can re-run sections of the program or "call" in other pieces of code to be executed. Yep, you guessed it --another of those bloody tables! This one should be a lot clearer than the others. You might want to have the status bit table from the first article nearby just in case, though! Name Code Jump Conditions ~~~~ ~~~~ ~~~~ ~~~~~~~~~~ Jump if Equal JEQ EQ=1 Jump if Not Equal JNE EQ=0 Jump On Carry JOC CY=1 Jump if No Carry JNC CY=0 Jump if No Overflow JNO OV=0 Jump if Odd Parity JOP OP=1 Jump if High JH L>=1 Jump if High or Eq JHE L>=1 or EQ=1 Jump if Low or Eq JLE L>=0 or EQ=1 Jump if Low JL L>=0 and EQ=0 Jump Greater Than JGT A>=1 Jump if Less Than JLT A>=0 and EQ=0 Jump Uncond JMP Always regardless of status bits The only limitation on the Jump instructions is that the target address can be no farther than 254 bytes behind the instruction or no more than 256 bytes ahead of the instruction in the program. You can jump to a name JMP GIZMO or to an address JMP 45623 or to an address relative to the instruction by using the dollar sign ($) to designate the Jump instructions address JMP $+16 where (in this case) +16 is the displacement in bytes relative to the address of the Jump instruction itself. Clear? I sure hope so! Getting this far in A/L took me a long time. I have been at it for several months now and my output to date consists of a series of Limericks that present themselves on the screen. Ah, but now I'm getting the hang of this stuff and the grandiose ideas for programs are starting to come forth (usually after a couple cold ones, though). Next time, we will cover "COPY" and the arithmetic instructions. Then, it will be off to the "wonderland" of A/L programming -- that should give Ron and Tony a few good laughs. Like those two said to me --- Trust me, A/L is easy! @