0

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 ?

2 Answers2

0

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
Drew McGowen
  • 11,471
  • 1
  • 31
  • 57
  • sorry but i just edited the question as earlier it conveyed something else. – sangam.saga Oct 30 '14 at 14:28
  • the address of a6 is 10CC and d3 is 32 (decimal value 2) so muls #5,d5 should be FA and 10CC + FA should 11C6 and i need the content of 11C6 in d4 but that's not what i am getting in d4 – sangam.saga Oct 30 '14 at 14:49
  • `add.b` is adding the contents of the address to register `d3`, is that what you want? If not, you should use `move.b` instead. – Drew McGowen Oct 30 '14 at 14:51
  • let us say a6 is 1000 and d3 is 10 then i want to move to the 1010th position just like accessing the 10th position of an array like array[10]. then i need to copy the content at that position to d4. so in a way i am trying to access the random elements of the array and store them in d4. – sangam.saga Oct 30 '14 at 14:55
0

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.

lvd
  • 793
  • 3
  • 12