flat assembler
Message board for the users of flat assembler.
Index
> Main > 'Numbers in the expression are treated as decimal' |
Author |
|
revolution 13 Feb 2012, 04:44
Yes. You can edit the source code so the the numbers are always interpreted as hex. It is non-standard though so if you upload code to here, or download code from here, then it will assemble differently for everyone else.
|
|||
13 Feb 2012, 04:44 |
|
shutdownall 13 Feb 2012, 16:47
fwd wrote:
This is not a good idea and will not be compatible to other assemblers. Interpreting hex values is done by one of three notations (FASM accepts all): 0Ah 0xA $A Try to use find&replace like ',0' with ,'0x0' or [0 with [0x0 or something similar. Maybe have to do something by hand but never heard about interpreting hex values as DEFAULT. |
|||
13 Feb 2012, 16:47 |
|
revolution 13 Feb 2012, 16:58
OP also never stated what syntax to use to change the default hex base to decimal.
Maybe 0x<digits> now becomes decimal? |
|||
13 Feb 2012, 16:58 |
|
LocoDelAssembly 13 Feb 2012, 17:16
I believe the OP is looking for the RADIX equivalent of MASM (and TASM?) in fasm. None exists, and using macros and strucs to emulate this would be really hard if not impossible.
|
|||
13 Feb 2012, 17:16 |
|
fwd 13 Feb 2012, 18:04
revolution wrote: Yes. You can edit the source code so the the numbers are always interpreted as hex. It is non-standard though so if you upload code to here, or download code from here, then it will assemble differently for everyone else. I've looked over \SOURCE\EXPRPARS.INC to find what looks like some functions I'd need to edit (get_number -> get_hex_number, etc.), but this is the first time I've looked at any of the source. shutdownall wrote:
I'm not concerned about portability / compatibility between assemblers. shutdownall wrote: Try to use find&replace like ',0' with ,'0x0' or [0 with [0x0 or something similar. Maybe have to do something by hand but never heard about interpreting hex values as DEFAULT. Finding & replacing is less feasible than editing FASM's source - less desirable, at least. revolution wrote: OP also never stated what syntax to use to change the default hex base to decimal. I don't need decimal at all (if it makes the task of editing the source any easier). LocoDelAssembly wrote: I believe the OP is looking for the RADIX equivalent of MASM (and TASM?) in fasm. None exists, and using macros and strucs to emulate this would be really hard if not impossible. I have no idea what that is, so probably not. Seems to me that loading numbers as hexadecimal would be less work for the assembler than having to convert from decimal to hex first. I'll poke around the source files more, but if anyone's gone down this path before, or has more expertise than I do (everyone here), I'd appreciate any help. |
|||
13 Feb 2012, 18:04 |
|
LocoDelAssembly 13 Feb 2012, 18:36
Quote: Seems to me that loading numbers as hexadecimal would be less work for the assembler than having to convert from decimal to hex first. About RADIX, it allows you to specify the default base for numbers, so using RADIX 16 at the beginning of the source would do what you want (but this is not available in fasm). |
|||
13 Feb 2012, 18:36 |
|
revolution 13 Feb 2012, 18:52
Hex base is awkward because of the ASCII character layout with the gap between '9' and 'A'. Decimal is simpler with the 0-9 all together and a common x10 factor for each successive digit.
However, it should matter little how much work the assembler has to do to deal with number conversion. Unless you are assembling multi-gigabyte files on a 24/7 basis, and somehow an extra 0.1% performance enhancement is both measurable and vital, then this should be the least of your thoughts. |
|||
13 Feb 2012, 18:52 |
|
LocoDelAssembly 13 Feb 2012, 19:25
I'm providing the steps to modify EXPRPARS.INC but YOU MUST STILL TEST IT THOROUGHLY.
The modification I made was the following: 1. Cut from pascal_hex_number to get_oct_number (excluding the latter) 2. Pasted just above get_dec_number 3. Cut from pascal_hex_number to get_hex_number (excluding the latter) 4. Pasted just above bad_number 5. Modified "je bad_number" (from pascal_hex_number) into "jne get_hex_number" After doing that, this code: Code: format pe console include 'win32ax.inc' cinvoke printf, fmt, 12345, 12345 cinvoke system, cmd invoke ExitProcess, 0 fmt db "Testing default base: %u %x", 0a, 0 cmd db "pause", 0a, 0 align 4 ; Just to be safe data import library kernel32, 'kernel32.dll',\ msvcrt,'msvcrt.dll' include 'api/kernel32.inc' import msvcrt,\ printf, 'printf',\ system, 'system' end data Code: Testing default base: 74565 12345 Press any key to continue . . . revolution: I should have clarified that easier for the processor to deal with.[edit]Ah... I'm forgetting error checking and that IMUL is relatively cheaper nowadays. The one that is easier for the processor (and humans) to deal with is int to hex than int to dec...[/edit] |
|||
13 Feb 2012, 19:25 |
|
shutdownall 14 Feb 2012, 16:49
fwd wrote:
Yes this should be the right place. Just search label number_begin: and change conditional jump after checking if value ends with "h" (which is marked hex value) and make a unconditional jump of it so that FASM thinks there is a h at the end of every (decimal) value to treat it as hexadecimal. You have to increment esi due to missing character, otherwise last character / digit of number will be "cut". By the way, the number is treated backwards from last digit to first digit in this routine. Code: cmp al,'h' ; je get_hex_number inc esi jmp get_hex_number I think this is more easy than the suggested changes of Loco. But there must be a leading zero if number starts with a character. mov al,12 will put 12h into al mov al,1e is valid mov al,ff has to be replaced with mov al,0ff Last edited by shutdownall on 14 Feb 2012, 17:24; edited 3 times in total |
|||
14 Feb 2012, 16:49 |
|
AsmGuru62 14 Feb 2012, 17:18
@fwd: so, you're trying to improve the speed of your code
or the speed of the FASM compiling your code? |
|||
14 Feb 2012, 17:18 |
|
LocoDelAssembly 14 Feb 2012, 18:44
shutdownall, I think your code will perform better than mine since if the number ends with b or d my modification fails to interpret the number as hex. Another modification would be removing all the decimal- and binary-related code since as far as I can see there is no chance for them to be used anymore.
|
|||
14 Feb 2012, 18:44 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.