Pelles C forum
Assembly language => Assembly discussions => Topic started by: Greenhorn on June 10, 2012, 08:53:20 PM
-
Hi,
if I declare an array with DUP and SIZEOF as the length-expression POASM throws an error:
error: Expected 'identifier'.
For example:
myArray BYTE SIZEOF(someStruct) DUP(0)
It would be a nice feature if POASM supports this. MASM does.
Regards
Greenhorn
-
Hi Greenhorn,
The code below works fine and eax returns 28h which is the correct result :
.386
.model flat,stdcall
option casemap:none
BITMAPINFOHEADER STRUCT
biSize DWORD ?
biWidth DWORD ?
biHeight DWORD ?
biPlanes WORD ?
biBitCount WORD ?
biCompression DWORD ?
biSizeImage DWORD ?
biXPelsPerMeter DWORD ?
biYPelsPerMeter DWORD ?
biClrUsed DWORD ?
biClrImportant DWORD ?
BITMAPINFOHEADER ENDS
ExitProcess PROTO :DWORD
includelib \PellesC\lib\Win\kernel32.lib
.data
myArray BYTE SIZEOF(BITMAPINFOHEADER) dup(0)
x1 dd 10
.code
start:
mov eax,OFFSET x1 - OFFSET myArray
invoke ExitProcess,0
END start
-
Hi Vortex,
hm, that irritates me.
POASM complains about the Name_ member:
IMAGE_AUX_SYMBOL_EX union
struct Sym
WeakDefaultSymIndex DWORD ? ;// the weak extern default symbol index
WeakSearchType DWORD ?
rgbReserved BYTE 12 dup (?)
ends
struct File
Name_ BYTE sizeof(IMAGE_SYMBOL_EX) dup (?)
ends
struct Section_
Length_ DWORD ? ;// section length
NumberOfRelocations WORD ? ;// number of relocation entries
NumberOfLinenumbers WORD ? ;// number of line numbers
CheckSum DWORD ? ;// checksum for communal
Number SWORD ? ;// section number to associate with
Selection BYTE ? ;// communal selection type
bReserved BYTE ?
HighNumber SWORD ? ;// high bits of the section number
rgbReserved BYTE 2 dup (?)
ends
struct
TokenDef IMAGE_AUX_SYMBOL_TOKEN_DEF <>
rgbReserved BYTE 2 dup (?)
ends
struct CRC
crc DWORD ?
rgbReserved BYTE 16 dup (?)
ends
IMAGE_AUX_SYMBOL_EX ends
PIMAGE_AUX_SYMBOL_EX typedef ptr IMAGE_AUX_SYMBOL_EX
So what's wrong in this ?
EDIT:
And here is the IMAGE_SYMBOL_EX structure:
IMAGE_SYMBOL_EX struct
union N
ShortName BYTE 8 dup (?)
struct Name_
Short_ DWORD ? ;// if 0, use LongName
Long DWORD ? ;// offset into string table
ends
LongName DWORD 2 dup (?) ;// PBYTE [2]
ends
Value DWORD ?
SectionNumber SDWORD ?
Type_ WORD ?
StorageClass BYTE ?
NumberOfAuxSymbols BYTE ?
IMAGE_SYMBOL_EX ends
PIMAGE_SYMBOL_EX typedef ptr IMAGE_SYMBOL_EX
Greenhorn
-
Hi Greenhorn,
If it's possible, could you post a code example simulating the issue?
-
Yes of course it is. ;)
I've translated some header files of the Windows SDK 7.1 and these structures are defined in the winnt.inc.
So I think it makes only sense if you have all the files for a proper test.
With JWASM it seems they work fine, but now I want to make them compatible for POASM.
However, the compressed archive is a little bit too big to attach it to a post here.
I hope it is OK for you if I send you a link for download via PM ...
-
Hi Greenhorn,
Removing the brackets seems to solve the problem. Could you try the code portion below?
IMAGE_AUX_SYMBOL_EX union
.
.
.
struct File
Name_ BYTE sizeof IMAGE_SYMBOL_EX dup (?)
ends
.
.
.
IMAGE_AUX_SYMBOL_EX ends
-
Hi Vortex,
yes, that solves the problem although if I don't understand why.
If I look into the documentation the brackets have the highest priority and should just evaluate the expression in it.
It's not a big thing but it would be nice if poasm wouldn't throw an error on this. I often use brackets for better reading, even if it's not always nessecary.
Thank you very much for your help.
Regards
Greenhorn
-
There seem to be a rather big difference between the documented and the actually supported syntax in MASM.
I have used the documented syntax. I can't find any documentation of parenthesis in sizeof.
-
There seem to be a rather big difference between the documented and the actually supported syntax in MASM.
I have used the documented syntax. I can't find any documentation of parenthesis in sizeof.
I am using MASM since '82 (actually earlier on Z80/8080) and I can't remember that this ever was a supported syntax, so I doubt that there is any documentation about using parenthesis...
Ralf
-
I am using MASM since '82 (actually earlier on Z80/8080) and I can't remember that this ever was a supported syntax, so I doubt that there is any documentation about using parenthesis...
I'm still a Greenhorn in coding, especially in assembler. But I just can say that MASM does accept parenthesis in most cases.
However, thanks for paying attention.
Greenhorn
-
But I just can say that MASM does accept parenthesis in most cases.
If an application is accepting/ignoring something doesn't result in this being valid, you will always have to make sure that this complies to the standard.
Many compilers allow non-standard coding, which must be pointed out in the documentation.
-
Well, I have put this on the "maybe" list for the future. Nothing will happen in version 7.00...