I have a fairly simple question regarding assembly language. We are using SIC/XE architecture which is basically make believe and for educational purposes only, but does follow the common conventions of other architectures. Now for my question and first thoughts on the answer.
assume that the symbols ALPHA and BETA are labels in a source program. What is the difference between the following two sequences of statements?
A.) LDA ALPHA-BETA
B.) LDA ALPHA
SUB BETA
Just for clarity, LDA loads data into register A, which is used for arithmetic operations. And an operation like SUB, as seen here, or ADD, works on register A by default without having to declare it.
Now, at first glance, I am assuming both A and B are equivalent. My logic is pretty straightforward. Load into A the difference of ALPHA and BETA, or alternatively load into A, ALPHA, then subtract from ALPHA in register A, BETA. Which seems to me accomplishes the same exact thing? Am i missing some trivial detail or is it really as simple as it looks?
LDA
accepts a single address in memory, and loads a word from that location. As such,LDA ALPHA-BETA
will load a word from addressALPHA-BETA
. The second code however will load a word fromALPHA
then subtract the word atBETA
.Assume:
Now,
LDA ALPHA-BETA
will be assembled asLDA 3
which will just load the word at address3
, that is42
in our example. The second code will first load the word at address103
, that is3
, then subtract the word at address100
that is2
, so the result is going to be1
.