Click here to Skip to main content
15,915,508 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: XP bug: Very slow for large files Pin
Stefan Pedersen14-Jan-03 10:09
Stefan Pedersen14-Jan-03 10:09 
QuestionAny assembly geeks out there? Pin
Chris Losinger13-Jan-03 8:55
professionalChris Losinger13-Jan-03 8:55 
AnswerRe: Any assembly geeks out there? Pin
Rama Krishna Vavilala13-Jan-03 9:00
Rama Krishna Vavilala13-Jan-03 9:00 
GeneralRe: Any assembly geeks out there? Pin
Chris Losinger13-Jan-03 9:11
professionalChris Losinger13-Jan-03 9:11 
AnswerRe: Any assembly geeks out there? Pin
Tim Smith13-Jan-03 9:12
Tim Smith13-Jan-03 9:12 
GeneralRe: Any assembly geeks out there? Pin
Chris Losinger13-Jan-03 9:15
professionalChris Losinger13-Jan-03 9:15 
GeneralRe: Any assembly geeks out there? Pin
Tim Smith13-Jan-03 9:25
Tim Smith13-Jan-03 9:25 
AnswerRe: Any assembly geeks out there? Pin
Chris Richardson13-Jan-03 10:30
Chris Richardson13-Jan-03 10:30 
I'm sure it could be written better, and it doesn't handle DWORD alignment, but it will do the trick. For more information on the Intel instruction set:


http://www.intel.com/design/pentium4/manuals/245471.htm
[^]

void Invert( unsigned char * p_pucData, unsigned long p_ulLen )
{
   __asm
   {
      // Save all registers.
      pusha

      // ecx will be our Counter.
      mov ecx, p_ulLen
      
      // ebx will be our pointer to the current dword or byte.
      mov ebx, p_pucData
      
      // main loop.
      head:
      
      // Check if we're done doing the dwords.
      cmp ecx, 4
      jle tailbytes
      
      // Bitwise NOT the dword pointed to by ebx.
      not dword ptr [ebx]
      
      // Subtract 4 bytes from our counter.
      sub ecx, 4
      
      // Check if we're done.
      cmp ecx, 0
      je end
      
      // Increment the data pointer by 4 bytes.
      add ebx, 4
      
      // Jump to the start of the main loop.
      jmp head
      
      // Leftover bytes loop.
      tailbytes:
      
      // Check if it's done.
      cmp ecx, 0
      je end
      
      // Bitwise NOT the current byte.
      not byte ptr [ebx]
      
      // Increment the data pointer by 1 byte.
      add ebx, 1
      
      // Subtract 1 byte from the counter.
      sub ecx, 1
      
      // Jump to the start of the loop.
      jmp tailbytes

      end:
      
      // Restore all registers.
      popa
   }
}


Chris Richardson

Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
AnswerRe: Any assembly geeks out there? Pin
Chris Losinger13-Jan-03 10:54
professionalChris Losinger13-Jan-03 10:54 
GeneralRe: Any assembly geeks out there? Pin
Chris Richardson13-Jan-03 11:48
Chris Richardson13-Jan-03 11:48 
GeneralRe: Any assembly geeks out there? Pin
Tim Smith13-Jan-03 12:04
Tim Smith13-Jan-03 12:04 
GeneralRe: Any assembly geeks out there? Pin
Chris Richardson13-Jan-03 12:13
Chris Richardson13-Jan-03 12:13 
AnswerRe: Any assembly geeks out there? Pin
nde_plume13-Jan-03 11:48
nde_plume13-Jan-03 11:48 
GeneralWindow position Pin
electronicman_x13-Jan-03 8:18
electronicman_x13-Jan-03 8:18 
Generaltext formatting question. Pin
Maximilien13-Jan-03 8:06
Maximilien13-Jan-03 8:06 
GeneralForget it, I found it ... Pin
Maximilien13-Jan-03 8:11
Maximilien13-Jan-03 8:11 
GeneralChanging MessageBox button captions. Pin
rghin13-Jan-03 7:23
rghin13-Jan-03 7:23 
GeneralRe: Changing MessageBox button captions. Pin
Navin13-Jan-03 7:23
Navin13-Jan-03 7:23 
GeneralRe: Changing MessageBox button captions. Pin
Jim A. Johnson13-Jan-03 7:34
Jim A. Johnson13-Jan-03 7:34 
GeneralRe: Changing MessageBox button captions. Pin
Nish Nishant13-Jan-03 8:46
sitebuilderNish Nishant13-Jan-03 8:46 
GeneralGetting Hardware Profile in Win9x Pin
Jim Hewitt13-Jan-03 7:11
Jim Hewitt13-Jan-03 7:11 
Generalspawning of process Pin
wavk13-Jan-03 6:54
susswavk13-Jan-03 6:54 
GeneralRe: spawning of process Pin
Navin13-Jan-03 7:25
Navin13-Jan-03 7:25 
GeneralAdding right click menu to CDialogBar Pin
Aaron Schaefer13-Jan-03 6:56
Aaron Schaefer13-Jan-03 6:56 
GeneralSaving window state of docking window Pin
Aaron Schaefer13-Jan-03 6:46
Aaron Schaefer13-Jan-03 6:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.