1

so I've come up with the following code thats calculating the required byte / word offset of an array.

    org $1000
NROWS db 3
NCOLS db 3
D2ARR_1 db 0, 0, 0, 0, 0, 0, 0, 0, 0
D2ARR_2 dw 0, 0, 0, 0, 0, 0, 0, 0, 0
byteOffset rmb 1
wordOffset rmb 1
row db 2
column db 2

    org $4000
Main:
    ldaa row
    ldab column
    MUL
    stab byteOffset

    ldaa row
    ldab column
    MUL
    ldaa #2
    MUL
    stab wordOffset

But for some reason the store accumulator b isn't working, I'm debugging in a simulator and the memory location of byteOffset and wordOffset never change. They've been defined using reserve memory byte, as oppose to reserve storage, which I believe is correct (I've tried both) But can't seem to figure out what the problem is as to why it's not storing. The value is correct in b but the stab line is simply doing nothing.

In my debug the command being executed is

4007  STAB  $101d

with accumulator B containing the value 4 and memory location 101d being completely free and writable.

Any help would be appreciated,

Thanks

Lundin
  • 195,001
  • 40
  • 254
  • 396
Belgin Fish
  • 19,187
  • 41
  • 102
  • 131
  • You have two stab instructions, first and second. Which one are you complaining about? What you state is in B is 4, which implies you are talking about the first. What is it about the instruction that you think is "not working"? What's the specific evidence that it is not working? (It looks to me like your program would place "4" in memory location "byteOffset" and "8" in memory location "wordoffset". Is that not what it does? – Ira Baxter Jan 31 '14 at 07:36
  • 2
    Not related to your problem: Its been along time since I've coded on an 6811/12, but, IIRC, are there not ASLB and ROLA instructions? If so, the sequence "LDA #2/MUL" could equivalently be done by "ASLB,ROLA", with both fewer instruction bytes (typically important in small machines) and less time (2 clocks vs a MUL which ought to take 8 clocks) . – Ira Baxter Jan 31 '14 at 07:39
  • @Ira Baxter Neither work, and as I stated neither are setting the memory location as I saw through debug. I didn't think of the second method you suggested though, I will see if I can get the code working using that method. – Belgin Fish Jan 31 '14 at 13:52

0 Answers0