Posts

Showing posts with the label assembly

Compiler choice of not using REP MOVSB instruction for a byte array move

Image
Compiler choice of not using REP MOVSB instruction for a byte array move I'm checking the Release build of my project done with the latest version of the VS 2017 C++ compiler. And I'm curious why did compiler choose to build the following code snippet: //ncbSzBuffDataUsed of type INT32 UINT8* pDst = (UINT8*)(pMXB + 1); UINT8* pSrc = (UINT8*)pDPE; for(size_t i = 0; i < (size_t)ncbSzBuffDataUsed; i++) { pDst[i] = pSrc[i]; } as such: UINT8* pDst = (UINT8*)(pMXB + 1); UINT8* pSrc = (UINT8*)pDPE; for(size_t i = 0; i < (size_t)ncbSzBuffDataUsed; i++) 00007FF66441251E 4C 63 C2 movsxd r8,edx 00007FF664412521 4C 2B D1 sub r10,rcx 00007FF664412524 0F 1F 40 00 nop dword ptr [rax] 00007FF664412528 0F 1F 84 00 00 00 00 00 nop dword ptr [rax+rax] 00007FF664412530 41 0F B6 04 0A movzx eax,byte ptr [r10+rcx] { pDst[i] = pSrc[i]; 00007FF664412535 88 01 ...

Understanding Assembly basic code

Understanding Assembly basic code pointr: .word pointr mov #pointr,r0 mov pointr,r1 Can someone please explain the difference between the values r0 and r1? From experience with asm syntax for other machines, likely #pointr is an immediate operand (the address of the label), while pointr is a memory source operand, so the 2nd mov is a load instruction. – Peter Cordes Jul 1 at 2:42 #pointr pointr mov pointr: .word pointr creates a label for a word value containing the actual absolute address of pointr . mov #pointr,r0 uses immediate mode to move the value of the pointr label directly to r0. mov pointr,r1 uses relative mode to move the word value at pointr into r1 . Since the word value stored at pointr is the address of pointr itself it has the effect of moving the address of pointr to r1. The values in...