Jump to content



- - - - -

Bulls And Cows


  • Please log in to reply
41 replies to this topic

#41 Guest_feanor_*

Guest_feanor_*
  • Guests

Posted 18 January 2006 - 04:57 PM

Because now, there's just one call of TESTNUMBER, replace it by inserting the TESTNUMBER Code directly so you save the call.

hmm.. are you shure that there is no need to call testnumber twice? When I tried to do this soome days ago, there was lost of some repositions, which is of course not acceptable...
upper testnumber called much more rarely then lower, but if not use it at all, we lost some repositions....

this is a code, in which permuteall called:
procedure calculate(ttn:numb);
Var
 i,j,use_zero:byte;
begin
  PermuteAll(ttn,dlina);
  if xit=true then exit;
  while (true) do begin
	 i:=dlina;
	 while (i>0) and (ttn[i]=MaxSgn-dlina+i) do
	  Dec(i);
	 if i=0 then begin tm2:=timerticks;writeln('your answers were');
	  writeln('wrong! (',((tm2-tm1)/50):4:2,'s) ');
	  gotoxy(0,7);
	  write('[EXE] - back to menu');
	 repeat until readkey=ckey_exe;
	 setcrtvisualpage(0);
	 setcrtactivepage(0);
	 exit;end;
	 Inc(ttn[i]);
	 for j:=i+1 to dlina do
	  ttn[j]:=ttn[j-1]+1;
	 PermuteAll(ttn,dlina);
	 if xit=true then begin setcrtvisualpage(0);setcrtactivepage(0);exit;end;
   end;
end;


#42 Marco

Marco

    Casio Freak

  • Members
  • PipPipPipPip
  • 185 posts
  • Location:Dresden, Germany

  • Calculators:
    Casio CFX 9850G (broken),
    Casio CFX 9850GB,
    Casio Algebra FX 2.0 Plus

Posted 18 January 2006 - 06:38 PM

there is no need to insert _all_ testnumber code, cuz time critical only that part what I've posted before. Other part is only I/O part (outputs current number and inputs answer for it).

So make the time critical part and own procedure and integrate it directly, and leave the rest (the IO part) in the original procedure. The point is as now is, TESTNUMBER is called much times (and call needs time), even if the IO part is used seldom.

hmm.. are you shure that there is no need to call testnumber twice? When I tried to do this soome days ago, there was lost of some repositions, which is of course not acceptable...

Normally not, because also when called only once it's executed twice because it's posted directly after the label, not before it:

m1:
procedurecall
if something then exit
...
goto m1
It should do exactly the same like
procedurecall
if something then exit
m1:
...
procedurecall
if something then exit
goto m1

If it doesn't work nevertheless, I just dunno why.

Now for the code that still is missing (* ????, remember :D). The point why we can't use huhn_m's code for testnumber is, that adressing the fields is a bit more complex because there's an array in an array. When constructing the three loops we also must concern the way how we want to adress this fields in order to achieve optimal performance (e.g., which registers to use? which values to load/compute already outside the most inner loop?).
In my code, replace "???? * (see below)" by

cmp al, byte[DI+offset info-16]
jnz @mexit
where MEXIT is below your IO code (the last instruction of testnumber). But as MEXIT must be within the same assembler block, make your IO code in an own procedure (I said this already) and call it from the TESTNUMBER assembler block.

Maybe the code for TESTNUMBER doesn't work because it's long I didn't test it. If so, try a bit by yourself, I commented it this time *g* (so you should guess the principle it's thought to work like, and you will learn a bit assembler by doing so)




2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users