;redcode-94odd ;name SUBLEQ Hello World ;author Roy van Rijn ;assert 1 ;---------------- ; Implementation of the OISC SUBLEQ interpreter. ; All instructions take 3 lines: ; dat A,0 ; dat B,0 ; dat C,0 ; ; The interpreter works as following: ; ; Substract A from B ; If B is less or equal to zero jump to C ; Else go to the next instruction (+3) ; ; If the jump is to HALT (-1) the program will halt ; If the substraction is OUT (-2) the program will output the amount ; substracted ;---------------- HALT equ -1 OUT equ -2 ;Pointers used by program: EQ dat PROGRAM-1 , PROGRAM PTR dat PROGRAM , PROGRAM+1 RESETV dat PROGRAM-SUBSTR , PROGRAM-SUBSTR ;reset values NEXTV dat #3 , #3 ;Print to command line: PRINT mov.ab *SUBSTR , #0 mov.b -1 , <1000 ;sts.b -1,0 for output ;Reset to absolute values: NEXT add.f NEXTV , PTR RESET mov.f RESETV , SUBSTR ;Main logic: START add.a *PTR , SUBSTR add.ab >PTR , SUBSTR mov.a @PTR , NEWPTR ;Check if output is OUT, print and go to next instruction: mov.a