News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Problem with quoted characters

Started by donkey, February 18, 2008, 09:58:12 PM

Previous topic - Next topic

donkey

Hi Jeremy,

I was recently trying to use characters instead of their values in a MOV operation and ran into this problem

mov eax,'A'|('B'<<8)|('C'<<16)|('D'<<24)

Quote from: GoAsm.Exe Version 0.56.4Error!
Line 37 of assembler source file (Testit.asm):-
Unknown mnemonic, instruction, redefinition or directive:-
|('B'<<8)|('C'<<16)|('D'<<24)

While this works fine...

mov eax,41h|(42h<<8)|(43h<<16)|(44h<<24)

Any reason for this ? It makes FOURCC's a bit more cumbersome since I had hoped to use the following macro in my header files...

#IFNDEF MAKEFOURCC
MAKEFOURCC(%1,%2,%3,%4,%5) MACRO
%1 equ  %2|(%3<<8)|(%4<<16)|(%5<<24)
ENDM
#ENDIF


Example...

MAKEFOURCC(FOURCC_RIFF,'R','I','F','F')
mov eax,FOURCC_RIFF


The macro works perfectly well in the header file when only numeric values are used however it fails when characters are used.

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

jorgon

Hi Donkey

No is there no reason for this so I shall look into it soonest.

Author of the "Go" tools (GoAsm, GoLink, GoRC, GoBug)

ChrisLeslie


jorgon

QuoteMust be a tricky one......

Well, I did not expect it to be a tricky one, but when I looked I found that the difficulty is that GoAsm believes it is dealing with a simple character immediate.

Therefore it does not pass the line to the more complex parser which can deal with arithmetic, various brackets etc.

To add this feature therefore, GoAsm would need either to look forward in the line to see if the line is more complex, and if so pass it on to the complex parser (or it could pass on to the complex parser anyway).  Then the complex parser would need to be checked and possibly amended to deal with the complex character immediate including arithmetic.  This would need some careful attention since the complex parser needs to deal with several possible variations.  Also I would not be sure how passing such a line to the complex parser anyway would affect other source code currently dealt with properly.  It is complicated by the varieties of quotes used for Unicode - L', A' and 8'.

In the circumstances I was wondering whether the benefit arising from adding this feature outweighs the work and risk involved in adding it?

Author of the "Go" tools (GoAsm, GoLink, GoRC, GoBug)

wjr

I understand the hesitation - currently calming the code from the ripple effect of many changes to thINC (other delays from bit shifting near record breaking snowfall). From a header file point of view, I can see how having the macro work would simplify things (although the approach I ended up taking for the next update translates this macro, along with a few others).

I suspect that the C implementation-defined multi-character constant involves reverse storage, otherwise an avoidable use of a macro... it is much easier with GoAsm to write A'RIFF', so questionable benefits under the circumstances. However, character constants in C use single quotes, so that could be a method to consider for selecting the complex parser. Assembly language generally has not made this distinction though, so the potential for additional complexity enters... another internal amending thought - if the string routines kept track of the number of bytes just written for a string, then arithmetic operations would be able to look back and verify an 8 to 32/64-bit operand suitable to replace/continue with...