0

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?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
enigma
  • 27
  • 1

1 Answers1

2

LDA accepts a single address in memory, and loads a word from that location. As such, LDA ALPHA-BETA will load a word from address ALPHA-BETA. The second code however will load a word from ALPHA then subtract the word at BETA.

Assume:

ALPHA=103
BETA=100
mem[3]=42
mem[100]=2
mem[103]=3

Now, LDA ALPHA-BETA will be assembled as LDA 3 which will just load the word at address 3, that is 42 in our example. The second code will first load the word at address 103, that is 3, then subtract the word at address 100 that is 2, so the result is going to be 1.

Jester
  • 56,577
  • 4
  • 81
  • 125