Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Requests and Feedback

Augmented assignment

A community discussion post from the original code:zIRON forum.

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

OK, I have added this to my todo list. Thanks.

0CodErr member
Posts
201
Threads
37
Location
Unknown

Seems that it also not so hard to do:

dword a, b, d;

a = b + d;
a = b - d;
a = b | d;
a = b ^ d;
a = b & d;
a = b >> d;
a = b << d;
a = b * d;
a = b / d;

Can be translated as:

eax = b; eax += d;            a = eax; // uses eax
eax = b; eax -= d;            a = eax; // uses eax
eax = b; eax |= d;            a = eax; // uses eax
eax = b; eax ^= d;            a = eax; // uses eax
eax = b; eax &= d;            a = eax; // uses eax
eax = b; ecx  = d; eax >> cl; a = eax; // uses eax, ecx
eax = b; ecx  = d; eax << cl; a = eax; // uses eax, ecx
eax = b; mul d;               a = eax; // uses eax
eax = b; edx = 0; div d;      a = eax; // uses eax, edx

And yet about

eax and edx changing without the programmer understanding this

Programmer should know that in this case(dividing of dword) after such instructions as 'div' and 'idiv' the remainder stores in 'edx'. And of course 'edx' will changes :)

And 'mul' may also corruptes 'edx'. Also flags are corrupted(even if you do just eax += ebx). But you do not save flags.

My point that such things should be documented. But our documentation still not have needed explanation about it.

0CodErr member
Posts
201
Threads
37
Location
Unknown

Can You add the ability to use?

program RAW_IMAGE 'test';
#set bits 32;

al = CF;
al = PF;
al = ZF;
al = SF;
al = OF;

Currently

Instruction usage is not supported!
Colin admin
Posts
928
Threads
49
Location
Bulgaria

Hmm this I wonder if would better added as macros.

maybe something like...

inline function getCF() {
  setc al
  $return al;
}

al = getCF();

then you can easily use dl = getCF();

which will translate to

setc al
mov dl, al

what do you think?

0CodErr member
Posts
201
Threads
37
Location
Unknown

Is it too hard to implement?

al = CF;

Cause this is more shorter than GetCF().

And just by analogy: if we want to set dl to al we write "al = dl" but not "al = Getdl()"

Colin admin
Posts
928
Threads
49
Location
Bulgaria

setc does not work with al etc, so it means you would physically need to write:

al = CF;
dl = al;

vs

dl = getCF();

But i will consider to inbuild this to automate dl = CF; etc.

Colin admin
Posts
928
Threads
49
Location
Bulgaria

Sorry for very very very late response, but exactly is it you want al = cf to do?

0CodErr member
Posts
201
Threads
37
Location
Unknown
al = cf

Yes, that's what I meant.