Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Valued Contributor II
21 Views

Usage of '_asm ALIGN 16' inline assembler directive in C/C++ codes

*** Usage of '_asm ALIGN 16' inline assembler directive in C/C++ codes ***
0 Kudos
4 Replies
Highlighted
Valued Contributor II
21 Views

[ Abstract ] Usage of _asm ALIGN 16 inline assembler directive in C/C++ codes to align binary codes to avoid performance problems.
0 Kudos
Highlighted
Valued Contributor II
21 Views

[ Test case 1 ] // C/C++ codes ... RTuint64 uiClock1 = CrtRdtsc(); ... // Note 1: // 00244486 is not a 16-byte aligned address ( 00244486(hex) = 2376838(dec) % 16 = 6 ) // Assembler codes ... 00244486 0F 31 rdtsc ...
0 Kudos
Highlighted
Valued Contributor II
21 Views

[ Test case 2 ] // C/C++ codes ... _asm ALIGN 16 RTuint64 uiClock1 = CrtRdtsc(); ... // Note 2: // 00244486 is not a 16-byte aligned address ( 00244486(hex) = 2376838(dec) % 16 = 6 ) // Assembler codes ... 00244486 EB 08 jmp 00244490 00244488 90 nop 00244489 90 nop ... 0024448E 90 nop 0024448F 90 nop 00244490 0F 31 rdtsc ... // Note 3: // 00244490 is a 16-byte aligned address ( 00244490(hex) = 2376848(dec) % 16 = 0 )
0 Kudos
Highlighted
Valued Contributor II
21 Views

[ Conclusion ] As you can see after addition of _asm ALIGN 16 assembler directive in C/C++ source codes, before a call to CrtRdtsc function, an address of a memory ( 0x00244490 ) with opcode for rdtsc instruction ( 0F 31 ) is 16-byte aligned.
0 Kudos