CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 41

Threaded View

  1. #8
    Join Date
    Jan 2009
    Posts
    1,689

    Re: Data Type Conversion

    Does anyone see the bus error? I hate writing 32-bit assembly on a 64-bit machine:

    Code:
    inline void Assembly(){
        __asm__ __volatile__(
    	    "  movl $1000000, %%ecx		  ;\n"	   //put the size of the table in here, don't reference it
    	    "  myloop:				  ;\n"	   //beginning of my loop
    	    "	  movb 12(%0), %%ah	  ;\n"	   //char 4
    	    "	  movb 8(%0), %%al	  ;\n"	   //char 3
    	    "	  shl $16, %%eax	  ;\n"	   //can't access high bits directly, so shift these there for now
    	    "	  movb 4(%0), %%ah	  ;\n"	   //char 2
    	    "	  movb (%0), %%al	  ;\n"	   //char 1
    	    "	  movl %%eax, (%1)	  ;\n"	   //push it out to the destination
    	    "	  add $4, %1		  ;\n"	   //move the dst ptr by 4 because we did 4 ata  time
    	    "	  add $16, %0		  ;\n"	   //move the src ptr by 16
    	    "  loop myloop			  ;\n"	   //loop until ecx is zero
    	    :							   //No output
    	    :  "r" (src),					   //Let CGG decide what registers to assign these to
    		  "r" (dst)					   //Let GCC decide what registers to assign these to
    	    :  "eax", "ecx"					   //these two get explicitly clobbred
    	    );
    }
    It runs fine for small arrays, but once I try doing one over 1000, it starts throwing bus errors.
    Last edited by ninja9578; May 14th, 2010 at 10:13 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured