Finding an efficient shift/add/LEA instruction sequence to multiply by a given constant (avoiding MUL/IMUL)
问题 I'm trying to write a C program mult.c that has a main function that receives 1 int argument (parsed with atoi(argv[1]) ), that is some constant k we want to multiply by. This program will generate an assembly file mult.s that implements int mult(int x) { return x * k; } for that constant k . (This is a followup to Efficient Assembly multiplication) For example: if main() in mult.c gets 14 as argument it may generate (though it is not minimal as later emphasized): .section .text .globl mult