Reputation: 11
I have this code:
loop2
move.b (a4)+,d3 * moving the morse code array input to d3
muls #5,d3
add.b $d3(a6),d3 * moving the character in morse code array to d4
move.b d3,d4
cmp.b #dot,d4
Here, I am accessing an array starting at a4
. I am taking an element of the array and multiplying it with 5 to move to the memory location where I have the desired element.
a6
represents the starting point of an array which contains certain character.
the statement $d3(a6),d3
wokrs but the code gets faulty
as i know the code d3(a6),d3 should be correct but it show me an error. how should i do it ?
Upvotes: 0
Views: 643
Reputation: 812
In add.b (a6,d3),d3
you probably should declare size of d3 used for address generation: either (a6,d3.w)
or (a6,d3.l)
, depending on what you need. In general case, after a multiplication you have full 32bit result and should use d3.l
. Only if you are sure that the result of multiplication fits 16bit you can use d3.w
.
If you write code specifically for 68020+ (020,030,040,060), also consider using scaled addressing mode like (a6,d3.w*n)
, where n is one of 1, 2, 4, 8.
Upvotes: 0
Reputation: 11706
What's happening is since $
is for specifying hex constants, and d3
is technically a valid hex constant, it's using a6 + 0xd3
as the memory address. What you're trying to accomplish uses different syntax, namely both registers are in the parentheses: (a6,d3)
So the correct statement is:
add.b (a6,d3),d3
Upvotes: 0