home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.whtech.com
/
ftp.whtech.com.tar
/
ftp.whtech.com
/
articles
/
archives
/
limanews.exe
/
ASSM_3.TXT
< prev
next >
Wrap
Text File
|
2006-10-19
|
6KB
|
113 lines
ORIGINALLY PUBLISHED IN LIMA NEWSLETTER FEBURARY 1994
Assembler Executing #3
By Bob Carmany
Have you ever heard of the "Riddle of the Sphinx"? It goes something like
this: "What walks on four legs in the morning, two legs at mid-day, and three
legs in the evening"? A real puzzler, huh? (answer later). Why did I bring
that up? It's about the way I feel about this next topic -- addressing modes
for registers which is where we will start. Let's have at it!
The first of the five general addressing modes is Register Direct
Addressing. It is very simple (probably why I only had to read it once to
understand it!). It simply takes the contents of one register and copies it to
a second register. After the operation, both registers are identical. It
looks like this:
MOV R10,R1
If R10 contained the value 3, both would contain 3 after the operation.
No worries about this one!
WARNING: THIS NEXT SECTION SHOULD BE READ ONLY WHILE SOBER!!!
The second of the five general addressing modes is Register Indirect
Addressing. Now things start to get complicated! This copies values from one
register to the LOCATION contained in the second register. For example, if R1
(our example) contained a memory location, Indirect Addressing would copy our
value 3 to the address contained in R1 instead of to R1 itself. I'm not sure I
still understand this one fully! Anyway, it looks like this:
MOV R10,*R1
I think of it as moving a value to the location POINTED TO by the second
register.
The third of the general addressing modes is Register Indirect
Autoincrement Addressing. Here's where things start to ge bloody unbearable!
For this example, we will use some hex values (more fun). R10 contains the hex
value A062 and R3 contains the hex value B37E when we start this example. Ok,
this operation moves the value A062 (from R10) to memory location B37E (pointed
to by R1) and then increments R1 by two. So, when the operation js complete,
R1 points to B380. The format looks like this:
MOV R10,*R1+
This is one I have problems with! In fact, it is my justification for
keeping a book on elementary A/L programming next to the computer. Have Ron or
Tony explain it to you at the next meeting.
Whew! Time for an easy one. The fourth general addressing mode is
Symbolic Addressing. It can be used to move a value to a location in general
memory that isn't in a register (ie. a memory location). It can also be used
to move the value to a memory location specified by name. For example:
MOV R10,@@>837C
moves the contents of R10 to the memory location >837C. Or:
MOV R10,@@SCRN
moves the contents of R10 to the memory location named SCRN.
The last of the general addressing modes is Indexed Addressing. This is a
combination of Symbolic Addressing and an address in a register. Let's take a
look at this one! Suppose R10 contains our hex value A062 and R1 contains the
value 0004 and SCRN contains the hex value B37E. The operation:
MOV @@SCRN(R1),R10
Moves the value contained in R10 to address B382 (the memory location in
SCRN - B37E plus 4 -- the value in R1).
I'm beginning to get the idea that I was in fact "sold a blind horse" by
those two --Ron K and Tony McG. All of this has made my head hurt and bsides
that, I'm thirsty! I'll be back in a few minutes to continue this (I hope).
Immediate Addressing is the next one. It is almost as easy as the first
of the general addressing modes that we discussed. There are two instructions
to use with it -- LI (LoadImmediate) and AI -- (AddImmediate). They do exactly
that! Depending on which one you use, they either load or add a value to a
register. For example:
LI R10,5
loads the value 5 into R10. And:
AI R10,4
Adds 4 to the current value of R10. The biggest advantage that they have
is a savings in space when assembled.
The last of the addressing modes that we will attempt for the present is
the PC (Program Counter)-relative Addressing mode. The discussion on this one
is going to be brief --- find an elementary A/L book and read about jump
instructions. There are 13 of them and the easiest thing to do is read about
them at your own pace. I would suggest "Learning TI-99/4A Home Computer
Assembly Language Programming" by Ira McComic. It's the one I use and where I
got most of my examples from.
Now, for my very first attempt at an A/L program. This program runs from
the E/A cartridge because I'm just not up to writing my own standalone routines
for some of this stuff. It is much easier to use the REF table to access the
routines, anyway. This program serves no utilitarian purpose. It just
displays bits of text on the screen.
Oh yes, I only got 7 errors the first time I assembled this lot from the
source code. Most of them were typos but I got some colorful screen displays
at the start when I used the wrong register in the SCRWRT routine for
displaying the text. I got the inspiration for this by examining bits of
commented source code that came my way from Ron K (and his cohorts) in their
undying effort to coerce me into trying A/L in the first place. Anyway, much
to my surprise, this stupid program actually worked after I corrected the typos
and the errant register access. It isn't the most elegant program but maybe
Tony started this way once . . .naw, not a chance!
The answer to the riddle: a man. Crawls on all fours as a baby, walks on
two legs in middle age, and with a cane (three legs) when aged. 'Til next
month!
.PL 1