; Example : first_boot ; version Wed, 22 Feb 2012 02:04:15 GMT .name FirstBoot .profile auto mov 1234h R1 mov 5678h R4 ADD 4321h R1 ADD R1 R1 R1 mov 2 R2 mov 3 R3 mov R2 R4 mov R3 R4 add R1 R3 R4 mov 56 PC sub R2 R3 R4 add 1234h R3 R4 sub 1234h R3 R4 sub R3 R2 R4 and R2 R3 R4 ADD 8 PC mov 32 PC andn R2 R3 R4 and 1234h R3 R4 andn 1234h R3 R4 nand R2 R3 R4 or R2 R3 R4 orn R2 R3 R4 nor R2 R3 R4 xor R2 R3 R4 xorn R2 R3 R4 PUT R3 R4 GET R3 R4 PUT R3 7 MOV 0 PC ; Example of R16 × R16 multiply ; YASEP16 : 13 instructions, 44 bytes .name Mul16x16 .profile YASEP16 ; R1 x R2 => R3-R4 (R5=scratch) ; R2 left modified (rotated) after execution ; the 2 middle bytes are computed together MUL8H R1 R2 R3 MUL8H R2 R1 R4 ; Notice the exchange of operands ADD R4 R3 ; carry reused later SHR 8 R3 R4 ; adjust between R3 and R4, SHL 8 R3 MOV 100h R5 ; speculative carry OR R4 R5 R4 carry ; and put the carry back into R4 ; lower byte MUL8L R2 R1 R5 ADD R5 R3 ADD 1 R4 R4 carry ; higher byte ROL 8 R2 MUL8H R2 R1 R5 ADD R5 R4 ; eventually : ROR 8 R2 ; Example : testcall (test that call and return work) ; Version Tue, 20 Mar 2012 18:55:43 GMT .name testcall .profile auto mov 50 A2 mov 1234h R4 mov 5678h R2 mov 5 r3 call A2 R5 nop nop mov 1 R4 mov 2 R2 call 50 R5 nop nop mov 600Dh R5 ; good mov DEADh R4 add -26804 r3 mov r4 r5 nz R3 INV ; fonction : adresse de retour dans R5 add R4 R2 add r2 r3 mov R5 PC ; return ; testcond : test all the conditions ; Version Tue, 20 Mar 2012 19:19:25 GMT .name testcond mov 8 A5 mov 16 PC ; where to jump in case of error add -2 R4 ; adjust error address MOV DEADh R5 INV ; always & never call A5 R4 never add 6 PC always call A5 R4 ; test zero, LSB, MSB mov 0 r2 add 6 PC zero R2 ; fail ? call A5 R4 call A5 R4 NZ R2 add 6 PC LSB0 R2 call a5 r4 call a5 R4 LSB1 R2 mov -1 r3 add 6 PC NZ R3 call A5 R4 call A5 R4 zero R3 add 6 PC LSB1 R3 call a5 r4 call a5 r4 LSB0 R3 ; test the carry mov 0 R4 ; ok counter mov 8 r3 mov -1 R2 add 1 R2 ; set carry or 1 R4 CARRY call A5 R4 NO_CARRY add 1 R2 ; clear carry call A5 R4 CARRY or 2 R4 NO_CARRY mov 0 R2 add 0 R2 or 4 R4 NO_CARRY call A5 R4 CARRY mov 0 R2 add 0 R2 call A5 R4 CARRY or r3 r4 NO_CARRY add r3 r3 ; r3=16 MOV 8000h R5 ADD 8000h R5 or r3 r4 CARRY call A5 R4 NO_CARRY CMPU 31 r4 call A5 R4 NEQ ; test bits of R1 : ;mov A55Ah r1 ; disabled for this version as R1 is modified ;call a5 r4 BIT1 0 ;call a5 r4 BIT0 1 ;call a5 r4 BIT1 2 ;call a5 r4 BIT0 3 ;call a5 r4 BIT0 4 ;call a5 r4 BIT1 5 ;call a5 r4 BIT0 6 ;call a5 r4 BIT1 7 ; EQUAL: mov 3 R2 CMPU 3 r2 call A5 R4 NEQ add 6 PC EQ call a5 r4 mov 4 r3 CMPU r3 r2 call A5 R4 EQ add 6 PC NEQ call a5 r4 ; the end mov 600Dh R5 INV ; testLFSR : a simple example of a 16-bit LFSR ; version Sat, 17 Mar 2012 14:43:58 GMT .name testLFSR .profile YASEP16 ; R2 : POLY ; R5 : LFSR ; A3 : loop ; LFSR : mov 1234h R5 ; seed of the LFSR mov FFEDh R2 ; polynomial ; (it's just one of the 2048 polynomials ; with maximum length for 16-bits LFSRs) ADD 4 PC A3 ; loop entry ; generate 1 pseudo-random bit : ADD R5 R5 ; shift left with carry xor R2 R5 CARRY ; endless loop mov A3 PC ; testROP2 : test all the ROP2 operations ; Version Sat, 17 Mar 2012 11:47:45 GMT .name testROP2 .profile YASEP16 ; NOTE: the -N functions complement ; the 2nd operand, not the first mov 8 A5 mov 16 PC ; where to jump in case of error add -2 R4 ; adjust error address MOV DEADh R5 INV MOV 3 R2 MOV 5 R3 AND R2 R3 R4 ; 1 CMPU 1 R4 MOV A5 PC NEQ ANDN R2 R3 R4 ; 2 CMPU 2 R4 MOV A5 PC NEQ NAND R2 R3 R4 ; -2 CMPU -2 R4 MOV A5 PC NEQ OR R2 R3 R4 ; 7 CMPU 7 R4 MOV A5 PC NEQ ORN R2 R3 R4 CMPU -5 R4 MOV A5 PC NEQ NOR R2 R3 R4 ; -8 CMPU -8 R4 MOV A5 PC NEQ XOR R2 R3 R4 ; 6 CMPU 6 R4 MOV A5 PC NEQ XORN R2 R3 R4 ; -7 CMPU -7 R4 MOV A5 PC NEQ ;the end : mov 600Dh R5 INV