There is no stdint.h file with Watcom 9.01d.Doesn't Watcom C support __int64? If not, then see if it has stdint.h and look for int64_t
This is a discussion on ASM to C language within the C Programming forums, part of the General Programming Boards category; Doesn't Watcom C support __int64? If not, then see if it has stdint.h and look for int64_t There is no ...
There is no stdint.h file with Watcom 9.01d.Doesn't Watcom C support __int64? If not, then see if it has stdint.h and look for int64_t
Watcom C compiler - Wikipedia, the free encyclopedia says that the version 11 added 64-bit support.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
So far as I can tell it's more like (x/256) rounded toward zero.
More specifically: the extension makes edx all 1 or all 0; the shl will put eight zeros at the end and set the carry bit where appropriate; the sbb will either do nothing (if eax was positive) or, if eax was negative will give the same exact upper eight bits only if the lower eight bits are all zero, otherwise it will be one more than that. [For instance, -512 gives -512(+ stuff in the lower eight bits) because of the carry bit, but -511 gives -256(+ stuff).] The shr then cuts out the last eight bits, doing the division.
You totally lost me!!! Any way to break it down to more "simple" term that a novice might understand?So far as I can tell it's more like (x/256) rounded toward zero.
More specifically: the extension makes edx all 1 or all 0; the shl will put eight zeros at the end and set the carry bit where appropriate; the sbb will either do nothing (if eax was positive) or, if eax was negative will give the same exact upper eight bits only if the lower eight bits are all zero, otherwise it will be one more than that. [For instance, -512 gives -512(+ stuff in the lower eight bits) because of the carry bit, but -511 gives -256(+ stuff).] The shr then cuts out the last eight bits, doing the division.
OK, i tried the following piece of code:
And it actually produced the ASM code:Code:y = x/256; y <<= 8; x -= y;
cdq
shl edx 8
sbb eax, edx
Now comes the important question.....Since all this piece of code seems to do is clear edx, what's the purpose of it? Could it actually be used as an error check of some kind or something?
Actually, just using
y = x/256;
yields the three ASM operations (cdq, shl, sbb). But the question still remains as to it's purpose other than clearing edx??????
The purpose of what?
The purpose of the whole thing is to give you x/256, as you mentioned. That's what's left in eax when all is said and done, is x/256. edx gets set to something in the meantime, but that's just extra scratch work that needs to be done in order to compute the answer.
I understand now. Thanks to all who contributed to this thread.The purpose of the whole thing is to give you x/256, as you mentioned. That's what's left in eax when all is said and done, is x/256. edx gets set to something in the meantime, but that's just extra scratch work that needs to be done in order to compute the answer.