Warning: Use of undefined constant admin - assumed 'admin' (this will throw an Error in a future version of PHP) in /disk/site/hcc.nl/interessegroep/forth/www/w/cookbook/userauth2/userauth2-permchecklib.php on line 927 Warning: Use of undefined constant admin - assumed 'admin' (this will throw an Error in a future version of PHP) in /disk/site/hcc.nl/interessegroep/forth/www/w/cookbook/userauth2/userauth2-permchecklib.php on line 927 Deprecated: Function create_function() is deprecated in /disk/site/hcc.nl/interessegroep/forth/www/w/pmwiki.php on line 470 Warning: Use of undefined constant admin - assumed 'admin' (this will throw an Error in a future version of PHP) in /disk/site/hcc.nl/interessegroep/forth/www/w/cookbook/userauth2/userauth2-permchecklib.php on line 927 Warning: Cannot modify header information - headers already sent by (output started at /disk/site/hcc.nl/interessegroep/forth/www/w/cookbook/userauth2/userauth2-permchecklib.php:927) in /disk/site/hcc.nl/interessegroep/forth/www/w/pmwiki.php on line 1257 HCC!Forth | ByteForth / OptimaliserendeCompiler
Warning: Use of undefined constant admin - assumed 'admin' (this will throw an Error in a future version of PHP) in /disk/site/hcc.nl/interessegroep/forth/www/w/cookbook/userauth2/userauth2-permchecklib.php on line 927 Deprecated: Function create_function() is deprecated in /disk/site/hcc.nl/interessegroep/forth/www/w/pmwiki.php on line 470 Deprecated: Function create_function() is deprecated in /disk/site/hcc.nl/interessegroep/forth/www/w/pmwiki.php on line 470
HCC!Forth Warning: Use of undefined constant admin - assumed 'admin' (this will throw an Error in a future version of PHP) in /disk/site/hcc.nl/interessegroep/forth/www/w/cookbook/userauth2/userauth2-permchecklib.php on line 927

HCC!forth

ByteForth


6. Optimising compiler

Een prefix met datawoord assembleert zeer compacte code (TO-concept).

Voorbeeld:

\ voor 8051
VARIABLE COUNTER

CLEAR COUNTER wordt
   adr 0 # MOV, [3 bytes]

INCR COUNTER
   adr INC, [2 bytes]


FROM COUNTER
   R0: DEC, @R0 adr MOV, [3 bytes]
\ voor AVR
VARIABLE COUNTER

CLEAR COUNTER wordt
   R16 0 LDI, Y+adr R16 STD, [4 bytes]

INCR COUNTER
   R16 Y+adr LDD, R16 INC,
   Y+adr R16 STD, [6 bytes]

FROM COUNTER
   R16 Y+adr LDD, -X R16 ST, [4 bytes]
\ voor 8051
FLAG END?

CLEAR END? wordt
   bitadr CLR, [2 bytes]

SET END?
   bitadr SETB, [2 bytes]

END?
   C: bitadr MOV, A: ACC: SUBB,
   R0: DEC, @R0 A: MOV, [6 bytes]

	
\ voor AVR
FLAG END?

CLEAR END? wordt
   CLT, bitadr BLD, [4 bytes]

SET END?
   SET, bitadr BLD, [4 bytes]

END?
   R16 CLR, bitadr SBRC, R16 $FF ORI, 
   -X R16 ST, [8 bytes]

EXIT maakt van de laatste call een jump indien mogelijk. Controlestructuren assembleren rechtstreeks machinecode. Edge optimiser: alle woorden en macro's zijn gemerkt met een code waar hun stack-invoer en stack-uitvoer aan af te lezen is. De compiler kan hieruit afleiden hoe hij deze randen kan optimaliseren. Macro's kunnen hierdoor in elkaar geschoven worden. Enkele voorbeelden.

Zonder optimiser:

\ 8051

10 TO COUNTER
   R0: DEC, @R0 10 # MOV,
   adr @R0 MOV, R0: INC, [6 bytes]

BEGIN END? UNTIL
   C: bitadr MOV, A: ACC: SUBB,
   R0: DEC, @R0 A: MOV,
   A: @R0 MOV, R0: INC,
   codeadr JZ, [10 bytes]


\ AVR

10 TO COUNTER
   R16 10 LDI, -X R16 ST,
   R16 X+ LD, Y+adr STD, [8 bytes]

BEGIN END? UNTIL
   R16 CLR, bitadr SBRC, -X R16 ST,
   R16 X+ LD, R16 TST,
   codeadr BREQ, [12 bytes]

Met optimiser:


 10 TO COUNTER
    adr 10 # MOV, [3 bytes]


 BEGIN END? UNTIL
    bitadr codeadr JNB, [3 bytes] 



 10 TO COUNTER
    R16 10 LDI,
    Y+adr R16 STD, [4 bytes]       

 BEGIN END? UNTIL
    bitadr SBRS,
    adr RJMP, [4 bytes]