From: Wolfgang Kern on

James Van Buskirk posted:

>> So? They are equivalent instructions. Who cares if the op codes are
>> different? Here's what I get when I try that with MASM. Ratch

> C:\>link /dump /disasm ex2.obj
> Microsoft (R) COFF/PE Dumper Version 8.00.40310.39
> Copyright (C) Microsoft Corporation. All rights reserved.


Something seems to be wrong with this interpretation ...
If it shall be 64-bit long mode code then

8B 05 .. should mean 'mov eax, [RIP+..]', same for 40 8b 05 ..

and I miss a 'Zero-page' indicator on 67 A1 ... or at least
an 'A32' for the '67' prefix.

Ok this SIB forms and the 40-rex are valid, but bloated and redundant,
so they may be just used to classify a compiler by disassembling.

A good test anyway.

__
wolfgang

______________________
> Dump of file ex2.obj
>
> File Type: COFF OBJECT
>
> testme2:
> 0000000000000000: A1 9A 78 56 34 12 mov eax,dword ptr
> [00000012345678
> 9Ah]
> 00 00 00
> 0000000000000009: A1 78 56 34 12 00 mov eax,dword ptr
> [00000000123456
> 78h]
> 00 00 00
> 0000000000000012: 67 A1 78 56 34 12 mov eax,dword ptr
[12345678h]
> 0000000000000018: 8B 05 78 56 34 12 mov eax,dword ptr
[12345696h]
> 000000000000001E: 8B 04 25 78 56 34 mov eax,dword ptr
[12345678h]
> 12
> 0000000000000025: 8B 04 65 78 56 34 mov eax,dword ptr
[12345678h]
> 12
> 000000000000002C: 8B 04 A5 78 56 34 mov eax,dword ptr
[12345678h]
> 12
> 0000000000000033: 8B 04 E5 78 56 34 mov eax,dword ptr
[12345678h]
> 12
> 000000000000003A: 40 8B 05 78 56 34 mov eax,dword ptr
[123456B9h]
> 12
> 0000000000000041: 40 8B 04 25 78 56 mov eax,dword ptr
[12345678h]
> 34 12
> 0000000000000049: 40 8B 04 65 78 56 mov eax,dword ptr
[12345678h]
> 34 12
> 0000000000000051: 40 8B 04 A5 78 56 mov eax,dword ptr
[12345678h]
> 34 12
> 0000000000000059: 40 8B 04 E5 78 56 mov eax,dword ptr
[12345678h]
> 34 12
> 0000000000000061: C3 ret
>
> Summary
>
> 62 .code
>
> --
> write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
> 6.0134700243160014d-154/),(/'x'/)); end




From: Wolfgang Kern on

Ratch asked:

>>>> testme:
>>>> 00000000: 01 D8 add eax,ebx
>>>> 00000002: 03 C3 add eax,ebx
>>>> 00000004: C3 ret

>>> So? They are equivalent instructions.
>>> Who cares if the op codes are different?

>> Assembly programmers ....

> Why? Ratch

It can help to determine which tool produced the code.
And even the variant with the set direction bit is easier to
handle for compilers and SMC programmers, sometimes the other
way may show better opportunities (a reason for 'db'-code).

Replace the ADD example with the MOV-doubles, and find LD/ST
instead of MOV.

__
wolfgang



From: Wolfgang Kern on

Wannabee skrev:
....
>>>> Telekinesis ?
>>>> Out of handicapped support:
>>>> Just use two (stereoscope) webcams which follow your eye focus,

>>> Is that what was left of the research I heard of with the diodes
>>> attached to the front of the head in order to move the mouse by
>>> detecting the muscles that would move when you got angry enough?

>> We still have something similar in use, but EMG/EEG-controlled
>> devices joined in the scenario recently and they work astonishing well.

> < http://dsplab.eng.fiu.edu/DSP/Publications/publication.asp?num=60 >

> Like this?

Yeah 1999 ...,
last year they could made a direct brain controlled artificial arm.
Don't know if it's published on net.

> I want one. Then I can program from my bed, and not even having to get up.
> Then I should mostly be rested when coding, and if not sleepy, code.
:)

this things aren't mass-production items and need individual adapting,
so they are quite expensive.
Much cheaper will be Mr.Bean's broom-supported remote-control :)
__
wolfgang




From: Wolfgang Kern on

Ratch wrote:

>>>>> My assertion is that MASM can generate every coding that the
>>>>> CPU is able to execute. Ratch

>>>> We all know that this is possible, but you may know much better than
>>>> a confused newbie which addressing modes need workarounds and what's
>>>> not all in the 'reserved' list.

>>> The reserved word list is documented. What addressing modes need "work
>>> arounds"? Ratch

>> MOV eax,label ;should compile to B8.... mov eax,imm32

> Why? Why should it assemble to an address with relocation by default.
> It makes just as much sense to assemble so as to load the contents at the
> label address. That's what it does. If you want the label address,
> use the OFFSET directive. Either way, a load from a label is not a
> imm32. There is relocation involved. See below.

>> MOV eax,[label] ;should compile to A1.... mov eax,[imm32]

> As so it does, with relocation. A constant does not have relocation.
> See 'R' flags below.

I don't see any need for relocation (except for external referenced labels),
the compiler calculates this immediate value from 'data' or 'code' offset.

>> AFAIK MASM needs either a 'ptr' or an 'offset' directive and may confuse

> MASM can't read your mind. It needs to know the size of the operand so
> as to select the correct op code and check for errors. Doesn't any
> assembler?

Most non-MASM tools 'know' the operand size and need size-casts only
for the few instructions which really need one
INC/DEC[mem]; MOVZX/MOVSX r,r/m; MUL/DIV[mem]; and perhaps a few more.

NASM may show up to three size casts in one instruction, but these
are optional code style modifiers and not mandatory.

>> itself with the brackets and more if 'label' isn't declared as a dword.

> Show me. Ratch

> 00000010 00000003 LAB1 DWORD 3
> 00000000 .CODE
> 00000000 START:
> 00000000 TESTME:
> 00000000 B8 00000010 R MOV EAX,OFFSET LAB1
> 00000005 A1 00000010 R MOV EAX,LAB1
> 0000000A A1 00000010 R MOV EAX,[LAB1]
> 0000000F B8 00000010 MOV EAX,4*DWORD

You just explained it.
Perhaps MASM lacks on direct reference calculation and need to
detour with runtime reallocation ?

Ok, all MASM users will know how to treat their tool ...
But I may continue to recommend FASM/NASM/RosAsm for newbies.
__
wolfgang




From: Ratch on

"Wolfgang Kern" <nowhere(a)never.at> wrote in message
news:fm2om6$osg$2(a)newsreader1.xoc.utanet.at...
>
> Ratch asked:
>
>>>>> testme:
>>>>> 00000000: 01 D8 add eax,ebx
>>>>> 00000002: 03 C3 add eax,ebx
>>>>> 00000004: C3 ret
>
>>>> So? They are equivalent instructions.
>>>> Who cares if the op codes are different?
>
>>> Assembly programmers ....
>
>> Why? Ratch
>
> It can help to determine which tool produced the code.

Who cares?

> And even the variant with the set direction bit is easier to
> handle for compilers

I have no idea what you mean.

and SMC programmers,

What does "SMC" mean? Define your acronyms before you use them, unless
they are so common that everyone knows what they are.

>sometimes the other
> way may show better opportunities (a reason for 'db'-code).

The assembler has to choose one coding or the other. As long as each
instruction is the functionally equivalent and the same length, what more
can a assembler do if several possibilities exist?
>
> Replace the ADD example with the MOV-doubles, and find LD/ST
> instead of MOV.

What is "MOV-doubles" and "LD/ST"? Is that NASM jargon? If so, I
don't know it. Ratch