Author Topic: Bug Easycode struct problem BITMAPFILEHEADER  (Read 1953 times)

costycnc

  • Regular Member
  • *
  • Posts: 3
Bug Easycode struct problem BITMAPFILEHEADER
« on: November 13, 2014, 08:00:46 AM »
I see when create a structure first parameter  must be Dword for functioning....
If first parameter is declared word ... this parameter keep 4 octets and write 2 octets
Second parameter is written after 4 octets ... even if the first parameter is declared word

Example:



TEST Struct

Param1 DWord  ?
Param2 DWord  ?

TEST ENDS


Local pertest:TEST

mov pertest.Param1, "AA"
mov pertest.Param2, "BB"

Result of this struct  is : "A","A",0,0,"B","B"  and will be this ... "A","A","B","B"....  right?
Is bug?


Thanks !






guga

  • Moderator
  • Member
  • *****
  • Posts: 826
  • Assembly is a state of art.
    • RosAsm
Re: Bug Easycode struct problem BITMAPFILEHEADER
« Reply #1 on: August 07, 2015, 12:55:11 PM »
Hi costycnc

Not sure, if i understood. Which syntax is this?

It is not for rosasm.
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

rsala

  • Member
  • **
  • Posts: 247
    • Easy Code
Re: Bug Easycode struct problem BITMAPFILEHEADER
« Reply #2 on: August 07, 2015, 04:23:39 PM »
Hi costycnc,

That is probably because the alignment. Try this:

TEST Struct 2   <-- This makes the structure to be word aligned

Param1 Word  ?
Param2 Word  ?

TEST ENDS

Regards.
EC coder

dedndave

  • Member
  • *****
  • Posts: 8749
  • Still using Abacus 2.0
    • DednDave
Re: Bug Easycode struct problem BITMAPFILEHEADER
« Reply #3 on: August 07, 2015, 07:32:42 PM »
for one thing, when you enclose text in immediate data, the letters are reversed
for another thing, when you write a DWORD, but specify less than 4 letters, the upper bytes are 0's
Code: [Select]
    mov     dwValue,'ABCD'   ;writes 'DCBA'
    mov     dwValue,'AB'     ;writes 'BA',0,0, assuming dwValue is a DWORD

the original post is from last year   :biggrin:
it may not have gotten much attention, because we thought it had to do with EasyCode syntax - lol

ToutEnMasm

  • Member
  • *****
  • Posts: 1189
    • EditMasm
Re: Bug Easycode struct problem BITMAPFILEHEADER
« Reply #4 on: August 08, 2015, 02:29:11 AM »
Quote
I see when create a structure first parameter  must be Dword for functioning....
If first parameter is declared word ... this parameter keep 4 octets and write 2 octets
Second parameter is written after 4 octets ... even if the first parameter is declared word

WRONG !
The structure need to be align to work,that all.
Try to modify it is the badest way.
I search a little and give you the answer
 
Quote
;Include pshpack2.SDK
 DEFALIGNMASM TEXTEQU  <WORD>

;ECHO   region Desktop Family
IF  WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)

BITMAPFILEHEADER   STRUCT DEFALIGNMASM
   bfType WORD ?
   bfSize DWORD ?
   bfReserved1 WORD ?
   bfReserved2 WORD ?
   bfOffBits DWORD ?
BITMAPFILEHEADER      ENDS
correct syntax
Quote
BITMAPFILEHEADER   STRUCT WORD
   bfType WORD ?
   bfSize DWORD ?
   bfReserved1 WORD ?
   bfReserved2 WORD ?
   bfOffBits DWORD ?
BITMAPFILEHEADER      ENDS

Fa is a musical note to play with CL