Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 06-04-2009
Member
 
Join Date: May 2008
Posts: 859
Place a uint > 255 in a buffer

I am currently working on frames by developing a network driver, so I follow hexa placed in buffers. I would add the size of my package to the frame in my buffer, here's how I proceeded:

Code:
UINT size = 4512, // I put a fixed value for my test 
memset (pDest, size, sizeof (size)) // I send this value in my buffer pDest 
//then after I send the frame ...
in hex 4512 = 11A0, or when I do my screen I can see that A0:: a0 a0 a0 a0 ff ff ff ff ff ff 45 75 ...

how do I get for example: 00 00 11 a0 ff ff ff ff ff ff 45 ...

I am not very clear, I hope you see my problem, thank you.
Reply With Quote
  #2  
Old 06-04-2009
Member
 
Join Date: May 2008
Posts: 945
Re: Place a uint > 255 in a buffer

The memset () that you give the data value (unsigned char) size with sizeof (size) of characters beginning in pDest table.

If you want your chars have different values

Code:
pDest [3] = size % 256; 
pDest [2] = (size/256) % 256; 
pDest [1] = (size/256/256) % 256; 
pDest [0] = (size/256/256/256) % 256;
(Assuming pDest is indeed a pointer to unsigned char).
Reply With Quote
  #3  
Old 06-04-2009
Member
 
Join Date: Feb 2008
Posts: 194
Re: Place a uint > 255 in a buffer

char * pdest = gnigni

* ((UINT *) pdest) = size;
pdest + = sizeof UINT;

by effectively against the endianness depends cpu, so if you want big endian, you fall on the solution Programmer (but with >> and & in principle, or just a >>)
Reply With Quote
  #4  
Old 06-04-2009
Member
 
Join Date: May 2008
Posts: 859
Re: Place a uint > 255 in a buffer

pDest is PUCHAR type, yes. As against it can not go through having to choose the character of the table? pDest [0], pDest [1 ],... I feel that is what the method of Ashok.M offers but I do not understand how it works?
Reply With Quote
  #5  
Old 06-04-2009
Member
 
Join Date: May 2008
Posts: 945
Re: Place a uint > 255 in a buffer

When I write C++, I do not write assembler. When I write the assembler, not I do not write C++.

I think this operation has a decomposition as in base 256, so I expressed it as:

Code:
size = ((p[0]* 256 + p[1])*256 + p[2])*256 + p[3];
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Place a uint > 255 in a buffer"
Thread Thread Starter Forum Replies Last Post
Setting depth buffer (z buffer) size (16bit / 24bit) NewComer Monitor & Video Cards 4 08-04-2010 05:47 AM
How to Cancel Printer Buffer jennifer Operating Systems 3 04-09-2009 03:21 PM
How can i convert c# 'uint' to 'int' Taipai Software Development 3 02-06-2009 05:20 AM
Buffer of a disk Xan Hardware Peripherals 3 16-03-2009 09:41 AM
I'm having trouble with the buffer monsitj Technology & Internet 4 22-09-2008 07:50 PM


All times are GMT +5.5. The time now is 12:19 AM.