DATA SEGMENTTIM DB 7FH ;設定初始值DATA ENDSSTACK SEGMENT STACK "STACK" ;堆疊段定義 DB 100 DUP(?) STACK ENDSCODE SEGMENT ASSUME CS:CODE,DS:DATA,SS:STACKSTART: MOV AX,DATA MOV DS,AX MOV DX,0EEE0H IN AL,DX ;讀取當前埠狀態 AND AL,TIM JNZ OVR MOV AL,7FH ;先點亮第一個燈 MOV DX,0EEE0HLOOP1: OUT DX,AL CALL DELAY MOV BL,AL ROR AL,1 ;右移,點亮下一個燈 MOV BL,AL MOV AH,0BH ;檢測鍵盤輸入 INT 21H OR AL,AL JZ LOOP1 ;迴圈點亮 MOV AX,4C00H ;程式結束 INT 21HOVR:NOP RETDELAY PROC NEAR ;延時子程式 NOP PUSH CX MOV CX,0FFFFHCONTI: LOOP CONTI POP CX RETDELAY ENDP MOV AX,4C00H INT 21HCODE ENDS END START
DATA SEGMENTTIM DB 7FH ;設定初始值DATA ENDSSTACK SEGMENT STACK "STACK" ;堆疊段定義 DB 100 DUP(?) STACK ENDSCODE SEGMENT ASSUME CS:CODE,DS:DATA,SS:STACKSTART: MOV AX,DATA MOV DS,AX MOV DX,0EEE0H IN AL,DX ;讀取當前埠狀態 AND AL,TIM JNZ OVR MOV AL,7FH ;先點亮第一個燈 MOV DX,0EEE0HLOOP1: OUT DX,AL CALL DELAY MOV BL,AL ROR AL,1 ;右移,點亮下一個燈 MOV BL,AL MOV AH,0BH ;檢測鍵盤輸入 INT 21H OR AL,AL JZ LOOP1 ;迴圈點亮 MOV AX,4C00H ;程式結束 INT 21HOVR:NOP RETDELAY PROC NEAR ;延時子程式 NOP PUSH CX MOV CX,0FFFFHCONTI: LOOP CONTI POP CX RETDELAY ENDP MOV AX,4C00H INT 21HCODE ENDS END START