/*
 *  This function just prints the code text in a cyclic manner each time
 *  it is called.
 *
 */


 void code(void)
 {
  static int i = 1;
  static char *code_one="\
 CE-ACI      8F-ADC A    88-ADC B    89-ADC C    8A-ADC D  \n\
 8B-ADC E    8C-ADC H    8D-ADC L    8E-ADC M    87-ADD A  \n\
 80-ADD B    81-ADD C    82-ADD D    83-ADD E    84-ADD H  \n\
 85-ADD L    86-ADD M    C6-ADI 8    A7-ANA A    A0-ANA B  \n\
 A1-ANA C    A2-ANA D    A3-ANA E    A4-ANA H    A5-ANA L  \n\
 A6-ANA M    E6-ANI      CD-CALL     DC-CC       FC-CM     \n\
 2F-CMA      3F-CMC      BF-CMP A    B8-CMP B    B9-CMP C  \n\
 BA-CMP D    BB-CMP E    BC-CMP H    BD-CMP L    BE-CMP M  \n\
 D4-CNC      C4-CNZ      F4-CP       EC-CPE      FE-CPI    \n\
 E4-CPO      CC-CZ       27-DAA      09-DAD B    19-DAD D  \n\
 29-DAD H    39-DAD SP   3D-DCR A    05-DCR B    0D-DCR C  \n\
 15-DCR D    1D-DCR E    25-DCR H    2D-DCR L    35-DCR M  \n";
 static char *code_two="\
 0B-DCX B    1B-DCX D    2B-DCX H    3B-DCX SP   F3-DI     \n\
 FB-EI       76-HLT      DB-IN       3C-INR A    04-INR B  \n\
 0C-INR C    14-INR D    1C-INR E    24-INR H    2C-INR L  \n\
 34-INR M    03-INX B    13-INX D    23-INX H    33-INX SP \n\
 DA-JC       FA-JM       C3-JMP      D2-JNC      C2-JNZ    \n\
 F2-JP       EA-JPE      E2-JPO      CA-JZ       3A-LDA    \n\
 0A-LDAX B   1A-LDAX D   2A-LHLD     01-LXI B    11-LXI D  \n\
 21-LXI H    31-LXI SP   7F-MOV A,A  78-MOV A,B  79-MOV A,C\n\
 7A-MOV A,D  7B-MOV A,E  7C-MOV A,H  7D-MOV A,L  7E-MOV A,M\n\
 47-MOV B,A  41-MOV B,C  42-MOV B,D  43-MOV B,E  44-MOV B,H\n\
 45-MOV B,L  46-MOV B,M  4F-MOV C,A  48-MOV C,B  49-MOV C,C\n\
 4A-MOV C,D  4B-MOV C,E  4C-MOV C,H  4D-MOV C,L  4E-MOV C,M\n";
 static char *code_three="\
 57-MOV D,A  50-MOV D,B  51-MOV D,C  52-MOV D,D  53-MOV D,E\n\
 54-MOV D,H  55-MOV D,L  56-MOV D,M  5F-MOV E,A  58-MOV E,B\n\
 59-MOV E,C  5A-MOV E,D  5B-MOV E,E  5C-MOV E,H  5D-MOV E,L\n\
 5E-MOV E,M; 67-MOV H,A  60-MOV H,B  61-MOV H,C  62-MOV H,D\n\
 64-MOV H,H  65-MOV H,L  66-MOV H,M  6F-MOV L,A  68-MOV L,B\n\
 69-MOV L,C  6A-MOV L,D  6B-MOV L,E  6C-MOV L,H  6D-MOV L,L\n\
 6E-MOV L,M  77-MOV M,A  70-MOV M,B  71-MOV M,C  72-MOV M,D\n\
 73-MOV M,E  74-MOV M,H  75-MOV M,L  3E-MVI A    06-MVI B  \n\
 0E-MVI C    16-MVI D    1E-MVI E    26-MVI H    2E-MVI L  \n\
 36-MVI M    00-NOP      B7-ORA A    B0-ORA B    B1-ORA C  \n\
 B2-ORA D    B3-ORA E    B4-ORA H    B5-ORA L    B6-ORA M  \n\
 F6-ORI      D3-OUT      E9-PCHL     C1-POP B    D1-POP D  \n";
 static char *code_four="\
 E1-POP H    F1-POP PSW  C5-PUSH B   D5-PUSH D   E5-PUSH H \n\
 F5-PUSH PSW 17-RAL      1F-RAR      D8-RC       C9-RET    \n\
 07-RLC      F8-RM       D0-RNC      C0-RNZ      F0-RP     \n\
 E8-RPE      E0-RPO      0F-RRC      C8-RZ       9F-SBB A  \n\
 98-SBB B    99-SBB C    9A-SBB D    9B-SBB E    9C-SBB H  \n\
 9D-SBB L    9E-SBB M    DE-SBI      22-SHLD     F9-SPHL   \n\
 32-STA      02-STAX B   12-STAX D   37-STC      97-SUB A  \n\
 90-SUB B    91-SUB C    92-SUB D    93-SUB E    94-SUB H  \n\
 95-SUB L    96-SUB M    D6-SUI      EB-XCHG     AF-XRA A  \n\
 A8-XRA B    A9-XRA C    AA-XRA D    AB-XRA E    AC-XRA H  \n\
 AD-XRA L    AE-XRA M    EE-XRI      E3-XTHL               \n\
                                                           \n";
  gotoxy(0,7);
  if (i == 1) {
	write(1,code_one,709);
  }
  else if (i == 2) {
	write(1,code_two,709);
  }
  else if (i == 3) {
	write(1,code_three,709);
  }
  else if (i == 4) {
	write(1,code_four,709);
  }
  i = (i == 4) ? 1 : i+1;
  return;
 }
