Re: Doubt in memcpy() and memset()
- From: Kenneth Brody <kenbrody@xxxxxxxxxxx>
- Date: Thu, 07 Dec 2006 13:41:00 -0500
Tom St Denis wrote:
Kenneth Brody wrote:
No, but if you are passing an int rather than unsigned char, it
may need to zero-fill the rest of the int before passing it.
unsigned char x;
int ix;
x = 4;
ix = x;
What am I missing?
totally legal conversion provided you keep the values in x to the
portable range.
I may be mistaken here, but...
extern void foo(unsigned char c);
extern void bar(int i);
void foobar()
{
unsigned char c = 'x';
foo(c);
bar(c);
}
Here, the call to foo() can push the single byte of c (if the system
allows one to push a byte), or load the byte into a register and then
push the register. However, the call to bar() requires that the byte
be loaded into a register, while zero-filling the register prior to
pushing it on the stack.
Perhaps something like:
load al,[c]
push eax
call foo
xor eax,eax
load al,[c]
push eax
call bar
(Yes, this example assumes the concept of registers and a stack.)
--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:ThisIsASpamTrap@xxxxxxxxx>
.
- Follow-Ups:
- Re: Doubt in memcpy() and memset()
- From: CBFalconer
- Re: Doubt in memcpy() and memset()
- References:
- Doubt in memcpy() and memset()
- From: Shhnwz.a
- Re: Doubt in memcpy() and memset()
- From: Chris Dollin
- Re: Doubt in memcpy() and memset()
- From: Dead Loop
- Re: Doubt in memcpy() and memset()
- From: Lew Pitcher
- Re: Doubt in memcpy() and memset()
- From: Random832
- Re: Doubt in memcpy() and memset()
- From: Tom St Denis
- Re: Doubt in memcpy() and memset()
- From: Kenneth Brody
- Re: Doubt in memcpy() and memset()
- From: Tom St Denis
- Doubt in memcpy() and memset()
- Prev by Date: Re: I have a doubt
- Next by Date: Re: Random number (1,2,3)
- Previous by thread: Re: Doubt in memcpy() and memset()
- Next by thread: Re: Doubt in memcpy() and memset()
- Index(es):
Relevant Pages
|
|