0

Can someone help me understand this question that I have on a handout. What is the result in Accumulator A of the following code

LDAA #$3B ______________

and

ORAA #$23 ______________

I understand that the first one says Load in Accumulator A the hex 3B in immediate mode. And the second is to OR in Accumulator A the hex 23 in immediate mode. The second one is more confusing because I don't know what to OR it with.

Any help would be appreciated!

Martin Rosenau
  • 17,897
  • 3
  • 19
  • 38
Val
  • 9
  • 5
  • Is that [tag:intel-8080]? Regardless, presumably you're supposed to assume that the instructions run one after the other, so you already know the starting value of the accumulator before the ORAA. – Peter Cordes Mar 10 '19 at 03:52
  • It's for the Freescale HCS12 or the original M68HC12 – Val Mar 10 '19 at 04:06
  • I think it's sequential since no other values are given beforehand. Thank you for responding! – Val Mar 10 '19 at 04:10

1 Answers1

2

Well, assuming they're sequential instructions, you know what the value of A is before the OR:

LDAA #$3B --> 3b
ORAA #$23 --> 3b or'ed with 23

If they're not sequential, the answer is simply "whatever A was before but with bits five, one and zero set to 1 (counting bits starting at zero from the least significant end)".

I think it's probably the former, simply because that voluminous essay I had to write above for the alternative possibility, won't easily fit into the answer area provided :-)

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
  • Thank you for the response! If understand correctly, the initial value is simply 3B since we have no value given before that. And we go from there by Or'ing, And'ing, EOR'ing (which come later), etc. – Val Mar 10 '19 at 04:12
  • @Val: `ldaa`-immediate doesn't depend on the old value of the accumulator; it's write-only. (Unlike the later 2-input instructions). That's *why* they started the sequence with an instruction that doesn't read the accumulator. – Peter Cordes Mar 10 '19 at 04:18
  • Just to clarify, @Val, the value after the `LDAA` is `3b` no matter *what* was in `A` before-hand. Load instructions, unlike bit manipulation instruction like `or`, replace whatever was there totally. – paxdiablo Mar 10 '19 at 04:20