Author Topic: Size of records  (Read 2022 times)

Biterider

  • Member
  • *****
  • Posts: 1083
  • ObjAsm Developer
    • ObjAsm
Size of records
« on: October 30, 2021, 06:20:54 AM »
Hi
I am wondering about strange behavior when getting the size of records (bit fields).
The following code
Code: [Select]
TEST_BITS_001 record BITS_001:001
TEST_BITS_008 record BITS_008:008
TEST_BITS_016 record BITS_016:016
TEST_BITS_032 record BITS_032:032
TEST_BITS_064 record BITS_064:064
TEST_BITS_128 record BITS_128:128

%echo $ToStr(%sizeof(TEST_BITS_001))
%echo $ToStr(%sizeof(TEST_BITS_008))
%echo $ToStr(%sizeof(TEST_BITS_016))
%echo $ToStr(%sizeof(TEST_BITS_032))
%echo $ToStr(%sizeof(TEST_BITS_064))
%echo $ToStr(%sizeof(TEST_BITS_128))

returns
Code: [Select]
1
1
2
4
8
128

All of these values seem to be coherent except for the last one, which should be 128/8 = 16.

UASM Version 2.52, 32 bit

Biterider

HSE

  • Member
  • *****
  • Posts: 2499
  • AMD 7-32 / i3 10-64
Re: Size of records
« Reply #1 on: October 30, 2021, 06:55:12 AM »
Hi Biterider!!

Yes, is wrong   :thumbsup:

Code: ( types.c ) [Select]
    /* now calc size in bytes and set the bit positions */

    if ( cntBits > 16 ) {
        if ( cntBits > 64 ) {
            newr->sym.total_size = 128 ;   <<<<<< must say 16
            newr->sym.mem_type = MT_OWORD;
        } else

        if ( cntBits > 32 ) {
            newr->sym.total_size = sizeof( uint_64 );
            newr->sym.mem_type = MT_QWORD;
        } else {
            newr->sym.total_size = sizeof( uint_32 );
            newr->sym.mem_type = MT_DWORD;
        }
    } else if ( cntBits > 8 ) {
        newr->sym.total_size = sizeof( uint_16 );
        newr->sym.mem_type = MT_WORD;
    } else {
        newr->sym.total_size = sizeof( uint_8 );
        newr->sym.mem_type = MT_BYTE;
    }

Regards, HSE.
Equations in Assembly: SmplMath

Biterider

  • Member
  • *****
  • Posts: 1083
  • ObjAsm Developer
    • ObjAsm
Re: Size of records
« Reply #2 on: October 30, 2021, 05:00:17 PM »
Hi HSE
I didn't know you were familiar with the UASM source code.  :thumbsup:
I hope John continues to support UASM.

Biterider

HSE

  • Member
  • *****
  • Posts: 2499
  • AMD 7-32 / i3 10-64
Re: Size of records
« Reply #3 on: October 31, 2021, 01:38:18 AM »
Hi Biterider!

I didn't know you were familiar with the UASM source code.  :thumbsup:
:biggrin: Not really, just a reminder of building assemblers that work with long source code lines.

I hope John continues to support UASM.
UASM developers can't say they don't have time to find the error  :biggrin:

Regards, HSE.
« Last Edit: October 31, 2021, 03:56:26 AM by HSE »
Equations in Assembly: SmplMath

Biterider

  • Member
  • *****
  • Posts: 1083
  • ObjAsm Developer
    • ObjAsm
Re: Size of records
« Reply #4 on: October 31, 2021, 10:01:15 PM »
Hi HSE
I think it might be interesting to know whether the parallel developments (e.g. asmc) that have a common code base are also affected.

Biterider


HSE

  • Member
  • *****
  • Posts: 2499
  • AMD 7-32 / i3 10-64
Re: Size of records
« Reply #5 on: October 31, 2021, 10:55:54 PM »
Hi Biterider!

AsmC I'm using say: 1  1  2  4  1  1  😀

Regards, HSE
Equations in Assembly: SmplMath

Biterider

  • Member
  • *****
  • Posts: 1083
  • ObjAsm Developer
    • ObjAsm
Re: Size of records
« Reply #6 on: November 01, 2021, 02:46:38 AM »
Hi HSE
Thanks for testing. It seems that there is a similar bug in asmc as well.  :rolleyes:
Nidud might be interested in correcting it too.

Biterider

nidud

  • Member
  • *****
  • Posts: 2388
    • https://github.com/nidud/asmc
Re: Size of records
« Reply #7 on: November 01, 2021, 03:16:18 AM »
deleted
« Last Edit: February 26, 2022, 05:17:57 AM by nidud »

Biterider

  • Member
  • *****
  • Posts: 1083
  • ObjAsm Developer
    • ObjAsm
Re: Size of records
« Reply #8 on: November 01, 2021, 05:13:35 AM »
Hi nidud
Thanks for the clarification.
Although your list of results appears to be missing a "2", the case is clear.

Biterider

johnsa

  • Member
  • ****
  • Posts: 893
    • Uasm
Re: Size of records
« Reply #9 on: November 09, 2021, 12:49:22 AM »
Hi,

I've added this fix into the v2.53 branch.
I've been away from UASM for some time, but I do check in here frequently to make sure nothing catastrophic has occurred :)

There are a few other open issues on GitHub for 2.53 I'd like to fix and I'll compile binaries.

Biterider

  • Member
  • *****
  • Posts: 1083
  • ObjAsm Developer
    • ObjAsm
Re: Size of records
« Reply #10 on: November 09, 2021, 01:17:01 AM »
Thank you John!  :thumbsup:
Biterider