home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.whtech.com
/
ftp.whtech.com.tar
/
ftp.whtech.com
/
articles
/
limanews
/
ASSM_6.TXT
< prev
next >
Wrap
Text File
|
2006-10-19
|
5KB
|
108 lines
ORIGINALLY PUBLISHED IN LIMA NEWSLETTER SEPTEMBER 1994
Assembler Executing . . .
By Bob Carmany
Ever onward! The only problem is that I'm not exactly sure where we're
headed. I think that it might be down the fabled "primrose path". So far,
this hasn't been as bad as I had imagined. I have actually been able to
understand a good portion of what has been going on. It may change soon, but
for the present. . .
Ah yes, arithmetic instructions! All of that "good" stuff --adding,
subtracting, multiplying, etc. I think that I could do without this lot.
After all, I never was all that good in mathematics in school. Luckily, most
of this lot deals with small numbers --the kind that you can use your fingers
and toes to count. Let's go ahead and get started!
Name Op Code Comments
~~~~ ~~~~~~~ ~~~~~~~~
Add Immediate AI Uses a register and immediate addressing
Add Words A Any of the general addressing modes
Add Bytes AB " " " " "
Subtract Words S " " " " "
Subtract Bytes SB " " " " "
Increment INC " " " " "
Increment by Two INCT " " " " "
Decrement DEC " " " " "
Decrement by Two DECT " " " " "
Negate NEG " " " " "
Absolute Value ABS " " " " "
Multiply MPY Any general mode and a register
Divide DIV " " " " "
Most of these arithmetic operations are so simple that they scarcely need
any sort of explanation. That's good because if they were very involved I
wouldn't be able to understand any of this next bit.
AI R7,6 This loads the value 6 into register 7. The Overflow and
Carry bits are affected by additions (remember the JUMP
operators last time?)
A R1,R7 Adds two 16-bit numbers contained in registers 1 and 7.
The sum is compared to zero and the Logical Greater Than,
Arithmetic Greater Than, and Equal status bits are
affected.
AB @GIZMO,R7 This is the same as add words except that two bytes are
added and the Odd Parity bit is affected.
Subtract words (S) and subtract bytes (SB) are the converse of their "add"
complements. The same status bits can be read and JUMP instructions can be
used with them.
The decrement and increment instructions use a constant to either
increment or decrement a value by either one or two. They affect the Carry and
Overflow status bits and when the result is compared to zero, the Logical
Greater Than, Arithmetic Greater Than, and Equal status bits are affected and
can be read. I found they they are commonly used in loops. Remember that?
Negate (NEG) is easy to understand. The easiest way I found to figure it
out was that it changed the sign of the value to the opposite. For example, if
R5 contained the value of -5 :
NEG R5 would leave a value of 5 there instead.
Absolute Value creates the absolute value of a number. The same bits as
the previous examples are affected.
Multiply (MPY) and Divide (DIV) multiply and divide two 16-bit numbers to
create a 32-bit product. The second
operand must be register direct addressing. The 32-bit product spills over
into two adjacent registers.
MPY @GIZMO,R7 would put the most significant 16 bits into register 7 and
the least significant 16 bits into register 8. No status
bits are affected.
Divide does the same thing except that the Overflow status bit is
affected.
There are still a bunch of instructions that I haven't encountered to a
large degree but from time-to-time they appear in programs --usually the ones
that Ron K and Tony write. Luckily, I keep my trusty set of A/L books with me
so I can read them whenever I find one of those "goodies". As I encounter
them, I'll try to explain each in turn.
Now, for something easy --COPY. This is easier than drinking a Tooheys!
COPY is used to copy bits of source code that have been saved as seperate files
on disk. The stuff is moved in and assembled when the assembler executes (I
might use that for a title). . .
COPY "DSK1.PART1"
COPY "DSK1.PART2"
etc.
This column sure causes a great thirst. Its time for a glass (or four) of
Black Opal Cabernet. I found a supplier here in the States at long last!
With all of the preliminaries out of the way, next time I'm going to take
a whack at writing a sort program. That ought to be interesting!