Jerome,

Interesting question - and code !

harpo equ $160
chico equ $140
elem_size equ $0c

        clr.l a1                        A1 = 0
        moveq.l #4,d2
        lea harpo(a1),a1                A1 = A1 + $160 = $160
myloop:
        adda.w elem_size,a1             A1 = A1 + (5 * $0c) = $19c
        dbra d2,myloop

        lea chico-4*elem_size(a1),a1            A1 = $140 - $19c + (4 * $0c)
= $140 - $1cc

>> Question: what is the value of a1 at the end ?
Well it could be $ffffff74 ......

>> (I also have my idea, but I do not want to influence yet!)
BUT it depends upong how good your assembler is, does it do expressions
evaluation correctly so that the multiplication is done before the addition,
or does it do it in-line ?
 My answer above shows what it should be (!) assuming correct precedence,
but if the assembler is in-line, then it will be :

(($140 - 4) * $0c) + $19c
($13c * $0c) + $19c
$ed0 + $19c
$106c

So, which answer did you think ?



By the way, you loop around FIVE times because the dbra instruction stops
when the counter reaches -1, so we pass through the loop with d2 = 4,3,2,1
and then 0, adding $0c to a1 each time, so a1 ends up at $160 + (5 * $0c)
which is (reaches for hex calculator ...) $19c.

How did I do ?

Cheers,
Norman.



-------------------------------------
Norman Dunbar
Database/Unix administrator
Lynx Financial Systems Ltd.
mailto:[EMAIL PROTECTED]
Tel: 0113 289 6265
Fax: 0113 289 3146
URL: http://www.Lynx-FS.com
-------------------------------------


This email is intended only for the use of the addressees named above and
may be confidential or legally privileged.  If you are not an addressee you
must not read it and must not use any information contained in it, nor copy
it, nor inform any person other than Lynx Financial Systems or the
addressees of its existence or contents.  If you have received this email
and are not a named addressee, please delete it and notify the Lynx
Financial Systems IT Department on 0113 2892990.

Reply via email to