by@drafear
TLE
putchar:equ 08000h getchar:equ 08003h ld D,1 ld E,1 loop: call getchar ld B,A ; if C == 'T' then D = 0 ld A,B cp 'T' jr NZ,endif_T ld D,0 endif_T: ; if C == 'K' then E = 0 ld A,B cp 'K' jr NZ,endif_K ld E,0 endif_K: ; if D == 0 || E == 0 then putchar 'X' ld A,D cp 0 jr Z,if_C ld A,E cp 0 jr Z,if_C ld A,B jr endif_C if_C: ld A,'X' jr endif_C endif_C: ; output call putchar ; if D == 0 and E == 0 then exit ld A,D or E jr NZ,endif_halt halt endif_halt: ; D = (D+1)%51 inc D ld A,D cp 51 jr NZ,endif_step ld D,0 endif_step: jr loop
ORG 0000h LD A,(BC) LD (HL),B LD (HL),L LD (HL),H LD H,E LD L,B LD H,C LD (HL),D LD A,(7165h) LD (HL),L ADD HL,BC JR NC,L0047 JR NC,L0041 JR NC,L007B LD A,(BC) LD H,A LD H,L LD (HL),H LD H,E LD L,B LD H,C LD (HL),D LD A,(7165h) LD (HL),L ADD HL,BC JR NC,L005A JR NC,L0054 INC SP LD L,B LD A,(BC) LD A,(BC) ADD HL,BC LD L,H LD H,H ADD HL,BC LD B,H INC L LD SP,090Ah LD L,H LD H,H ADD HL,BC LD B,L INC L LD SP,0A0Ah LD L,H LD L,A LD L,A LD (HL),B LD A,(090Ah) LD H,E L0041: LD H,C LD L,H LD L,H ADD HL,BC LD H,A LD H,L L0047: LD (HL),H LD H,E LD L,B LD H,C LD (HL),D LD A,(BC) ADD HL,BC LD L,H LD H,H ADD HL,BC LD B,D INC L LD B,C L0054: LD A,(BC) ADD HL,BC DEC SP JR NZ,L00C2 LD H,(HL) L005A: JR NZ,L009D+2 ; reference not aligned to instruction JR NZ,L009B DEC A JR NZ,L0088 LD D,H DAA JR NZ,L00D9 LD L,B LD H,L LD L,(HL) JR NZ,L00AD+1 ; reference not aligned to instruction JR NZ,L00A9 JR NZ,L009D+1 ; reference not aligned to instruction LD A,(BC) ADD HL,BC LD L,H LD H,H ADD HL,BC LD B,C INC L LD B,D LD A,(BC) ADD HL,BC LD H,E LD (HL),B ADD HL,BC L007B: DAA LD D,H DAA LD A,(BC) ADD HL,BC LD L,D LD (HL),D ADD HL,BC LD C,(HL) LD E,D INC L LD H,L LD L,(HL) L0088: LD H,H LD L,C LD H,(HL) LD E,A LD D,H LD A,(BC) ADD HL,BC LD L,H LD H,H ADD HL,BC LD B,H INC L JR NC,L00A0 LD H,L LD L,(HL) LD H,H LD L,C LD H,(HL) L009B: LD E,A LD D,H L009D: LD A,(090Ah) L00A0: DEC SP JR NZ,L010C LD H,(HL) JR NZ,L00E7+2 ; reference not aligned to instruction JR NZ,L00E5 DEC A L00A9: JR NZ,L00D2 LD C,E DAA L00AD: JR NZ,L0123 LD L,B LD H,L LD L,(HL) JR NZ,L00F8+1 ; reference not aligned to instruction JR NZ,L00F3 JR NZ,L00E7+1 ; reference not aligned to instruction LD A,(BC) ADD HL,BC LD L,H LD H,H ADD HL,BC LD B,C INC L LD B,D LD A,(BC) ADD HL,BC L00C2: LD H,E LD (HL),B ADD HL,BC DAA LD C,E DAA LD A,(BC) ADD HL,BC LD L,D LD (HL),D ADD HL,BC LD C,(HL) LD E,D INC L LD H,L LD L,(HL) L00D2: LD H,H LD L,C LD H,(HL) LD E,A LD C,E LD A,(BC) ADD HL,BC L00D9: LD L,H LD H,H ADD HL,BC LD B,L INC L JR NC,L00EA LD H,L LD L,(HL) LD H,H LD L,C LD H,(HL) L00E5: LD E,A LD C,E L00E7: LD A,(090Ah) L00EA: DEC SP JR NZ,L0156 LD H,(HL) JR NZ,L0134 JR NZ,L012F DEC A L00F3: JR NZ,L0125 JR NZ,L0173 LD A,H L00F8: JR NZ,L013F JR NZ,L0139 DEC A JR NZ,L012F JR NZ,L0175 LD L,B LD H,L LD L,(HL) JR NZ,L0176 LD (HL),L LD (HL),H LD H,E LD L,B LD H,C LD (HL),D L010C: JR NZ,L0135 LD E,B DAA LD A,(BC) ADD HL,BC LD L,H LD H,H ADD HL,BC LD B,C INC L LD B,H LD A,(BC) ADD HL,BC LD H,E LD (HL),B ADD HL,BC JR NC,L0129 ADD HL,BC LD L,D LD (HL),D ADD HL,BC L0123: LD E,D INC L L0125: LD L,C LD H,(HL) LD E,A LD B,E L0129: LD A,(BC) ADD HL,BC LD L,H LD H,H ADD HL,BC LD B,C L012F: INC L LD B,L LD A,(BC) ADD HL,BC LD H,E L0134: LD (HL),B L0135: ADD HL,BC JR NC,L0142 ADD HL,BC L0139: LD L,D LD (HL),D ADD HL,BC LD E,D INC L LD L,C L013F: LD H,(HL) LD E,A LD B,E L0142: LD A,(BC) ADD HL,BC LD L,H LD H,H JR NZ,L0189 INC L LD B,D LD A,(BC) ADD HL,BC LD L,D LD (HL),D ADD HL,BC LD H,L LD L,(HL) LD H,H LD L,C LD H,(HL) LD E,A LD B,E L0156: LD A,(BC) LD L,C LD H,(HL) LD E,A LD B,E LD A,(090Ah) LD L,H LD H,H ADD HL,BC LD B,C INC L DAA LD E,B DAA LD A,(BC) ADD HL,BC LD L,D LD (HL),D JR NZ,L01D1 LD L,(HL) LD H,H LD L,C LD H,(HL) LD E,A LD B,E LD A,(BC) L0173: LD H,L LD L,(HL) L0175: LD H,H L0176: LD L,C LD H,(HL) LD E,A LD B,E LD A,(090Ah) DEC SP JR NZ,L01EE+1 ; reference not aligned to instruction LD (HL),L LD (HL),H LD (HL),B LD (HL),L LD (HL),H LD A,(BC) ADD HL,BC LD H,E LD H,C L0189: LD L,H LD L,H ADD HL,BC LD (HL),B LD (HL),L LD (HL),H LD H,E LD L,B LD H,C LD (HL),D LD A,(BC) ADD HL,BC DEC SP JR NZ,L0201 LD H,(HL) JR NZ,L01DF JR NZ,L01DA DEC A JR NZ,L01D0 JR NZ,L0203 LD L,(HL) LD H,H JR NZ,L01EA+1 ; reference not aligned to instruction JR NZ,L01E5 DEC A JR NZ,L01DB JR NZ,L0221 LD L,B LD H,L LD L,(HL) JR NZ,L0217 LD A,B LD L,C LD (HL),H LD A,(BC) ADD HL,BC LD L,H LD H,H ADD HL,BC LD B,C INC L LD B,H LD A,(BC) ADD HL,BC LD L,A LD (HL),D ADD HL,BC LD B,L LD A,(BC) ADD HL,BC LD L,D LD (HL),D ADD HL,BC LD C,(HL) LD E,D INC L LD H,L LD L,(HL) LD H,H LD L,C LD H,(HL) L01D0: LD E,A L01D1: LD L,B LD H,C LD L,H LD (HL),H LD A,(BC) ADD HL,BC LD L,B LD H,C LD L,H L01DA: LD (HL),H L01DB: LD A,(BC) LD H,L LD L,(HL) LD H,H L01DF: LD L,C LD H,(HL) LD E,A LD L,B LD H,C LD L,H L01E5: LD (HL),H LD A,(090Ah) DEC SP L01EA: JR NZ,L0230 JR NZ,L022B L01EE: JR NZ,L0218 LD B,H DEC HL LD SP,2529h DEC (HL) LD SP,090Ah LD L,C LD L,(HL) LD H,E ADD HL,BC LD B,H LD A,(BC) ADD HL,BC LD L,H L0201: LD H,H ADD HL,BC L0203: LD B,C INC L LD B,H LD A,(BC) ADD HL,BC LD H,E LD (HL),B ADD HL,BC DEC (HL) LD SP,090Ah LD L,D LD (HL),D ADD HL,BC LD C,(HL) LD E,D INC L LD H,L LD L,(HL) L0217: LD H,H L0218: LD L,C LD H,(HL) LD E,A LD (HL),E LD (HL),H LD H,L LD (HL),B LD A,(BC) ADD HL,BC L0221: LD L,H LD H,H ADD HL,BC LD B,H INC L JR NC,L0232 LD H,L LD L,(HL) LD H,H L022B: LD L,C LD H,(HL) LD E,A LD (HL),E LD (HL),H L0230: LD H,L LD (HL),B L0232: LD A,(090Ah) LD L,D LD (HL),D ADD HL,BC LD L,H LD L,A LD L,A LD (HL),B LD A,(BC)
T K