what is faster in asm
Posted: Tue Apr 10, 2007 3:16 am
for my interrupt handler routines i have a question regarding some asm statements
here is my code
this will define the functions isrDivideByZero and wrapper_isrDivideByZero my question is regarding the leaq statement. When an interrupt service routine does not have an error code i will use leaq $-8(%rsp), %rdi otherwise leaq (%rsp), %rdi
is this faster then using the movq %rsp, %rdi; addq $-8, %rdi alternative?
here is my code
Code: Select all
#define wrapper(x) extern "C" void x(isr_stack_frame*); \
extern "C" void wrapper_##x(void); \
asm volatile (".align 0x10;" \
"wrapper_"#x": " \
"leaq (%rsp), %rdi;" \
"call "#x"; iretq" \
)
#define vector(x) (vintpc)wrapper_isr##x
#define interrupt(x) dummy(void); wrapper(isr##x); void isr##x
void interrupt(DivideByZero)(isr_stack_frame * frame) {
frame = (isr_stack_frame *)((vintp)frame - 8);
printf("#DivideByZero\n");
printf("- errorCode : %x\n", frame->errorCode);
printf("- returnInstructionPointer: %x\n", frame->returnInstructionPointer);
printf("- returnCodeSelector : %x\n", frame->returnCodeSelector);
printf("- flags : %x\n", frame->flags);
printf("- stackPointer : %x\n", frame->stackPointer);
printf("- stackSelector : %x\n", frame->stackSelector);
for(;;);
}
is this faster then using the movq %rsp, %rdi; addq $-8, %rdi alternative?