Hi folks,

Masm refuses to recognize the string "ffffffffh" as a valid symbol. I'd really like to be able to return -1 from a function. What am I doing wrong? I'd like to be able to return various negative numbers from my program to indicate errors. Help!

Thanks,

-Chalain
Posted on 2002-04-21 03:44:53 by Chalain
use 0FFFFFFFFh.
before a char you have to use a number. so put a 0 infront.
this one works
Posted on 2002-04-21 04:10:26 by adapix
A hex value needs to start with a number, so 55555h or 123h is okay, but ffffh or aaah :) isn't. The solution is simple, just put a zero before it: 0ffffh, 0aaaah.
But you can use negative values as well:

mov eax, -1 ; will assemble as mov eax, 0FFFFFFFFh
mov cl, -1 ; will assemble as mov cl, 0FFh

Thomas
Posted on 2002-04-21 04:11:37 by Thomas
or, if eax is already equal to one, you can use:
neg eax
to make it negative 1.
i think it's smaller?
Posted on 2002-04-21 13:58:18 by jademtech


xor eax, eax
dec eax
Posted on 2002-04-21 14:05:19 by bazik
Actually the shortest is 'or reg, -1':


[b]for eax:[/b]
00000000: 66B8FFFFFFFF mov eax,0FFFFFFFF ;"????"
(6 bytes)

00000006: 6633C0 xor eax,eax
00000009: 6648 dec eax
(5 bytes)

0000000B: 6683C8FF or eax,-001 ;"?"
(4 bytes)

[b]for al only:[/b]
For al, MOV and OR are the same size. The first may be faster in
some cases because to calculate the OR it needs the previous
value of al which slows (earlier?) pentiums down iirc.

0000000F: B0FF mov al,0FF ;"?"
(2 bytes)

00000011: 32C0 xor al,al
00000013: FEC8 dec al
(4 bytes)

00000015: 0CFF or al,0FF ;"?"
(2 bytes)


Thomas
Posted on 2002-04-21 14:36:05 by Thomas
<ModuleEn> $ 83C8 FF        or eax,FFFFFFFF

004017D6 . 83CA FF or edx,FFFFFFFF
004017D9 . B8 FFFFFFFF mov eax,-1
004017DE . BA FFFFFFFF mov edx,-1
004017E3 . 33C0 xor eax,eax
004017E5 . 48 dec eax

You must be in a 16-bit segment?
Subtract all the 0x66's. :)
Posted on 2002-04-21 16:47:28 by bitRAKE
:stupid:
sorry, I simply wrote the opcodes in hiew but forgot to switch to 32-bit mode and didn't look at what I was posting :rolleyes:

Thomas
Posted on 2002-04-21 17:16:39 by Thomas