Curses, I have been found out ! I agree that an assembler *should* evaluate expressions properly, but some don't I'm afraid. QMAC seems to do it, but GWASL (ie the light version) can't assemble the original code for the lea instruction. I can't remember if the original GST non-macro assembler did it correctly or not.
Anyway, as written the code is a bit misleading, in the loop the CONTENTS of ADDRESS elem_size is being added to A1, which on my QPCv3 is zero, so at the end of the loop, A1 is still set to $160, then the lea changes it to $270. Rerunning the code to add #elem_size to A1 each time results in a1 coming out of the loop set to $19C and then changing to �2AC after the final lea. So the code as written sets A1 to $270 on exit. 'Corrected' code sets A1 to $2AC on exit. The expression chico-4*elem_size evaluates to $110 using the QMAC assmebler so it does evaluate correctly. Thanks for correcting my 'interesting' version of how LEA works !! 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 ------------------------------------- -----Original Message----- From: Marcel Kilgus [mailto:[EMAIL PROTECTED]] Sent: Friday, January 17, 2003 11:15 AM To: ql-users Subject: Re: [ql-users] Assembly question Norman Dunbar wrote: > lea chico-4*elem_size(a1),a1 A1 = $140 - $19c + (4 * $0c) > = $140 - $1cc Huh, interesting interpretation of LEA, but I'm afraid your 68k might disagree ;-) The address register is the base (i.e. always added), "chico-4*elem_size" is the offset. And of course an assembler must obey the rule to multiply first, otherwise it's trash. > How did I do ? I'm afraid you have to take that exam again ;-) Ciao, Marcel 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.
