MOV AL,0B6H 0000 1011 0110
选择计数器2;
11先读/写低字节,后读/写高字节
011方式3,方波发生器
二进制计数
CODE SEGMENT ASSUME CS:CODE,DS:CODE ORG 100H ;程序段的入口或者起始地址 START:JMP BEGIN ;跳到第七行 LONG1 EQU 6 SHORT1 EQU 1 ;相当于定义符号常量 BEGIN:MOV AX,CODE MOV DS,AX ;将代码段的段地址送入DS MOV AL,0B6H OUT 43H,AL ;命令口地址为43H MOV AX,5D3H ;计数初值 OUT 42H,AL ;先装低字节 MOV AL,AH ;后装高字节 OUT 42H,AL IN AL,61H ;读PB AND AL,0FCH ;1111 1100置PB0、PB1为零,关闭与门 OUT 61H,AL ;查任意键,启动发生器 WAIT1:MOV AH,0BH ;功能调用 INT 21H CMP AL,00H ;无按键按下,等待 JE WAIT1 ;发长音,相等跳转 LOP:MOV BL,LONG1 ;长音参数 CALL SSP ;调入发声子程序 MOV AH,0BH INT 21H CMP AL,00H JE CONTINUE1 MOV AH,08H INT 21H CMP AL,1BH JE QUIT CONTINUE1:MOV BL,SHORT1 CALL SSP JMP LOP QUIT:IN AL,61H MOV AH,AL AND AL,0FCH OUT 61H,AL MOV AH,4CH INT 21H SSP PROC NEAR IN AL,61H OR AL,03H OUT 61H,AL SUB CX,CX L:LOOP L DEC BL JNZ L RET SSP ENDP CODE ENDS END START