Register | Login
Forum Index > Bugs and Fixes > signed | unsigned comparison
Author Message
Pages: 1 2 3 4
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1612] - posted: 2015-02-03 19:17:45
Code:
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.

Code:
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.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1613] - posted: 2015-02-03 20:06:55
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.
Code:
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){
  
  }
}
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1616] - posted: 2015-02-03 22:52:37
I'm not clear as to what you mean.. but in this case you can also cast the register.

Code:
// 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.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1619] - posted: 2015-02-04 18:07:53
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: Code:
eax = al;
eax = ah;
eax = ax;

And let's count how many we have registers? And in 64bit smile 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>smile.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1621] - posted: 2015-02-04 19:09:12
I don't really understand.... what are you suggesting?

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1623] - posted: 2015-02-04 19:15:59
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.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1625] - posted: 2015-02-04 20:48:21
you mean to keep the casting as global throughout the whole source lifetime?

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1626] - posted: 2015-02-04 21:05:00
you mean to keep the casting as global throughout the whole source lifetime?
emm..i think no smile

Maybe not so clear for me and should be documented:
Code:
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?
Pages: 1 2 3 4
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 7 user(s) online. 0 member(s) and 7 guest(s)
Most users ever online was 1046, January 28, 2022, 2:08 pm.


Statistics:
Threads: 225 | Posts: 1848 | Members: 51 | Active Members: 51
Welcome to our newest member, yecate
const Copyright = '2011-2024 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd