Terraspace / UASM

UASM - Macro Assembler
http://www.terraspace.co.uk/uasm.html
Other
214 stars 47 forks source link

Error A2237: Constant value too large #205

Open mrfearless opened 1 month ago

mrfearless commented 1 month ago

Just in case it wasn't on your radar to have a look at, large immediate values in uasm64 throw an Error A2237

for example when using AND or some other instruction with say 8000000000000000h, will stop the assembly.

As mentioned here: https://masm32.com/board/index.php?topic=10026.0

Thanks.

mrfearless commented 1 month ago

Just to add to this, I believe it is any value greater than a 32bit value that triggers this error in UASM64. I had a look at the code a few weeks ago to see if I could track down the area that was issuing the error and think its in the parser.c, maybe the switch case statements that dont have a case 8 for qword size which emits the INVALID_OPERAND_SIZE? But I could be wrong.

john-terraspace commented 1 month ago

` ;mov rax, 8000000000000000h ;ok => valid 48 B8 00 00 00 00 00 00 00 80 movabs rax, 0x8000000000000000 ;and rax, 8000000000000000h ;ok => Error A2237: Constant value too large: 800000000000000h ;test rax, 800000000000000h ;ok => Error A2237: Constant value too large: 800000000000000h ;test rax, 8000000000000000h ;ok => Error A2237: Constant value too large: 800000000000000h

test rax, 80000000000000000h mov rax, 80000000000000000h
`

The first 4 examples work, only MOV supports 64bit immediates, AND/TEST etc do not. The last two fail silently because the immediate is > 64bit which the parser/tokenizer don't even see.

john-terraspace commented 1 month ago

` or rax, 0xffffffff0 ;ok => Error A2237: Constant value too large: 800000000000000h

or rax, 8000000000000000h ;ok => Error A2237: Constant value too large: 800000000000000h

mov rax, 8000000000000000h ;ok => valid 48 B8 00 00 00 00 00 00 00 80 movabs rax, 0x8000000000000000

and rax, 8000000000000000h ;ok => Error A2237: Constant value too large: 800000000000000h

test rax, 800000000000000h ;ok => Error A2237: Constant value too large: 800000000000000h

test rax, 8000000000000000h ;ok => Error A2237: Constant value too large: 800000000000000h

test rax, 80000000000000000h ;ok => Error A2237: Constant value too large: 800000000000000h

mov rax, 80000000000000000h ;ok => Error A2237: Constant value too large: 800000000000000h

` Working now in 2.57 including >64bit case.