문제

I am attempting to learn some assembly programming.I came across this code.The macro ENTRY used in the asm file.But I cannot understand what this code actually means?.

#define ALIGN(log) .align(log) ,0x90;

what does 0x90 mean? I am quite new to assembly.and why is ALIGN(5) used instead of typical ALIGN(4) or ALIGN(8)

#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#  define ALIGN_LOG
#endif

#ifdef ALIGN_LOG
#  define ALIGN(log) .align (log), 0x90;
#else
#  define ALIGN(log) .align 1 << (log), 0x90;
#endif

#define ENTRY(name)     \
  ALIGN(5);             \
  .globl name;          \
  .globl _##name;       \
  name: ;               \
  _##name:
~                            
도움이 되었습니까?

해결책

It's a power-of-2 alignment, e.g., ALIGN(4) for 16-byte alignment, ALIGN(5) for 32-byte, etc. The 0x90 specifies the opcode for the NOP instruction - to be used as the padding instructions to achieve the alignment.

There are longer instructions sequences that are also effective NOPs. Many of the assemblers support the more flexible .p2align directive; all recent GNU-based assemblers for example.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top