function memsetw/memset
function memsetw/memset
hi guys, i m that newbie who ask always for help.
some guys here give me a link to a tutorial which explain how to make your kernel(os if you like) in C. and i really apreched, but this is not why i m writing for :this my problem:
i don't understand what the function of these two function... can any one explain me step by step what is the job of these function and how can code but pls explain how to make but not give the source...
DON'T GIVE ME THE SOURE PLEASE
thanks for your help..
some guys here give me a link to a tutorial which explain how to make your kernel(os if you like) in C. and i really apreched, but this is not why i m writing for :this my problem:
i don't understand what the function of these two function... can any one explain me step by step what is the job of these function and how can code but pls explain how to make but not give the source...
DON'T GIVE ME THE SOURE PLEASE
thanks for your help..
Re: function memsetw/memset
If I understood your question, let me try.
memset is like ...
memset(void *src, byte value, size_t amount);
memsetw(void *src, word value, size_t amount);
those functions just fill up your void *src with your byte value how many bytes your specify at size_t amount;
the diference from memsetw is that memsetw just set with a word " 2bytes value" against 1 byte value from memset.
example. you create an array like byte array[0xff];
and you want to fills up that array with 0xf then
memset(array, 0xf, sizeof (array));
and
to use memsetw, word array[0xff];
memsetw(array, 0xff, sizeof(array));
this is just example,
memset is like ...
memset(void *src, byte value, size_t amount);
memsetw(void *src, word value, size_t amount);
those functions just fill up your void *src with your byte value how many bytes your specify at size_t amount;
the diference from memsetw is that memsetw just set with a word " 2bytes value" against 1 byte value from memset.
example. you create an array like byte array[0xff];
and you want to fills up that array with 0xf then
memset(array, 0xf, sizeof (array));
and
to use memsetw, word array[0xff];
memsetw(array, 0xff, sizeof(array));
this is just example,
- gravaera
- Member
- Posts: 737
- Joined: Tue Jun 02, 2009 4:35 pm
- Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.
Re: function memsetw/memset
Yo,
http://www.cplusplus.com/reference/clib ... ng/memset/
Also, on most standard UNIX installations, you can use "man <posix-or-C-function>" and get a proper listing of its expected behaviour. Do "man memset"
http://www.cplusplus.com/reference/clib ... ng/memset/
Also, on most standard UNIX installations, you can use "man <posix-or-C-function>" and get a proper listing of its expected behaviour. Do "man memset"
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
Re: function memsetw/memset
hi,
with the help of your explication i tried to code my function this way:
correct me if i m wrong... that's what i understand from your explication and those of tutorial..
thanks for help
with the help of your explication i tried to code my function this way:
Code: Select all
unsigned char *memset(unsigned char *dest, unsigned char val, int count)
{
unsigned char *n = (unsigned char*)dest;
while(count-- != 0)
{
*n++ = (unsigned char) val;
}
return dest;
}
thanks for help
-
- Member
- Posts: 255
- Joined: Tue Jun 15, 2010 9:27 am
- Location: Flyover State, United States
- Contact:
Re: function memsetw/memset
If you don't understand simple functions such as memset, I would definitely not recommend OS development as a project.
Re: function memsetw/memset
what i have done is wrong? than correcte me
-
- Member
- Posts: 255
- Joined: Tue Jun 15, 2010 9:27 am
- Location: Flyover State, United States
- Contact:
Re: function memsetw/memset
First off, the more standard prototype for memset is
As for your implementation, there are a lot of redundant typecasts and some other minor things that might affect performance.
Whether it works or not, you won't know until you test it.
Code: Select all
void * memset ( void * ptr, int value, size_t num );
Whether it works or not, you won't know until you test it.
Re: function memsetw/memset
thanks but i m actually reading a tutorial the tutorial is who give me this parameters and give me the order to code it but he don't say what i have to do for these to functions: there is mempcy which is explained well and it 's so easy but the others are not explained.
maybe you forget that i m doing a kernel in C.
maybe you forget that i m doing a kernel in C.
-
- Member
- Posts: 255
- Joined: Tue Jun 15, 2010 9:27 am
- Location: Flyover State, United States
- Contact:
Re: function memsetw/memset
I know you are doing a kernel in C. What I am saying is that you should have enough experience in C before coming to kernel development that you know exactly what memset/memcpy are and how to implement them.
Re: function memsetw/memset
Memset is a function provided by the stdlib so you can't know how the complier implements it. You know only how to use it so the question of Cchedy is good. The C programmer doesn't need to know "how it works". Now in osdev things are a little different, so I can't understand why you have to be so hard with a person which has only asked a question.
@ Cchedy You should provide some portable types in your code like uint8 or size_t. They aren't required but they makes you code easier to be ported to an other architecture.
@ Cchedy You should provide some portable types in your code like uint8 or size_t. They aren't required but they makes you code easier to be ported to an other architecture.
Re: function memsetw/memset
thanks for your help!!!
evry time here when i ask a question they come always to discourage me. you are the seconde person who don't do the same really thanks ...
evry time here when i ask a question they come always to discourage me. you are the seconde person who don't do the same really thanks ...
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: function memsetw/memset
Your logic is flawed: for memset (and the exact same argument holds for memcpy and others), how it does it is identical to what it does: fill n bytes starting from location x with value y. Now, someone who can't reliably write such a function does not meet the requirements to pass a formal C programming course (something code monkeys can do), let alone start with OS development (something code monkeys can not do, only real programmers).Karlosoft wrote:The C programmer doesn't need to know "how it works". Now in osdev things are a little different, so I can't understand why you have to be so hard with a person which has only asked a question.
@OP: Have you ever written something fairly complex like a graphics engine? Are you able to do that using only the manuals and other existing documents, and not asking any live person for help? If the answer is no, then OS development is not (yet) for you.
Re: function memsetw/memset
i m a pro in C++only and with lib QT but C i don't really used for very simple things i never used memcpy or memset/w.
i guess what you will say: you don't have the required to be here... bla bla yaya ...
but you forget that you was like me.
i guess what you will say: you don't have the required to be here... bla bla yaya ...
but you forget that you was like me.
Re: function memsetw/memset
Okay, I am not here to discourage you but why don't you chose C++ as your OSDEV language?Cchedy wrote:i m a pro in C++only and with lib QT but C i don't really used for very simple things i never used memcpy or memset/w.
i guess what you will say: you don't have the required to be here... bla bla yaya ...
but you forget that you was like me.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !