showp+showp)=2;
showp++;
}
/*showp+=intValueLength;*/
}
else if (des[i+1]=='c')
{
/*here show charactor value*/
*(char far*)(0xb8000000+160*10+80+showp+showp)=*(int *)(_BP+6+parap+parap); /*value of _BP and distance address of CALL order*/
*(char far*)(0xb8000000+160*10+81+showp+showp)=2;
parap++;
showp++;
i+=2;
}
else /*direct show char value in string des*/
{
*(char far *)(0xb8000000+160*10+80+showp+showp)=*(int *)(*(int *)(_BP+4)+i);
i++;
showp++;
}
}
else /*also direct to show char in des*/
{
*(char far *)(0xb8000000+160*10+80+showp+showp)=*(int *)(*(int *)(_BP+4)+i);
i++;
showp++;
}
}
}
int pow(int index,int power)
{
int finalValue=1;
if(power==0);
else
{
while(power!=0)
{
finalValue=finalValue*index;
power--;
}
}
return finalValue;
}
二、解决的问题
(1)使用es+偏移地址时,查看指令,段寄存器会独自占一条指令。
(2)Main函数是如何给showchar传递参数的?showchar是如何接受参数的?
答:main函数将参数入栈,showchar用bp寄存器在栈中提取参数。
(3)showchar函数是如何知道要显示多少个字符的?printf是如何知道有多少个参数的?
答:showchar函数是通过第一个参数n知道要显示字符数量的,printf是通过第一个字符串中%c和%d的数量来知道要显示字符数量的。
三、未解决的问题
(1)main函数将char型数据和int型数据入栈是占2个字节,那么如果是float型或者longint型、double型、longdouble型等超过2字节的变量类型怎么办?
(2)Showchar函数将栈中取出的参数赋给al,为什么2是int型也只赋给一个字节的al?如果是更大的参数怎么办?