Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Bugs and Fixes

signed | unsigned comparison

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

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria
edx = -100500 as int32;
if (SomeFunction() < edx){}

Because SomeFunction will return eax, it will use the current cast of EAX as the primary cast operator.

edx = -100500 as int32;
if (SomeFunction() < edx) {
  //should check correctly..
}

// or

edx = -100500;
eax = SomeFunction() as int32;
if (eax < edx) {
  //should check correctly..
}

The alternative is that it uses the second operator as a decider for signed/unsigned.

I am planning in a future update to have types specified for functions, but I am not sure how I want to do this yet, I was planning a big update in the near future to have "managed" functions, which will work like high level languages (auto generated assembly) - but this will be after getting everything working perfectly.

0CodErr member
Posts
201
Threads
37
Location
Unknown

How is eax inside SomeFunction?

And how is after return?

SomeFunction may also call some other function in some place.

If we cannot be sure then need to write each time the type of

register. As said above, easy way this is -- to have different operators.

But already implemented other way: uses the status of the first operand.

Then is not such a clear situation.

edx = -100500;
eax = SomeFunction() as int32;
if (eax < edx) {
  //should check correctly..
}

// let this function somewhere far away
// and we do not want to check it every time
function SomeFunction() {
  if (eax < ecx){
  
  }
}
Colin admin
Posts
928
Threads
49
Location
Bulgaria

I'm not clear as to what you mean.. but in this case you can also cast the register.

// let this function somewhere far away
// and we do not want to check it every time
function SomeFunction() {
  if ([int32]eax < ecx){
    // code
  }
}

Also the AS statement is local not global.

0CodErr member
Posts
201
Threads
37
Location
Unknown
Also the AS statement is local not global.

Useful information, did not know before about this.

But anyway, what if it is inline function?

Also i think that signed|unsigned important also here:

eax = al;
eax = ah;
eax = ax;

And let's count how many we have registers? And in 64bit :) It make programming a bit harder because it means that we need always keep in mind type of register or we need always write type of register(i.e. [type]<reg>).

Colin admin
Posts
928
Threads
49
Location
Bulgaria

I don't really understand.... what are you suggesting?

0CodErr member
Posts
201
Threads
37
Location
Unknown

As i asked in [1611]

Maybe need some convention when we use '<reg> as <type>'

Maybe need to define some default type(signed or unsigned) of registers and let in macros keep it at end of macro.

Colin admin
Posts
928
Threads
49
Location
Bulgaria

you mean to keep the casting as global throughout the whole source lifetime?

0CodErr member
Posts
201
Threads
37
Location
Unknown
you mean to keep the casting as global throughout the whole source lifetime?

emm..i think no :)

Maybe not so clear for me and should be documented:

inline function SomeInlineFunction() {
// what kind of type eax here?
// some code  
  eax as dword;
// some code  
}

eax as int32;
SomeInlineFunction();
// what kind of type eax here?