gen/genacorn.c
static void generate_feedback(int input_is_ciphertext)
{
    // f = state->s1_l ^ (~state->s3_l) ^
    //     maj(s244, s23, s160) ^ (ca & s196) ^ (cb & ks);
    // f ^= plaintext;
    alloc_high_reg(&f); // Needs to be a high register for shift_down().
    insn_printf("mov r%d,r%d", f, s3_l);
    insn_printf("com r%d", f);
    insn_printf("eor r%d,r%d", f, s1_l);
    release_reg(&s1_l); // Don't need the low byte of s1 any more.

    // f ^= maj(s244, s23, s160)
    insn_printf("mov r%d,r%d", temp_reg, s244); // f ^= (s244 & s23)
    insn_printf("and r%d,r%d", temp_reg, s23);
    insn_printf("eor r%d,r%d", f, temp_reg);
    insn_printf("and r%d,r%d", s23, s160);      // f ^= (s23 & s160)
    insn_printf("eor r%d,r%d", f, s23);
    insn_printf("and r%d,r%d", s244, s160);     // f ^= (s244 & s160)
    insn_printf("eor r%d,r%d", f, s244);
    release_reg(&s244);
    release_reg(&s23);
    release_reg(&s160);

    // f ^= (ca & s196). Note that when decrypting, ca is always 1.
    if (!input_is_ciphertext)
        insn_printf("and r%d,%%3", s196);       // s196 &= ca
    insn_printf("eor r%d,r%d", f, s196);        // f ^= s196
    release_reg(&s196);

    // f ^= (cb & ks) ^ plaintext
    // If we are processing the ciphertext, then we need to first
    // decrypt the input with ks.  We leave the plaintext in "ks".
    // Note that when decrypting, cb is always 0.
    if (!is_32bit_version) {
        // Plaintext and ciphertext are 8-bit values in registers.
        if (input_is_ciphertext) {
            insn_printf("eor r%d,%%2", ks);     // plaintext = ciphertext ^ ks
            insn_printf("eor r%d,r%d", f, ks);  // f ^= plaintext
        } else {
            insn_printf("mov r%d,r%d", temp_reg, ks);   // f ^= (cb & ks)
            insn_printf("and r%d,%%4", temp_reg);
            insn_printf("eor r%d,r%d", f, temp_reg);
            insn_printf("eor r%d,%%2", f);              // f ^= plaintext
        }
    } else {
        // Plaintext and ciphertext are 32-bit values in the stack frame.
        static const char * const out_regs[] = {"%A0", "%B0", "%C0", "%D0"};
        static const char * const in_regs[]  = {"%A2", "%B2", "%C2", "%D2"};
        if (input_is_ciphertext) {
            insn_printf("ldd r%d,%s", temp_reg, in_regs[lfsr_offset]);
            insn_printf("eor r%d,r%d", ks, temp_reg);
            insn_printf("eor r%d,r%d", f, ks);
            insn_printf("std %s,r%d", out_regs[lfsr_offset], ks);
        } else {
            insn_printf("mov r%d,r%d", temp_reg, ks);
            insn_printf("and r%d,%%4", temp_reg);
            insn_printf("eor r%d,r%d", f, temp_reg);
            insn_printf("ldd r%d,%s", temp_reg, in_regs[lfsr_offset]);
            insn_printf("eor r%d,r%d", f, temp_reg);
            insn_printf("eor r%d,r%d", temp_reg, ks);
            insn_printf("std %s,r%d", out_regs[lfsr_offset], temp_reg);
        }
        release_reg(&ks);
    }
}
// Generate the next 8 non-linear feedback bits.
Generate the next 8 non-linear feedback bits.
Generate the next 8 non - linear feedback bits .
static void generate_feedback(int input_is_ciphertext)
{
    alloc_high_reg(&f); 
    insn_printf("mov r%d,r%d", f, s3_l);
    insn_printf("com r%d", f);
    insn_printf("eor r%d,r%d", f, s1_l);
    release_reg(&s1_l); 
    insn_printf("mov r%d,r%d", temp_reg, s244); 
    insn_printf("and r%d,r%d", temp_reg, s23);
    insn_printf("eor r%d,r%d", f, temp_reg);
    insn_printf("and r%d,r%d", s23, s160);      
    insn_printf("eor r%d,r%d", f, s23);
    insn_printf("and r%d,r%d", s244, s160);     
    insn_printf("eor r%d,r%d", f, s244);
    release_reg(&s244);
    release_reg(&s23);
    release_reg(&s160);
    if (!input_is_ciphertext)
        insn_printf("and r%d,%%3", s196);       
    insn_printf("eor r%d,r%d", f, s196);        
    release_reg(&s196);
    if (!is_32bit_version) {
        if (input_is_ciphertext) {
            insn_printf("eor r%d,%%2", ks);     
            insn_printf("eor r%d,r%d", f, ks);  
        } else {
            insn_printf("mov r%d,r%d", temp_reg, ks);   
            insn_printf("and r%d,%%4", temp_reg);
            insn_printf("eor r%d,r%d", f, temp_reg);
            insn_printf("eor r%d,%%2", f);              
        }
    } else {
        static const char * const out_regs[] = {"%A0", "%B0", "%C0", "%D0"};
        static const char * const in_regs[]  = {"%A2", "%B2", "%C2", "%D2"};
        if (input_is_ciphertext) {
            insn_printf("ldd r%d,%s", temp_reg, in_regs[lfsr_offset]);
            insn_printf("eor r%d,r%d", ks, temp_reg);
            insn_printf("eor r%d,r%d", f, ks);
            insn_printf("std %s,r%d", out_regs[lfsr_offset], ks);
        } else {
            insn_printf("mov r%d,r%d", temp_reg, ks);
            insn_printf("and r%d,%%4", temp_reg);
            insn_printf("eor r%d,r%d", f, temp_reg);
            insn_printf("ldd r%d,%s", temp_reg, in_regs[lfsr_offset]);
            insn_printf("eor r%d,r%d", f, temp_reg);
            insn_printf("eor r%d,r%d", temp_reg, ks);
            insn_printf("std %s,r%d", out_regs[lfsr_offset], temp_reg);
        }
        release_reg(&ks);
    }
}
static void generate_feedback ( int input_is_ciphertext ) { alloc_high_reg ( & f ) ; insn_printf ( " " , f , s3_l ) ; insn_printf ( " " , f ) ; insn_printf ( " " , f , s1_l ) ; release_reg ( & s1_l ) ; insn_printf ( " " , temp_reg , s244 ) ; insn_printf ( " " , temp_reg , s23 ) ; insn_printf ( " " , f , temp_reg ) ; insn_printf ( " " , s23 , s160 ) ; insn_printf ( " " , f , s23 ) ; insn_printf ( " " , s244 , s160 ) ; insn_printf ( " " , f , s244 ) ; release_reg ( & s244 ) ; release_reg ( & s23 ) ; release_reg ( & s160 ) ; if ( ! input_is_ciphertext ) insn_printf ( " " , s196 ) ; insn_printf ( " " , f , s196 ) ; release_reg ( & s196 ) ; if ( ! is_32bit_version ) { if ( input_is_ciphertext ) { insn_printf ( " " , ks ) ; insn_printf ( " " , f , ks ) ; } else { insn_printf ( " " , temp_reg , ks ) ; insn_printf ( " " , temp_reg ) ; insn_printf ( " " , f , temp_reg ) ; insn_printf ( " " , f ) ; } } else { static const char * const out_regs [ ] = { " " , " " , " " , " " } ; static const char * const in_regs [ ] = { " " , " " , " " , " " } ; if ( input_is_ciphertext ) { insn_printf ( " " , temp_reg , in_regs [ lfsr_offset ] ) ; insn_printf ( " " , ks , temp_reg ) ; insn_printf ( " " , f , ks ) ; insn_printf ( " " , out_regs [ lfsr_offset ] , ks ) ; } else { insn_printf ( " " , temp_reg , ks ) ; insn_printf ( " " , temp_reg ) ; insn_printf ( " " , f , temp_reg ) ; insn_printf ( " " , temp_reg , in_regs [ lfsr_offset ] ) ; insn_printf ( " " , f , temp_reg ) ; insn_printf ( " " , temp_reg , ks ) ; insn_printf ( " " , out_regs [ lfsr_offset ] , temp_reg ) ; } release_reg ( & ks ) ; } }
Generate the next 8 non-linear feedback bits.
Generate the next 8 non - linear feedback bits .
// f = state->s1_l ^ (~state->s3_l) ^ //     maj(s244, s23, s160) ^ (ca & s196) ^ (cb & ks); // f ^= plaintext; // Needs to be a high register for shift_down(). // Don't need the low byte of s1 any more. // f ^= maj(s244, s23, s160) // f ^= (s244 & s23) // f ^= (s23 & s160) // f ^= (s244 & s160) // f ^= (ca & s196). Note that when decrypting, ca is always 1. // s196 &= ca // f ^= s196 // f ^= (cb & ks) ^ plaintext // If we are processing the ciphertext, then we need to first // decrypt the input with ks.  We leave the plaintext in "ks". // Note that when decrypting, cb is always 0. // Plaintext and ciphertext are 8-bit values in registers. // plaintext = ciphertext ^ ks // f ^= plaintext // f ^= (cb & ks) // f ^= plaintext // Plaintext and ciphertext are 32-bit values in the stack frame.