Files
Last update 7 years 1 month
by
LALIT ARORA
Sorting_Machine.asm.ORG 0000H JMP 0040H .ORG 003CH JMP 0500H .ORG 0040H LXI SP,0FFFFH MVI A,00BH SIM EI MVI A,88H OUT 03H IR:IN 02H ANI 80H JZ IR MVI E,00H MVI A,20H ;COUNTER 0 OUT 83H MVI A,098H ; counter 2 mode 4 OUT 83H MVI A,74H ;COUNTER 1 OUT 83H RED:MVI A,050H ; counter 1 least significant bit OUT 81H MVI A,0C3H ; counter 1 most significant bit OUT 81H MVI A,014H ; counter 2 least significant bit OUT 82H MVI A,00CH OUT 02H MVI A,0FFH OUT 80H MVI A,00CH WAITR:JNZ WAITR MOV A,E CPI 0FFH JZ IR BLUE:MVI A,050H ; counter 1 least significant bit OUT 81H MVI A,0C3H ; counter 1 most significant bit OUT 81H MVI A,014H ; counter 2 least significant bit OUT 82H MVI A,00DH OUT 02H MVI A,0FFH OUT 80H MVI A,00DH WAITB:JNZ WAITB JMP IR DELAY: LXI B,0247H LOOPD:DCX B MOV A,C ORA B JNZ LOOPD RET REST:MVI H,32H LOOPY:CALL DELAY DCR H JNZ LOOPY RET .ORG 0500H CPI 00CH JNZ BLUE_DETECT IN 80H MOV C,A MVI A,0FFH SUB C CPI 02EH JNC ACLK_M1 ;RETURN CODE xra a EI RET ACLK_M1: MVI D,06H DRIVE_ACM1:MVI A , 05H OUT 00H CALL DELAY MVI A,01H OUT 00H CALL DELAY MVI A,09H OUT 00H CALL DELAY MVI A,08H OUT 00H CALL DELAY MVI A,0AH OUT 00H CALL DELAY MVI A,02H OUT 00H CALL DELAY MVI A,06H OUT 00H CALL DELAY MVI A,04H OUT 00H CALL DELAY DCR D JNZ DRIVE_ACM1 CALL REST MVI A,00H OUT 00H MVI D,06H DRIVE_CM1:MVI A,06H ; MOTOR ANTICLOCKWISE OUT 00H CALL DELAY MVI A,02H OUT 00H CALL DELAY MVI A,0AH OUT 00H CALL DELAY MVI A,08H OUT 00H CALL DELAY MVI A,09H OUT 00H CALL DELAY MVI A,01H OUT 00H CALL DELAY MVI A,05H OUT 00H CALL DELAY MVI A , 04H OUT 00H CALL DELAY DCR D JNZ DRIVE_CM1 CALL REST MVI A,00H OUT 00H ;return code MVI E,0FFH xra a EI RET BLUE_DETECT: IN 80H MOV C,A MVI A,0FFH SUB C CPI 027H JNC CLK TURN:MVI D,18H DRIVE_M12:MVI A , 50H ; MOTOR ANTICLOCKWISE OUT 00H CALL DELAY MVI A,04H OUT 00H CALL DELAY MVI A,10H OUT 00H CALL DELAY MVI A,06H OUT 00H CALL DELAY MVI A,90H OUT 00H CALL DELAY MVI A,02H OUT 00H CALL DELAY MVI A,80H OUT 00H CALL DELAY MVI A,0AH OUT 00H CALL DELAY MVI A,A0H OUT 00H CALL DELAY MVI A,08H OUT 00H CALL DELAY MVI A,20H OUT 00H CALL DELAY MVI A,09H OUT 00H CALL DELAY MVI A,60H OUT 00H CALL DELAY MVI A,01H OUT 00H CALL DELAY MVI A,40H OUT 00H CALL DELAY MVI A,05H OUT 00H CALL DELAY DCR D JNZ DRIVE_M12 CALL REST MVI A,00H OUT 00H ;return code xra a EI RET CLK: MVI D,06H DRIVE_CM2:MVI A , 40H ; OUT 00H CALL DELAY MVI A,60H OUT 00H CALL DELAY MVI A,20H OUT 00H CALL DELAY MVI A,A0H OUT 00H CALL DELAY MVI A,80H OUT 00H CALL DELAY MVI A,90H OUT 00H CALL DELAY MVI A,10H OUT 00H CALL DELAY MVI A,50H OUT 00H CALL DELAY DCR D JNZ DRIVE_CM2 CALL REST MVI A,00H OUT 00H MVI D,06H DRIVE_ACM2:MVI A,10H OUT 00H CALL DELAY MVI A,90H OUT 00H CALL DELAY MVI A,80H OUT 00H CALL DELAY MVI A,A0H OUT 00H CALL DELAY MVI A,20H OUT 00H CALL DELAY MVI A,60H OUT 00H CALL DELAY MVI A,40H OUT 00H CALL DELAY MVI A , 50H OUT 00H CALL DELAY DCR D JNZ DRIVE_ACM2 CALL REST MVI A,00H OUT 00H ;return code xra a EI RET