汇编:从键盘录入20个数(-128~127),求最大值
include 一套工具.mac
data segment
show db "Please Input twenty numbers:$"
iit1 db "The $"
iit2 db " number is:$"
buf db 20 dup(?)
x db ?,?,?,? ;x[0]用来存负号
w db ? ;用于显示提示信息
max db ?
boundary db "128$"
display db "Max:$"
error1 db "Input error!<you can check whether it is between -128~127>",13,10,"Please Input again:$"
data ends
stack segment
stack ends
code segment
assume ds:data,cs:code,ss:stack
start:
mov ax,data
mov ds,ax
mov ax,stack
mov ss,ax
mov bx,0
push bx
mov bx,1
;显示提示输入信息
oustring show
ld
inpu1: ;显示提示输入信息
oustring iit1
inc w
cmp w,9
jg www
mov dl,w
add dl,30h
mov ah,2
int 21h
oustring iit2
set1: ;输入
input
cmp al,1bh ;ESC退出
jz exit
cmp al,13 ;回车
jz outpu1
cmp al,'-'
jz minus
;判断是否在0-9
cmp al,30h
jl error0
cmp al,39h
jg error0
cmp bx,4
jg error0
sub al,30h
mov x[bx],al ;输入的字符合法,从x[1]开始存
inc bx
jmp set1
minus:
cmp x[0