1 ; multi-segment executable file template. 2 3 data segment 4 5 ends 6 7 stack segment 8 dw 128 dup(0) 9 ends10 11 code segment12 start:13 ; set segment registers:14 mov ax, data15 mov ds, ax16 mov es, ax17 18 ; add your code here 19 BEGIN: 20 MOV AH, 1 ;从键盘输入一个字符的DOS调用AL存放输入的字符21 INT 21H22 SUB AL, '0' ;输入的是字符需要转化为数字23 JB STOP ;输入字符<'0'吗?;below24 CMP AL, 9 ;输入字符>'9'吗?;above25 JA STOP26 CBW ;AL扩展到AH27 MOV CX, AX ;响铃次数N28 JCXZ STOP29 BELL: 30 MOV DL, 07H ;准备响铃31 MOV AH, 2 ;显示一个字符的DOS调用,实际为响铃32 INT 21H33 LOOP BELL34 STOP: RET35 36 ; wait for any key.... 37 mov ah, 138 int 21h39 40 mov ax, 4c00h ; exit to operating system.41 int 21h 42 ends43 44 end start ; set entry point and stop the assembler.