flat assembler
Message board for the users of flat assembler.

 Index > Heap > Did you know?
Author
typedef

Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
in binary : 10 * 10 = 100
In decimal : 10 * 10 = 100
21 Apr 2013, 08:10
nop

Joined: 01 Sep 2008
Posts: 165
Location: right here left there
nop
typedef wrote:
in binary : 10 * 10 = 100
In decimal : 10 * 10 = 100
and did you know
in binary 100 * 100 = 10000
in decimal 100 * 100 = 10000
and did you know...
21 Apr 2013, 09:32
alessandro95

Joined: 24 Mar 2013
Posts: 62
alessandro95
and did you know
chosen any base b "10" is the representation of b in base b?

e.g
10 (base 2)=2 (base 10)
10 (base 3)=3 (base 10)
10 (base 4)=4 (base 10)
etc.

and, whatever is the base 100 repesent b^2
e.g.
100 (base 2)=4=2^2 (base 10)
100 (base 3)=9=3^2 (base 10)
100 (base 4)=16=4^2 (base 10)

so, 10*10=100, the base doesn't matter.

which is equivalent to say that in every base b multiplication and division by b are simply shifts left or right, a concept assembly programmers are quite used to
21 Apr 2013, 10:08
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 17253
revolution
Did you know that 31 Oct = 25 Dec.
So that means that Halloween = Christmas.
21 Apr 2013, 10:21
MHajduk

Joined: 30 Mar 2006
Posts: 6034
Location: Poland
MHajduk
21 Apr 2013, 12:12
AsmGuru62

Joined: 28 Jan 2004
Posts: 1408
AsmGuru62
Nicely named topic.
Here is what I just discovered -- I learn sometimes too! (very cool!)

There is an instruction called CMOVxx.
So, I wanted to use it to load a structure member.
In C it would look something like that:
Code:
```typedef struct
{
UINT    BytesRemain;
UINT    BytesReserved;
PBYTE   RawBuffer;
} DEVICE;

void foo (DEVICE* p)
{
UINT    room = 0;

if (p)
{
room = p->BytesRemain;
}
}
```

Basically, if pointer parameter is not NULL, then load a structure member,
using that same pointer.

So, my equivalent in FASM looked like that:
Code:
```        mov     esi, [p]
xor     eax, eax
test    esi, esi
cmovnz  eax, [esi + DEVICE.BytesRemain]
```

To my surprise CMOVNZ crashes if ESI is NULL.
And it is written in CPU manual too: the memory operand must be valid
even if instruction will NOT MOVE data according to the condition.

Good to know.
21 Apr 2013, 17:01
HaHaAnonymous

Joined: 02 Dec 2012
Posts: 1180
Location: Unknown
HaHaAnonymous
[ Post removed by author. ]

Last edited by HaHaAnonymous on 28 Feb 2015, 20:57; edited 1 time in total
21 Apr 2013, 18:33
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 17253
revolution
AsmGuru62 wrote:
To my surprise CMOVNZ crashes if ESI is NULL.
And it is written in CPU manual too: the memory operand must be valid
even if instruction will NOT MOVE data according to the condition.
Did you know that only X86 has this silly behaviour. ARM does not have this problem, the memory is not touched for a failing condition.
21 Apr 2013, 22:17
HaHaAnonymous

Joined: 02 Dec 2012
Posts: 1180
Location: Unknown
HaHaAnonymous
[ Post removed by author. ]

Last edited by HaHaAnonymous on 28 Feb 2015, 20:57; edited 1 time in total
21 Apr 2013, 22:44
DOS386

Joined: 08 Dec 2006
Posts: 1901
DOS386

http://board.flatassembler.net/topic.php?t=2530 Main FAQ -> Group F
http://board.flatassembler.net/topic.php?t=11626
28 Apr 2013, 14:55
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsCompiler InternalsIDE DevelopmentOS ConstructionNon-x86 architecturesHigh Level LanguagesProgramming Language DesignProjects and IdeasExamples and Tutorials Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou can attach files in this forumYou can download files in this forum