Code : Tout sélectionner
typedef unsigned char BYTE;
typedef unsigned int WORD;
#define NULL 0
int abs(int j)
{
return (j >= 0) ? j : -j;
}
BYTE strlen(BYTE *string)
{
BYTE i;
for(i=0; string[i]; ++i);
return i;
}
void printStr_asm(BYTE len, WORD loc, char *str);
void printStr(BYTE x, BYTE y, char *string)
{
printStr_asm(strlen(string),x+y*256 ,string);
}
void printStr_asm(BYTE len, WORD loc, char *str)
{
_asm
ld b,4(ix)
ld e,5(ix)
ld d,6(ix)
ld l,7(ix)
ld h,8(ix)
call #0xbff1
_endasm;
}
void printNum(BYTE x, BYTE y, WORD value)
{
char str[6];
int i;
for(i=4; i>=0; i--) {
str[i] = '0' + value % 10;
value /= 10;
}
str[5] = NULL;
printStr(x,y,str);
}
void clearScreen()
{
_asm
ld a,#0x20
ld b,#144
ld de,#0
call #0xbfee
_endasm;
}
int main(void)
{
int x,y,r,s,t,n,a[9];
clearScreen();
for(n=1;n>0;--n){
r=8;
s=0;
x=0;
do
{
a[++x]=r;
do
{
++s;
y=x;
while(y>1)
{
if (!(t=a[x]-a[--y]) || x-y==abs(t))
{
y=0;
while(!--a[x])
--x;
}
}
} while(y!=1);
if(s==218)
{
printNum(0,1,t);
printNum(0,2,x);
printNum(0,3,y);
printNum(12,1,r);
printNum(12,2,a[x]);
printNum(12,3,a[y]);
}
} while(x!=r);
}
printNum(0,5,s);
}
mais il me retourne 218, et je ne comprends pas pourquoi !
lorsque j'execute le même code en C embarqué j'ai bien le bon résultat






