Author Topic: error A2071: initializer magnitude too large for specified size  (Read 20033 times)

jj2007

  • Member
  • *****
  • Posts: 8889
  • Assembler is fun ;-)
    • MasmBasic
Re: error A2071: initializer magnitude too large for specified size
« Reply #15 on: March 25, 2014, 10:49:30 AM »
The line no identified (171) points to the - readrec  endp  statement

Now it gets mysterious - there is nothing wrong with that line.
On my PC, the attached source works fine with Masm 6.14, 6.15, 9.0, 10.0 and JWasm.

I added an error check after fopen.

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1209
Re: error A2071: initializer magnitude too large for specified size
« Reply #16 on: March 25, 2014, 11:19:24 AM »
I also cannot find anything wrong anywhere in the source after I commented out the include gwMacros.inc statement. What assembler command line are you using?
Well Microsoft, here’s another nice mess you’ve gotten us into.

GoneFishing

  • Member
  • *****
  • Posts: 1056
  • Gone fishing
Re: error A2071: initializer magnitude too large for specified size
« Reply #17 on: March 25, 2014, 08:07:22 PM »
Last night when I was looking through pgw001's posts I noticed that he uses MS VS as IDE.
My last suggestion is to try assembling the code  in pure batch environment i.e. in QEDITOR
Best

jj2007

  • Member
  • *****
  • Posts: 8889
  • Assembler is fun ;-)
    • MasmBasic
Re: error A2071: initializer magnitude too large for specified size
« Reply #18 on: March 25, 2014, 09:06:47 PM »
Using \Masm32\qeditor.exe could help indeed. I used RichMasm without any problems.

There are several logical errors to fix. Inter alia,

1.
LOCAL cloc  :DWORD                          ; current location variable
is never initialised, and therefore will set the file pointer initially to an arbitrary value ->CRASH.
Test it by commenting out the mov cloc, fseek(hFile,cloc,0)

2. hMem is a local, too, and therefore this will fail in an unpredictable way:
    LOCAL hMem  :DWORD                          ; allocated memory handle
...
   cmp hMem, 0                           ; Check if file open
   jne labGO                           ; Jump if so

You should read The LOCAL variables trap carefully.

TWell

  • Member
  • ****
  • Posts: 748
Re: error A2071: initializer magnitude too large for specified size
« Reply #19 on: March 25, 2014, 09:21:43 PM »
broken rdLine: too
- no null checking
- no output buffer size checking

pgw001

  • Guest
Re: error A2071: initializer magnitude too large for specified size
« Reply #20 on: March 26, 2014, 01:20:37 AM »
Folks, thanks to all for your perseverance

The observation that I use the Visual Studio 2013 IDE and the recommendation I try qeditor.exe proved to be the guiding lights

The code, including the gwmacros.inc file, assembled and linked without errors or warnings using qeditor - I am not sure
what this says about the VS environment albeit I have now copied the code that made up the 'readrec proc' into a different
test harness which subsequently went on to assemble without error under VS.

Again thanks for your contributions and support - should I advise Microsoft?

jj2007

  • Member
  • *****
  • Posts: 8889
  • Assembler is fun ;-)
    • MasmBasic
Re: error A2071: initializer magnitude too large for specified size
« Reply #21 on: March 26, 2014, 04:55:19 AM »
should I advise Microsoft?
Honestly, Santa Claus doesn't exist, and Microsoft doesn't take advice from its clients ;-)

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: error A2071: initializer magnitude too large for specified size
« Reply #22 on: March 26, 2014, 06:22:51 PM »
Again thanks for your contributions and support - should I advise Microsoft?

you can try it, but the success will be questionable. So, let it be.

Gunther
Get your facts first, and then you can distort them.

raymond

  • Member
  • **
  • Posts: 218
    • Raymond's page
Re: error A2071: initializer magnitude too large for specified size
« Reply #23 on: March 27, 2014, 08:21:06 AM »
Quote
labCR:                                 ; CR found
   mov[edi],al                           ; store CR char
   inc edi                              ; incr out pointer
   mov al,[esi]
   inc esi
   cmp al,10                           ; check if LF char
   je labLF

labLF:                                 ; LF found
   mov[edi],al                              ; store LF char
   inc edi                                 ; incr out pointer

Although the above piece of code will not throw an error, it could mean trouble if the CR character is not followed by an LF character. Your intention should be to skip storing the character if it is NOT an LF but your
code simply continues to process that code you would want to skip! :icon_eek:
Whenever you assume something, you risk being wrong half the time.
http://www.ray.masmcode.com/

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1209
Re: error A2071: initializer magnitude too large for specified size
« Reply #24 on: March 27, 2014, 08:35:48 AM »
Honestly, Santa Claus doesn't exist, and Microsoft doesn't take advice from its clients ;-)

They do for the big customers, like the one that requested a Word macro system that can be programmed to silently format your hard drive :biggrin:
Well Microsoft, here’s another nice mess you’ve gotten us into.

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: error A2071: initializer magnitude too large for specified size
« Reply #25 on: March 28, 2014, 01:54:46 AM »
Michael,

They do for the big customers, like the one that requested a Word macro system that can be programmed to silently format your hard drive :biggrin:

but that's the world of the big money, not the normal users world.

Gunther
Get your facts first, and then you can distort them.