我发现g ++编译器几乎在没有任何push / pop指令的情况下生成汇编代码。它仅在进入/退出功能时使用。每次在堆栈中放置字节时,它都会生成2或3条指令,例如:
load('dataset.mat')
Target_Set=zeros(2,400); %Initialize Target array with 0s
%Set dimensions to resize
h = 50;
w = 45;
imgSize = h*w;
for j=1:4
for i=1:10
for k=1:10
Temp_Struct = struct('im',imresize(handwriting(i,j,k).im,[h,w]));
n = 100*(j-1) + 10*(i-1) + k;
P_Set(1:imgSize,n) = reshape(Temp_Struct.im,[imgSize,1]);
%Set Target patterns...
if (j==1) %When character I % Target Patterns...
Line 19========>Target_Set(0,n) = 1; % I J K L
Target_Set(1,n) = 0; % 0 1 0 1
elseif(j==2) %When character J % 0 0 1 1
Target_Set(0,n) = 1;
Target_Set(1,n)=0;
elseif(j==3) %When character K
Target_Set(0,n) = 0;
Target_Set(1,n)=1;
else %When character L
Target_Set(0,n) = 1;
Target_Set(1,n)=1;
end;
end;
end;
end;
仅安装了movl foo, %eax
subl $4, %esp
movl %eax, (%esp)`
。有什么理由吗?是更快还是什么?
谢谢。