⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getdata.asm

📁 读取字母
💻 ASM
字号:
; Prog. name:
; Description: ; it will check the valid input, namely, Esc(exit_key), Enter(start_key)
; Space(stop), y(bonus),A~Z or a~z(stored in variable "key")
; Once one of the above valid inputs is entered, the variable "char_enter" is set to 1.
; So check char_enter first, if it is 1, then check other flags or characters.

; Author:
; Creation date:
; Last update:
;stk segment stack
;DB 1024 DUP (?)
;stk ends
;data segment
;player1 db 30 dup (?)
;player2 db 30 dup (?) ;maximum 40bytes length of the list of names
;difficulty db '?' ;1,2,3
;start_key db 0 ;enter pressed
;exit_key db 0 ;Esc pressed
;stop db 0 ;space pressed
;bonus db 0 ;y pressed
;bonus_end db 0; bonus period is over
;key db '?'; a char in A~Z or a~z is stored here
;char_enter db 0 ; once there is a key enterer by the user, char_enter is set to 1

;data ends


;code segment
;assume cs:code, ds: data, ss:stk

;mov ax, data
;mov ds, ax
;mov ax, stk
;mov ss, ax
;the body of the program
start:
;loops:
extrn start_key:byte, exit_key:byte, stop:byte, bonus:byte, bonus_end:byte
extrn key:byte, char_enter:byte
cseg segment para 'code'
public getdata
getdata proc far
assume cs:cseg

mov ah, 6; check the input without waiting
mov dl, 0FFh
int 21h
jz exit1; no input
;jz loops; no input 
mov key, al
mov char_enter, 1; input exits
mov al, key
start_:
;mov al, key
cmp al, 0Ah ;enter pressed?
jnz exit_
mov start_key, 1
jmp exit1

exit_:
;mov al, key
cmp al, 1Bh ;esc pressed
jnz stop_
mov exit_key, 1
jmp exit1

stop_:
;mov al, key
cmp al, 20h ; space pressed
jnz bonus_
mov stop, 1
jmp exit1

bonus_:
;mov al, key
cmp al, 'y'
jnz character_
mov bonus, 1
jmp exit1

character_:
check_AZ:
cmp al, 40h ; A: 41H
ja check_Z ;al>=A
jmp no_valid_key_entered
check_Z:
cmp al, 5Bh ; Z: 5AH
jb exit1 ; al<=Z

check_small_az:
check_a:
cmp al, 60h ; a:61h
ja check_small_z ;al>=a
jmp no_valid_key_entered
check_small_z:
cmp al, 7Bh; z: 7Ah
jb exit1 ;al<=z

no_valid_key_entered:
mov char_enter, 0
jmp exit1
  

; call exit function
exit1: 

;;;;;;;;;;;
;cmp char_enter, 1
;jz key_output
;jmp key_no_output
;key_output:
;mov ah, 2
;mov dl, key
;int 21h
;key_no_output:

getdata endp
cseg ends
end

;mov ah, 4ch
;int 21h
;code ends
;end start

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -