;redcode
;name CloackTechnologyV4
;author Skybuck Flying
;strategy cloack/decloack demonstration
;version 4
;date 26 january 2008
; I am a bit bored right now, so let's do something usefull and write a
; little bit of code which I might re-use later or just for demonstration
purposes.
; this piece of code / demonstration / demo / routines / CODE LOL
; will show how to completely cloack some instruction and complete de-cloack
; them by using some routines and some loops and some counters and some
p-space.
; ok v2 working, now let's try to optimize it a little bit by getting rid of
the extra
; counter
; extra counter illiminated, counter is now reset by subtracting the
instruction length of it.
; code repeats it self, cloack/decloack/cloack/decloack/cloack/decloack
;
; further optimizations in version 4: post increment operators used to
increment the parameter counters
; for p-space, instead of storing a,b,a,b,a,b,a,b,a,b the parameters are now
stored:
; a,a,a,a,a,a,a,a,b,b,b,b,b,b,b,b,b thereby the counters only need to be
incremented with 1
; making the post increment operators possible with only one instruction
; nop >a, >b (cloack incrementation)
; nop }a, }b (decloack incrementation)
jmp Cloack
; Instructions to be cloacked/decloacked:
InstructionsBegin
InstructionsLength equ InstructionsEnd - InstructionsBegin
nop $555, $666
mov $777, $888
add #999, #1010
spl @1111, @1212
jmp #1313, #1414
dat $1515, $1616
jmz $1717, $1818
sub $1919, $2020
InstructionsEnd
; Counter which will be used to cloack instructions.
Counter dat $0, $InstructionsBegin
Cloack
CloackParameterA stp.ab @Counter, #1
CloackParameterB stp.b @Counter, #(1 + InstructionsLength )
sub @Counter, @Counter
add.ab #1, $Counter
nop >CloackParameterA, >CloackParameterB
djn Cloack, #InstructionsLength
mov #InstructionsLength, -1
; reset counter for decloack
sub.ab #InstructionsLength, $Counter
DeCloack
DeCloackParameterA ldp.a #1, @Counter
DeCloackParameterB ldp.ab #(1 + InstructionsLength), @Counter
add.ab #1, $Counter
nop }DeCloackParameterA, }DeCloackParameterB
djn DeCloack, #InstructionsLength
mov #InstructionsLength, -1
; reset counter for cloack
sub.ab #InstructionsLength, $Counter
jmp Cloack