News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Radix Support?

Started by 2-Bit Chip, December 12, 2009, 08:24:55 PM

Previous topic - Next topic

2-Bit Chip

Why is there no support for changing radix in windows.inc and many others?

Just this simple template below will crash the assembler.

.386
.model flat, stdcall
.radix 16
option casemap:none

include     \masm32\include\windows.inc

include     \masm32\include\kernel32.inc
include     \masm32\include\user32.inc

includelib  \masm32\lib\kernel32.lib
includelib  \masm32\lib\user32.lib

.data

    szPrompt    DB 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x74, 0x68, 0x65, 0x72, 0x65, 0x21, 0x00

.data?

.code

start:

end start

TNick

But this will not, I assume:

.386
.model flat, stdcall

option casemap:none

include     \masm32\include\windows.inc

include     \masm32\include\kernel32.inc
include     \masm32\include\user32.inc

includelib  \masm32\lib\kernel32.lib
includelib  \masm32\lib\user32.lib

.data

    szPrompt    DB 048h, 065h, 06Ch, 06Ch, 06Fh, 020h, 074h, 068h, 065h, 072h, 065h, 021h, 000h

.data?

.code

start:

end start


Nick

2-Bit Chip

Still the same:

Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: win2.asm
\masm32\include\windows.inc(80) : error A2042: statement too complex
\masm32\include\windows.inc(81) : error A2042: statement too complex
\masm32\include\windows.inc(82) : error A2091: index value past end of string
MacroLoop(1): iteration 34: Macro Called From
  ArgCount(5): Macro Called From
   \masm32\include\windows.inc(82): Include File
\masm32\include\windows.inc(82) : error A2008: syntax error : pr23
\masm32\include\windows.inc(83) : error A2091: index value past end of string
MacroLoop(1): iteration 34: Macro Called From
  ArgCount(5): Macro Called From
   \masm32\include\windows.inc(83): Include File
\masm32\include\windows.inc(83) : error A2008: syntax error : ty
\masm32\include\windows.inc(84) : error A2091: index value past end of string
MacroLoop(1): iteration 34: Macro Called From
  ArgCount(5): Macro Called From
   \masm32\include\windows.inc(84): Include File
\masm32\include\windows.inc(84) : error A2008: syntax error : ty
\masm32\include\windows.inc(7686) : error A2089: too many bits in RECORD : fRese
rved
\masm32\include\windows.inc(10933) : error A2089: too many bits in RECORD : BITR
ECORD
\masm32\include\windows.inc(18706) : error A2089: too many bits in RECORD : Name
Offset
\masm32\include\windows.inc(18712) : error A2089: too many bits in RECORD : Offs
etToDirectory
\masm32\include\windows.inc(20309) : fatal error A1016: Internal Assembler Error

_
Assembly Error
Press any key to continue . . .



Now, if I were to change the radix to '10' there would be no errors.

TNick

Did you removed the RADIX statement?

most of the source files are written with default in mind (no use of RADIX option).
so, you may find that
    pr10 ArgCount(10)
line 69 in windows.inc
will have a different meaning if you use a radix of 16, and will become
    pr10 ArgCount(16)


at line 7686
COMRECORD RECORD fCtsHold:1, fDsrHold:1,fRlsdHold:1,fXoffHold:1,fXoffSent:1,fEof:1,fTxim:1,fReserved:25

25 becomes 37, which is out of range.

Hope you've got the point here.
Nick

EDIT:
And, if you need to use this option, then include windows.inc and other that are written with radix 10 in mind, then place .RADIX 16 and start writing your own code like so:


.386
.model flat, stdcall

option casemap:none

include     \masm32\include\windows.inc

include     \masm32\include\kernel32.inc
include     \masm32\include\user32.inc

includelib  \masm32\lib\kernel32.lib
includelib  \masm32\lib\user32.lib

.RADIX 16
.data

    szPrompt    DB 048, 065, 06C, 06C, 06F, 020, 074, 068, 065, 072, 065, 021, 000
   ;similar to this without radix option
   ;szPrompt    DB 048h, 065h, 06Ch, 06Ch, 06Fh, 020h, 074h, 068h, 065h, 072h, 065h, 021h, 000h

.data?

.code

start:

end start

hutch--

Looks like MASM supports changing the .RADIX on the fly. See if this works for you.


; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

main proc

    .radix 16

    print str$(0D)

    .radix 10

    print chr$(13,10)

    ret

main endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤


Here is the reference from the old DOS masm help file.



  Syntax:   .RADIX expression

  See also: Radix Specifiers, PUSHCONTEXT, MASM 5.1 Compatibility

  Description:

     Sets the default radix (base) for integer constants to the value
     of <expression>. The default radix at the start of assembly is 10.

     The .RADIX directive does not affect floating-point constants or
     numbers that have explicit radix overrride tags:

     Tag Base
     H hexadecimal
     O or Q octal
     T decimal
     Y binary
     R floating point

     With a radix of 10 or below, you can use the characters B (b) and D
     (d) as the radix override characters for base 2 and base 10,
     respectively.

     The <expression> must evaluate to a decimal number in the range 2
     to 16 and cannot contain forward references.

     If the current radix in your code is greater than 10 decimal, MASM 6.1
     allows the radix specifiers B (binary) and D (decimal) only in
     compatibility mode. You must change B to Y for binary, and D to T for
     decimal, since both B and D are legitimate hexadecimal values, making
     numbers such as 12D ambiguous. If you want to keep B and D as radix
     specifiers when the current radix is greater than 10, you must specify
     OPTION M510.
    --
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php