功能比较简单,六位数的存款取款操作
DATAS SEGMENT
;此处输入数据段代码
TIP1 DB 'Welcome to DanBank!',0DH,0AH,'$'
TIP2 DB 'Please input your password:',0DH,0AH,'$'
TIP3 DB 'Sorry,your password error,Try again.',0DH,0AH,'$'
TIP4 DB 'Login succeed,welcome back!',0DH,0AH,'$'
TIP5 DB 'MAKE YOU CHOICE:',0DH,0AH,'$'
TIP6 DB 'Failed more than three time,system halt!',0DH,0AH,'$'
TIP7 DB 'Thanks for your using!',0DH,0AH,'$'
TIP8 DB 'Input the money you want to save:',0DH,0AH,'$'
TIP9 DB 'Your balance:$'
TIP10 DB 'Input the money you want to withdraw:',0DH,0AH,'$'
TIP11 DB 0DH,0AH,'ERROR INPUT!PLEASE MAKE YOUR CHOICE AGAIN:',0DH,0AH,'$'
CHO1 DB '1.BACK TO DOS',0DH,0AH,'$'
CHO2 DB '2.QUERY THE BALANCE',0DH,0AH,'$'
CHO3 DB '3.SAVE YOUR MONEY',0DH,0AH,'$'
CHO4 DB '4.WITHDRAW MONEY',0DH,0AH,'$'
BALANCE DB 5,0,0,0,0,9 ;05H,00H,00H,00H,00H,00H
BA_LEN EQU $-BALANCE
CACHE DB 7,?,7 DUP(?)
PWD DB '222222'
BF_PWD DB 10,?,10 DUP(?)
BF_CHO DB ?
DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码
DB 10 DUP(?)
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS,ES:DATAS
START:
MOV AX,DATAS
MOV DS,AX
MOV ES,AX
;此处输入代码段代码
MOV AH,09H
LEA DX,TIP1
INT 21H ;OUTPUT TIP1 Welcome to DanBank!
MOV AH,09H
LEA DX,TIP2
INT 21H ;OUTPUT TIP2 Please input your password:
MOV BL,0 ;BL TO RECORD THE TIME YOU TRY YOUR PWD,INIT 0 HERE
INPWD:
CALL ENTERPWD ;INPUT BF_PWD
CALL ENTERBACK ;INPUT ENTER TO SCREEN
LEA SI,BF_PWD+2
LEA DI,PWD
MOV CX,6
CLD
REPE CMPSB ;COMPARE
JZ PASS
JMP FAILED
PASS:
MOV AH,09H ;OUTPUT TIP4 Login succeed,welcome back!
LEA DX,TIP4
INT 21H
CHO:
CALL CHOINFO ;SHOW THE CHOICE INFOMATION
MOV AH,01H
INT 21H ;INPUT YOUR CHOICE
CALL DEALCHO
JMP QUIT
FAILED:
CMP BL,2
LEA DX,TIP6 ;OUTPUT Failed more than three time,system halt!
JZ QUIT
MOV AH,09H
LEA DX,TIP3
INT 21H
INC BL
JMP INPWD
QUERY:
CALL ENTERBACK ;INPUT ENTER TO SCREEN
MOV AH,09H
LEA DX,TIP9
INT 21H ;OUTPUT TIP9 Your balance:
MOV CX,BA_LEN
LEA BX,BALANCE
L1:
MOV DL,[BX]
ADD DL,30H
INC BX
MOV AH,02H
INT 21H
LOOP L1
CALL ENTERBACK ;INPUT ENTER TO SCREEN
JMP CHO
SAVE:
CALL ENTERBACK ;INPUT ENTER TO SCREEN
MOV AH,09H
LEA DX,TIP8
INT 21H ;OUTPUT TIP8
CALL INCACHE
CALL DEPOSIT
DRAW:
CALL ENTERBACK
MOV AH,09H
LEA DX,TIP10
INT 21H ;OUTPUT TIP8
CALL INCACHE
CALL WITHDRAW
QUIT:
CALL ENTERBACK
LEA DX,TIP7
MOV AH,09H
INT 21H
MOV AH,4CH
INT 21H
;************************SUB PROC******************
;---INPUT THE CACHE YOU WANT TO SAVE
INCACHE PROC
MOV CX,10
LEA BX,CACHE ;SAVE CACHE OFFSET TO BX
PUSH BX ;SAVE THE START POSITION
L2: CMP AL,0DH
JZ FINISH
MOV AH,01H
INT 21H
MOV [BX+1],AL ;SPARE THE FIRST PLACE TO STORE THE LENGTH
INC BX
LOOP L2
FINISH:
MOV DX,9
SUB DX,CX ;CALC THE LENGTH OF CACHE
ADD DX,30H ;CHANGE THE DX TO DECIMAL
POP BX
MOV [BX],DL ;SAVE THE LENGTH TO THE FIRST POSITION OF CACHE
MOV CX,0
RET
INCACHE ENDP
;---DEPOSIT MONEY TO BANK------------------------
; SI: STORE THE START POSITION OF CACHE
; BX: STORE THE OFFSET OF CACHE
; DI: STORE THE START POSITION OF BALANCE
; BP: STORE THE OFFSET OF BALANCE
; AL: STORE A BIT VALUE OF CACHE
; AH: STORE A BIT VALUE OF BALANCE
;---@ PARAM---- VALUE------------------------
DEPOSIT PROC
LEA SI,CACHE
MOV BX,[SI] ;GET OFFSET CACHE
AND BH,00H
SUB BL,30H ;USE BX TO SAVE LENGTH OF CACHE
LEA DI,BALANCE
MOV DX,BA_LEN ;USE DX TO SAVE LENGTH OF BALANCE
MOV CX,BA_LEN
MOV BP,BA_LEN-1 ;SAVE OFFSET FOR DEAL BY PER_BIT
L3:
CMP BX,0
JZ BXLSDX ;BX LESS THAN DX
MOV AL,[SI+BX]
MOV AH,[DI+BP]
JMP BXDX ;COMMON CALCULATE
BXLSDX:
POPF
MOV AL,0
MOV AH,[DI+BP]
ADC AL,AH
JMP NEXT
BXDX:
POPF
ADC AL,AH
DEC BX
JMP NEXT
NEXT:
AAA
PUSHF
MOV [DI+BP],AL
DEC BP
LOOP L3
JMP QUERY
RET
DEPOSIT ENDP
;---WITHDRAW MONEY FROM BANK--------------DONE
; SI: STORE THE START POSITION OF CACHE
; BX: STORE THE OFFSET OF CACHE
; DI: STORE THE START POSITION OF BALANCE
; BP: STORE THE OFFSET OF BALANCE
; AL: STORE A BIT VALUE OF BALANCE
; AH: STORE A BIT VALUE OF CACHE
;---@ PARAM---- VALUE------------------------
WITHDRAW PROC
ADD AL,0
PUSHF
LEA SI,CACHE
MOV BX,[SI] ;GET OFFSET CACHE
AND BH,00H
SUB BL,30H ;USE BX TO SAVE LENGTH OF CACHE
LEA DI,BALANCE
MOV DX,BA_LEN ;USE DX TO SAVE LENGTH OF BALANCE
MOV CX,BA_LEN
MOV BP,BA_LEN-1 ;SAVE OFFSET FOR DEAL BY PER_BIT
L3:
CMP BX,0
JZ BXLSDX ;BX LESS THAN DX
MOV AH,[SI+BX]
MOV AL,[DI+BP]
ADD AL,30H
JMP BXDX ;COMMON CALCULATE
BXLSDX:
MOV AH,30H
MOV AL,[DI+BP]
ADD AL,30H
POPF
SBB AL,AH
JMP NEXT
BXDX:
POPF
SBB AL,AH
DEC BX
JMP NEXT
NEXT:
AAS
PUSHF
MOV [DI+BP],AL
DEC BP
LOOP L3
JMP QUERY
RET
WITHDRAW ENDP
;---SHOW CHOICE INFOMATION-------
CHOINFO PROC
MOV AH,09H
LEA DX,TIP5
INT 21H
MOV AH,09H
LEA DX,CHO1
INT 21H
MOV AH,09H
LEA DX,CHO2
INT 21H
MOV AH,09H
LEA DX,CHO3
INT 21H
MOV AH,09H
LEA DX,CHO4
INT 21H
RET
CHOINFO ENDP
;---MAKE CHOICE & DEAL THE CHOICE---------
DEALCHO PROC
AND AH,00
CMP AL,'1'
JE QUIT
CMP AL,'2'
JE QUERY
CMP AL,'3'
JE SAVE
CMP AL,'4'
JE DRAW
MOV AH,09H
LEA DX,TIP11
INT 21H
JMP CHO ;ERROR INPUT,JMP TO CHOICE INFORMATION
RET
DEALCHO ENDP
;---ENTER THE PASSWORD
ENTERPWD PROC
PUSH BX ;SAVE BL FOR RECORDING ERROR TIME
LEA BX,BF_PWD
MOV CX,10
CLD
INPUT:
MOV AH,08H
INT 21H
CMP AL,0DH
JZ NEXT
MOV [BX+2],AL
INC BX
MOV AH,02H
MOV DL,2AH
INT 21H
LOOP INPUT
NEXT:
MOV CX,0
POP BX
RET
ENTERPWD ENDP
;---INPUT ENTER TO SCREEN
ENTERBACK PROC
MOV AH,02H
MOV DL,0DH
INT 21H
MOV AH,02H
MOV DL,0AH
INT 21H
RET
ENTERBACK ENDP
CODES ENDS
END START