Forth added to forum code highlighter

Discussion in 'Announcements' started by sk89q, Jan 9, 2013.

Tags:
  1. sk89q

    sk89q Administrator
    Staff Member

    Joined:
    Dec 1, 2011
    Messages:
    2,490
    Likes Received:
    1,504
    The forum code highlighter now supports Forth!
    Code:
    : EDUARDO ( -- )
    ." You rlly like Eduardo" CR
    ;
     
    : SORT ( -- )
    BEGIN
    \ output current item info
        20 SORTADDR !
        0 SORTSLOT@
        ( quantity ) DROP
        ( LSB ) 22 IOXADDR ! IOX!
        ( MSB ) 21 IOXADDR ! IOX!
     
    \ check input to see whether we need to send
        3 IOXADDR !
        IOX@ DUP DUP DUP
        1 AND IF
            EDUARDO 
            0 SORTPULL ( pull out item )
            2/ 31 AND SORTADDR !
            6 U>> 15 AND SORTCOLOR!
            10 U>> 255 AND SORTMATCH
        ELSE
            DROP DROP DROP
        THEN
    AGAIN
    ;
     
  2. Ali

    Ali SupaHam

    Joined:
    Feb 7, 2012
    Messages:
    139
    Likes Received:
    43
    Pretty damn impressive.
     
  3. hsun324

    hsun324 Programmer, Gamer

    Joined:
    May 14, 2012
    Messages:
    362
    Likes Received:
    90
    Now we don't have to look at walls of text when I (eventually) post something!
     
  4. DarkMaterias

    DarkMaterias Dark Materials

    Joined:
    Mar 3, 2012
    Messages:
    71
    Likes Received:
    26
    Nice work, sk. This is a bit off topic, but is Forth as complicating as it looks? I can understand jackshit about that code up there.
     
  5. hsun324

    hsun324 Programmer, Gamer

    Joined:
    May 14, 2012
    Messages:
    362
    Likes Received:
    90
    It's only hard when you can't read it. It's a stack-based language, i.e. there is a stack where data, etc. goes, and all of the words there are like commands with code behind them that use the data on the stack to get the information that they need to run. A good tutorial is: www.forth.com/starting-forth/
     
    DarkMaterias likes this.
  6. Chaeris

    Chaeris Active Member

    Joined:
    Mar 8, 2012
    Messages:
    766
    Likes Received:
    89
    The declaration of different parts in the code (such as the following:

    : EDUARDO)

    Makes me think of Assembly language, my main one :D