News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Question about TYPEDEF in masm

Started by StillLearningMasm, April 13, 2019, 07:48:31 PM

Previous topic - Next topic

aw27

Quote from: HSE on April 17, 2019, 02:20:24 AM
Just a bug in ML14


X:\masm32\test>ml crap.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: crap.asm
crap.asm(11) : error A2004: symbol type conflict : CRAP
crap.asm(11) : fatal error A1016: Internal Assembler Error


Not really: crap.asm(11) : fatal error A1016: Internal Assembler Error
At least now you receive a report.  :badgrin:

HSE

Quote from: AW on April 17, 2019, 02:29:09 AM
At least now you receive a report.  :badgrin:

Clearlly the error is "CRAP". Why you want a report?
Equations in Assembly: SmplMath

aw27

Quote from: HSE on April 17, 2019, 02:58:44 AM
Quote from: AW on April 17, 2019, 02:29:09 AM
At least now you receive a report.  :badgrin:

Clearlly the error is "CRAP". Why you want a report?

CRAP is perfectly valid, a pointer to CRAP is 4!  :t The value of pointing to it varies though.  :dazzled:
See:


.486

.model flat, stdcall


printf proto C :ptr, :vararg
ExitProcess proto :dword


label0 typedef ptr CRAP


.data
msg db "Value of a pointer to CRAP is %d, value of pointing to CRAP is %d",10,0

valueofpointingtocrap label0 0

.code


main proc
mov eax, label0
invoke printf, offset msg, eax, valueofpointingtocrap

push 0
call ExitProcess
main endp

end



Output:

Value of a pointer to CRAP is 4, value of pointing to CRAP is 0

hutch--

 :biggrin:

Now come on guys, MASM does not have bugs, it just has many specialised features that you need to understand, get 'em right and it pops object modules, otherwise it pops garbage at you, especially with the later versions.  :P

HSE

Quote from: AW on April 17, 2019, 03:05:50 AM
The value of pointing to it varies though.  :dazzled:
Of course, is a pointer!  :biggrin:

.486
.model flat, stdcall

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\msvcrt.lib

printf proto C :ptr, :vararg
ExitProcess proto :dword

label0 typedef ptr CRAP

CRAP struct
    Emptyness db 0,0,0,0
CRAP ends

.data
msg db "Value of a pointer to CRAP is %d, value of pointing to CRAP is %d",10,0

valueofpointingtocrap label0 offset Atelier

Atelier CRAP <'idea'>

.code
main proc
mov eax, label0
invoke printf, offset msg, eax, valueofpointingtocrap

push 0
call ExitProcess
main endp

end main


Output:
Value of a pointer to CRAP is 4, value of pointing to CRAP is 4206663
:t
Equations in Assembly: SmplMath

jj2007

Quote from: hutch-- on April 17, 2019, 08:40:15 AMNow come on guys, MASM does not have bugs, it just has many specialised features that you need to understand, get 'em right and it pops object modules, otherwise it pops garbage at you, especially with the later versions.  :P

The list of known "features" and their workarounds is long - see also the Discovering the mysteries of MASM features thread. The problem with some of the later versions is that you can never get it right, see e.g. the garbled error message problem.

Then there is a really nasty "feature" of recent ML versions: it produces wrong code, "forgetting" one byte. See the Guaranteed to crash in MASM and MASM 14.0 .if signed comparison bug threads.

Finally, there are UAsm and AsmC, 100% compatible except that they don't have the "features", but attention, they are 5 times as fast as Micros**t MASM, you might get confused and sick by so much speed 8)

hutch--

 :biggrin:

>  the garbled error message problem.

Real Programmers[tm] don't make errors.  :P

> Finally, there are .... ....

But MASM is there as long as Microsoft are there and you get it out of them for free. MASM has seen them come and go like JWASM and other pretenders and like it or lump it, MASM is the most directly used assembler in the world. GAS may come close as a compiler back end.

GabrielRavier

For MASM syntax, I'd agree that MASM is indeed the most popular assembler (mostly because it's the one that comes with the MASM32 SDK), but for coding in assembly in general ? I'd say NASM is at least as popular if not more (on Linux I only ever see people using NASM). And as a compiler back-end, I'd argue GCC/Clang/Icc combined are used more (they all use GAS as their assembler) than MSVC. Moreover, there are plenty of tools that emit output for GAS (or that uses GAS) while I know of almost none that generate output for MASM (not counting MSVC).
My github profile
https://github.com/GabrielRavier

daydreamer

#23
but with latest VC++,you can output your 4 differerent cpu architecture=4 different assemblers for x86,x64,ARM,ARM64?
is ARM,ARM64 also a MASM version?
windows phone development among things its for
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

hutch--

The target OS is the factor here, MASM will not run in Unix versions unless you use a Windows emulator and while there are versions of NASM and GAS that will run in Windows, they have nothing like the support that Windows dedicated assemblers have. NASM is a specialised tool for different platforms while GAS is mainly a compiler back end, I have seen very few write apps in GAS although it can be done in Windows if you set up a linker that will handle resource files.

I have always like GAS, its a no bullsh*t low level assembler and while the Unix guys tend to write AT&T notation in the few places where its used with manual code, it does have the option of Intel notation which then makes it a lot cleaner to use.

GabrielRavier

Quote from: hutch-- on April 18, 2019, 02:12:40 AM
while there are versions of NASM and GAS that will run in Windows, they have nothing like the support that Windows dedicated assemblers have.

I mean, Mingw and Cygwin (and thus the GAS in their toolchains) are both very well supported afaik, and NASM is packaged in a frequently updated package in MSYS2 and Cygwin, so I don't exactly see what you mean here.
My github profile
https://github.com/GabrielRavier

StillLearningMasm

I think I now understand TYPEDEF. Thanks to everyone.

One question.

If TYPEDEF has PROTO in it . Is PROTO used to define multiple variables where  instead  it  would have to use multiple TYPEDEF without PROTO?

hutch--

> I don't exactly see what you mean here.

Its simple, MASM has been around since 1982 and it has a massive user base. Microsoft have supplied it for that long and they have updated it for each OS version. They also supply it with their VC\VS applications since 1999 so it has a massive current distribution. NASM uses its own notation as it is a multi-port tool and GAS originally used AT&T notation as you see in some very low level Unix based code. As a compiler back end, GAS has a high rate of use but only in Unix based systems, in Windows the GCC tool chain is only a small player along side Microsoft's own VC based tools.

Only over recent times was GAS starting to support Intel notation as well as AT&T and that made it far more usable for the massive number of people who understand Intel notation.

aw27

The Chinese team (I am suspecting that only Chineses do MASM at Microsoft) is working on it:

https://developercommunity.visualstudio.com/content/problem/537068/masm-buffer-overflow-with-variable-named-as-fake-t.html


aw27

Quote
We've got a fix for this and I expect it to ship in the 16.2 release.

:t