- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
*** Usage of '_asm ALIGN 16' inline assembler directive in C/C++ codes ***
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[ Abstract ]
Usage of _asm ALIGN 16 inline assembler directive in C/C++ codes to align binary codes to avoid performance problems.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[ 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
...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[ 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 )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[ 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.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page