Benutzer:FUZxxl/MMIX-Test

aus Wikipedia, der freien Enzyklopädie

Dieser Code entstammt der MMIX-Distribution von Donald Ervin Knuth. Die Datei ist unter dem Namen silly.mms zu finden.

This code comes from the MMIX distribution by Donald Ervin Knuth. The original name of this file is silly.mms.

* A program that exercises all MMIX operations (more or less)
small       GREG   #abc
neg_zero    GREG   #8000000000000000
half        GREG   #3fe0000000000000
inf         GREG   #7ff0000000000000
sig_nan     GREG   #7ff1000000000000
round_off   GREG   ROUND_OFF<<16
round_up    GREG   ROUND_UP<<16
round_down  GREG   ROUND_DOWN<<16
addy        GREG   #7f6001b4c67bc809
addz        GREG   #ff5ffb6a4534a3f7
flip        GREG   #0102040810204080 
ry          GREG
rz          GREG
            LOC    Data_Segment
            GREG   @
Start_Inst  SUB    $4,half,$1
Final_Inst  SRU    $4,half,1
Load_Test   OCTA   #8081828384858687
            OCTA   #88898a8b8c8d8e8f
Jmp_Pop     JMP    @+8
            POP
Load_Begin  TETRA  #5f030405
Load_End    LDUNC  $3,$4,5
Big_Begin   GO     $40,ry,5
Big_End     ANDNL  $40,(ry-$0)<<8+5

            LOC    #100
Main        FCMP   $0,neg_zero,$5
            FCMP   $1,neg_zero,inf
            FCMP   $2,inf,sig_nan
            FUN    $3,sig_nan,sig_nan
            FEQL   $4,$4,neg_zero
            FADD   $5,half,inf
            FADD   $6,half,neg_zero
            FADD   $7,half,half
            FADD   $8,half,sig_nan
            FSUB   $9,half,small
            PUT    rA,round_off
            FSUB   $9,half,small
            FSUB   $9,small,half
            FSQRT  $10,$9
            FSUB   $11,sig_nan,$10
            PUT    rA,round_down
            FSUB   $12,half,half
            FSUB   $12,$20,$21
            FSUB   $12,$20,neg_zero
            PUT    rA,round_up
            SUB    $0,inf,1           % $0 = largest normal number
            FADD   $12,$0,small
            FIX    $12,half
            FIXU   $14,ROUND_DOWN,$9
            FLOT   $15,ROUND_DOWN,addy
            FLOT   $16,ROUND_UP,addy
            NEG    $1,1               % $1 = -1
            FLOT   $17,1
            FLOT   $17,$1
            FLOTU  $18,255
            FLOTU  $18,neg_zero
            FIX    $13,ROUND_NEAR,$18
            SFLOT  $18,ROUND_DOWN,addy
            SFLOT  $19,ROUND_UP,addy
            FSUB   $20,$18,$19
            FSUB   $20,$16,$15
            SFLOT  $20,1
            SFLOT  $20,$1
            SFLOTU $21,$1
            SFLOTU $21,255
            FMUL   $22,neg_zero,inf
            FMUL   $22,half,half
            FMUL   $23,small,$0
            PUT    rE,half
            FCMPE  $24,half,$21
            FCMPE  $24,neg_zero,small
            FCMPE  $24,neg_zero,half
            FCMPE  $24,half,inf
            FEQLE  $24,$15,$16
            PUT    rE,neg_zero
            FEQLE  $24,half,half
            FUNE   $24,half,half
            FSQRT  $25,ROUND_UP,$0
            FDIV   $26,$0,$25
            PUT    rA,$50
            FDIV   $26,$0,$25
            FMUL   $27,$25,$25
            FREM   $28,$9,half
            FREM   $29,$9,small
            FINT   $30,$9
            FINT   $30,ROUND_UP,small
            MUL    $31,flip,flip
            MUL    $32,flip,$1
            MUL    $33,flip,2
            DIV    $32,$32,$1
            DIV    $32,neg_zero,$1
            MULU   $32,flip,$1
            MULU   $31,flip,flip
            GET    $33,rH
            PUT    rD,$33
            DIV    $33,$1,3
            DIVU   $34,$31,flip
            ADD    $35,addy,addz
            FADD   $36,addy,addz
            CMP    $37,$36,$35
            GETA   $3,1F
            PUT    rW,$3
            LDT    $6,Start_Inst
            LDTU   $7,Final_Inst
1H          CMP    $5,$6,$7
            BNN    $5,1F
            INCML  $6,#100           % increase the opcode
            PUT    rX,$6             % ropcode 0
            RESUME                   % return to 1B
1H          BN     $0,@+4*6
            PBN    $0,@-4*1
            BNN    $0,@+4*6
            PBN    $0,@+4*5
            PBNN   $0,@+4*5
            BN     $0,@-4*3
            BNN    $0,@-4*3
            PBN    $0,@-4*3
            PBNN   $0,@-4*3
            BZ     $0,@+4*6
            PBZ    $0,@-4*1
            BNZ    $0,@+4*6
            PBZ    $0,@+4*5
            PBNZ   $0,@+4*5
            BZ     $0,@-4*3
            BNZ    $0,@-4*3
            PBZ    $0,@-4*3
            PBNZ   $0,@-4*3
            BP     $0,@+4*6
            PBP    $0,@-4*1
            BNP    $0,@+4*6
            PBP    $0,@+4*5
            PBNP   $0,@+4*5
            BP     $0,@-4*3
            BNP    $0,@-4*3
            PBP    $0,@-4*3
            PBNP   $0,@-4*3
            BOD    $0,@+4*6
            PBOD   $0,@-4*1
            BEV    $0,@+4*6
            PBOD   $0,@+4*5
            PBEV   $0,@+4*5
            BOD    $0,@-4*3
            BEV    $0,@-4*3
            PBOD   $0,@-4*3
            PBEV   $0,@-4*3
            LDA    $4,Load_Test+4
            GETA   $3,1F
            PUT    rW,$3
            LDTU   $7,Load_End
            LDTU   $6,Load_Begin
1H          CMPU   $8,$6,$7
            BNN    $8,1F
            INCML  $6,#100           % increase the opcode
            PUT    rX,$6
            RESUME                   % return to 1B
2H          OCTA   #fedcba9876543210 % becomes Jmp_Pop
            OCTA   #ffeeddccbbaa9988 % becomes Jmp_Pop
            NEG    ry,addy
            SET    rz,flip
            PUT    rM,addz
            POP
1H          GETA   $4,2B
            SETL   $7,4*11
            GO     $7,$7,$4
            GO     $7,$4,4*12
            PRELD  70,$4,$4
            PRELD  70,$4,0
            PREGO  70,$4,$4
            PREGO  70,$4,0
            CSWAP  $3,Load_Test+13
            GETA   $3,1F
            PUT    rW,$3
            SETL   rz,1
            ADD    ry,$4,4
            LDOU   $40,Jmp_Pop
            LDTU   $7,Big_End
            LDTU   $6,Big_Begin
1H          CMPU   $8,$6,$7
            BNN    $8,1F
            INCML  $6,#100           % increase the opcode
            PUT    rX,$6
            SET    $5,rz
            RESUME                   % return to 1B
1H          SL     $40,small,51
            SL     $40,small,52
            SAVE   $255,0
            PUT    rG,small-$0
            INCL   small-1,U_BIT<<8
            FADD   $100,small,$200
            PUT    rA,small-1        % enable underflow trip
            TRIP   1,$100,small
            FSUB   $100,small,$200   % cause underflow trip
            PUT    rL,10
            PUT    rL,small
            PUSHJ  11,@+4
            UNSAVE $255
            TRAP   0,Halt,0          % normal exit

            LOC    U_Handler
            PUSHJ  $255,Handler
3H          TRAP   0,$1
            SUB    $0,$1,1
            POP    2,0
4H          GET    $50,rX
            INCH   $50,#8100         % ropcode 1
            FLOT   $60,1
            PUT    rZ,$60
            JMP    2F

            LOC    0
            GET    $50,rX
            INCH   $50,#8200         % ropcode 2
            INCMH  $50,#ff00-(U_BIT<<8)
            TRAP   1
2H          PUT    rX,$50
            GET    $255,rB
            RESUME
Handler     SETL   $5,#abcd
            GET    $1,rJ
            PUSHJ  3,3B
            SUB    $10,$3,$4
            PUT    rJ,$1
            POP    11,(4B-3B)>>2

Updated language file for GeSHi

Habe hier mal eine aktuellere Version der Language File im Hintergrund laufen (Dev-System): *klick*.

Hier der aktuelle Stand:

<?php
/*************************************************************************************
 * mmix.php
 * -------
 * Author: Benny Baumann (BenBE@geshi.org)
 * Copyright: (c) 2009 Benny Baumann (http://qbnz.com/highlighter/)
 * Release Version: 1.0.8.11
 * Date Started: 2009/10/16
 *
 * MMIX Assembler language file for GeSHi.
 *
 * This is an implementation of the MMIX language as designed by Donald E. Knuth
 *
 * CHANGES
 * -------
 * 2004/08/05 (1.0.8.6)
 *   -  First Release
 *
 * TODO (updated 2009/10/16)
 * -------------------------
 *
 *************************************************************************************
 *
 *     This file is part of GeSHi.
 *
 *   GeSHi is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   GeSHi is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with GeSHi; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 ************************************************************************************/

$language_data = array (
    'LANG_NAME' => 'MMIX',
    'COMMENT_SINGLE' => array(1 => ';', 2 => '%'),
    'COMMENT_MULTI' => array(),
    //Line address prefix suppression
    'COMMENT_REGEXP' => array(
        3 => "/^\s*\*\s.*$/m",
        4 => "/^\s*[0-9a-f]{12,16}+(?:\s+[0-9a-f]+(?:\.{3}[0-9a-f]{2,})?)?:/mi"
        ),
    'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
    'QUOTEMARKS' => array("'", '"'),
    'ESCAPE_CHAR' => '',
    'NUMBERS' => array(
        1 => '(?<![\d\$#\w])[\da-fA-F]+(?!\w)',
        2 => '#[\da-fA-F]+',
        3 => '\$\d+'
        ),
    'KEYWORDS' => array(
        /*CPU*/
        1 => array(
            '16ADDU','2ADDU','4ADDU','8ADDU','ADD','ADDU','AND','ANDN','ANDNH',
            'ANDNL','ANDNMH','ANDNML','BDIF','BEV','BN','BNN','BNP','BNZ','BOD',
            'BP','BZ','CMP','CMPU','CSEV','CSN','CSNN','CSNP','CSNZ','CSOD',
            'CSP','CSWAP','CSZ','DIV','DIVU','FADD','FCMP','FCMPE','FDIV',
            'FEQL','FEQLE','FINT','FIX','FIXU','FLOT','FLOTU','FMUL','FREM',
            'FSQRT','FSUB','FUN','FUNE','GET','GETA','GO','GREG','INCH','INCL',
            'INCMH','INCML','JMP','LDB','LDBU','LDHT','LDO','LDOU','LDSF','LDT',
            'LDTU','LDUNC','LDVTS','LDW','LDWU','LOC','MOR','MUL','MULU','MUX',
            'MXOR','NAND','NEG','NEGU','NOR','NXOR','OCTA','ODIF','OR','ORH',
            'ORL','ORMH','ORML','ORN','PBEV','PBN','PBNN','PBNP','PBNZ','PBOD',
            'PBP','PBZ','POP','PREGO','PRELD','PREST','PUSHGO','PUSHJ','PUT',
            'RESUME','SADD','SAVE','SET','SETH','SETL','SETMH','SETML','SFLOT',
            'SFLOTU','SL','SLU','SR','SRU','STB','STBU','STCO','STHT','STO',
            'STOU','STSF','STT','STTU','STUNC','STW','STWU','SUB','SUBU','SWYM',
            'SYNC','SYNCD','SYNCID','TDIF','TETRA','TRAP','TRIP','UNSAVE',
            'WDIF','XOR','ZSEV','ZSN','ZSNN','ZSNP','ZSNZ','ZSOD','ZSP','ZSZ'
            ),
        /*registers*/
        3 => array(
            'rA','rB','rC','rD','rE','rF','rG','rH','rI','rJ','rK','rL','rM',
            'rN','rO','rP','rQ','rR','rS','rT','rU','rV','rW','rX','rY','rZ',
            'rBB','rTT','rWW','rXX','rYY','rZZ'
            ),
        /*Directive*/
        4 => array(
            ),
        /*Operands*/
        5 => array(
            )
        ),
    'SYMBOLS' => array(
        '[', ']', '(', ')',
        '+', '-', '*', '/', '%',
        '.', ',', ';', ':',
        '<<','>>'
        ),
    'CASE_SENSITIVE' => array(
        GESHI_COMMENTS => false,
        1 => true,
        2 => false,
        3 => true,
        4 => false,
        5 => false
        ),
    'STYLES' => array(
        'KEYWORDS' => array(
            1 => 'color: #00007f; font-weight: bold;',
            2 => 'color: #0000ff; font-weight: bold;',
            3 => 'color: #00007f;',
            4 => 'color: #000000; font-weight: bold;',
            5 => 'color: #000000; font-weight: bold;'
            ),
        'COMMENTS' => array(
            1 => 'color: #666666; font-style: italic;',
            2 => 'color: #666666; font-style: italic;',
            3 => 'color: #666666; font-style: italic;',
            4 => 'color: #adadad; font-style: italic;',
            ),
        'ESCAPE_CHAR' => array(
            0 => 'color: #000099; font-weight: bold;'
            ),
        'BRACKETS' => array(
            0 => 'color: #009900; font-weight: bold;'
            ),
        'STRINGS' => array(
            0 => 'color: #7f007f;'
            ),
        'NUMBERS' => array(
            0 => 'color: #0000ff;',
            1 => 'color: #0000ff;',
            2 => 'color: #0000ff;',
            3 => 'color: #00007f;'
            ),
        'METHODS' => array(
            ),
        'SYMBOLS' => array(
            0 => 'color: #339933;'
            ),
        'REGEXPS' => array(
//            0 => 'color: #0000ff;',
//            1 => 'color: #0000ff;'
            ),
        'SCRIPT' => array(
            )
        ),
    'URLS' => array(
        1 => '',
        2 => '',
        3 => '',
        4 => '',
        5 => ''
        ),
/*
    'NUMBERS' =>
        GESHI_NUMBER_BIN_PREFIX_PERCENT |
        GESHI_NUMBER_BIN_SUFFIX |
        GESHI_NUMBER_HEX_PREFIX |
        GESHI_NUMBER_HEX_SUFFIX |
        GESHI_NUMBER_OCT_SUFFIX |
        GESHI_NUMBER_INT_BASIC |
        GESHI_NUMBER_FLT_NONSCI |
        GESHI_NUMBER_FLT_NONSCI_F |
        GESHI_NUMBER_FLT_SCI_ZERO,
*/
    'OOLANG' => false,
    'OBJECT_SPLITTERS' => array(
        ),
    'REGEXPS' => array(
        //Hex numbers
//        0 => /*  */ "(?<=([\\s\\(\\)\\[\\],;.:+\\-\\/*]))(?:[0-9][0-9a-fA-F]{0,31}[hH]|0x[0-9a-fA-F]{1,32})(?=([\\s\\(\\)\\[\\],;.:+\\-\\/*]))",
        //Binary numbers
//        1 => "(?<=([\\s\\(\\)\\[\\],;.:+\\-\\/*]))[01]{1,64}[bB](?=([\\s\\(\\)\\[\\],;.:+\\-\\/*]))"
        ),
    'STRICT_MODE_APPLIES' => GESHI_NEVER,
    'SCRIPT_DELIMITERS' => array(
        ),
    'HIGHLIGHT_STRICT_BLOCK' => array(
        ),
    'TAB_WIDTH' => 8,
    'PARSER_CONTROL' => array(
        'KEYWORDS' => array(
            'DISALLOWED_BEFORE' => "(?<![a-zA-Z0-9\$_\|\#>|^])",
            'DISALLOWED_AFTER' => "(?![a-zA-Z0-9_<\|%])"
        )
    )
);

?>

Sollte noch was fehlen, bitte mich kurz im SF-Bugtracker noch mal drauf hinweisen. Änderungen gehen die Tage dann auch in's SVN.

Weiter Beispiele

// Kommentar
' Kommentar '
# Kommentar
? Kommentar
@#! Kommentar
-- Kommentar
$ Kommentar
+ Kommentar
1H      ADD $0,$1,$2 % Kommentar
foo     GET $0,rA      Kommentar
        JMP @+24       Kommentar
   { Kommentar (?) }

KeinKommentar IS 0

Main    TRAP KeinKommentar

THIS IS NOTACOMMENT But this is one (And this too).

TheOp   LDA $0,$1,$3 Should be highlighted.

        BSPEC 0 ist auch ein Pseudo-Op
        ESPEC 0 auch. (Beide müssen hervorgehoben sein.)

        ; I love MMIX!

Wenn GeSHi all das frisst, bin ich glücklich.