汇编 文件读写。。。
DATASSEGMENTXdb100dup(?)Ydb100dup(?)Zdb100dup(?)DB'$'FNAMEDB'TEST.TXT',0str1db'pleast...
DATAS SEGMENT
X db 100 dup(?)
Y db 100 dup(?)
Z db 100 dup(?)
DB '$'
FNAME DB 'TEST.TXT',0
str1 db 'pleast input num :$'
STR2 DB 0AH,0DH,'FILE SUCESS! $'
STR3 DB 0AH,0DH,'FILE FAILED'
;此处输入数据段代码
DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
MOV DX,OFFSET str1 ;LEA DX,STR1
MOV AH,09H
INT 21H
MOV BX,0
MOV DX,0
DATA1:
MOV AH,01H
INT 21H
CMP AL,'-'
JZ OUT1
PUSH AX
INC BX
JMP DATA1
OUT1:
MOV CX,BX
MOV SI,0
L1:
POP AX
MOV X[SI],AL
INC SI
LOOP L1
MOV BX,0
DATA2:
MOV AH,01H
INT 21H
CMP AL,'='
JZ OUT2
PUSH AX
INC BX
JMP DATA2
OUT2:
MOV CX,BX
MOV SI,0
L2:
POP AX
MOV Y[SI],AL
INC SI
LOOP L2
MOV SI,0
MOV CX,100
l3:
MOV AL,X[SI]
MOV DL,Y[SI]
CMP AL,DL
JL RESULT2
INC SI
LOOP L3
RESULT1:
CLC
PUSHF
MOV CX,100
MOV DI,99
MOV SI,0
CLT1:
MOV AL,X[SI]
MOV DL,Y[SI]
POPF
SBB AL,DL
AAS
PUSHF
ADD AL,30H
MOV Z[DI],AL
DEC DI
INC SI
LOOP CLT1
MOV SI,0
JMP L4
RESULT2:
CLC
PUSHF
MOV CX,100
MOV DI,99
MOV SI,0
CLT2:
MOV AL,Y[SI]
MOV DL,X[SI]
POPF
SBB AL,DL
AAS
PUSHF
ADD AL,30H
MOV Z[DI],AL
DEC DI
INC SI
LOOP CLT2
MOV SI,0
JMP L5
L4:
CMP Z[SI],30H
JNZ SHOW1
INC SI
JMP L4
SHOW1:
LEA DX,Z[SI]
MOV AH,09H
INT 21H
JMP OUT3
L5:
CMP Z[SI],30H
JNZ SHOW2
INC SI
JMP L5
SHOW2:
MOV DL,'-'
MOV AH,02H
INT 21H
LEA DX,Z[SI]
MOV AH,09H
INT 21H
;此处输入代码段代码
OUT3:
MOV DX,OFFSET FNAME
MOV AH,3CH
INT 21H
JNC OKMSG
LEA DX,STR3
MOV AH,09H
INT 21H
JMP OVER
OKMSG:
LEA DX,STR2
MOV AH,09H
INT 21H
MOV AH,30H
MOV AL,1
INT 21H
MOV AH,40H ;X写
LEA DX,Z
MOV AL,2
MOV BX,AX
MOV CX,100
INT 21H ; 关闭
MOV AH,3EH
INT 21H
MOV AH,30H
MOV AL,1
INT 21H
OVER:MOV AH,4CH
INT 21H
CODES ENDS
END START
前面的减法是对的 但是不知道文件的操作 怎么写进文件 怎么读取 还有文件在哪啊? 展开
X db 100 dup(?)
Y db 100 dup(?)
Z db 100 dup(?)
DB '$'
FNAME DB 'TEST.TXT',0
str1 db 'pleast input num :$'
STR2 DB 0AH,0DH,'FILE SUCESS! $'
STR3 DB 0AH,0DH,'FILE FAILED'
;此处输入数据段代码
DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
MOV DX,OFFSET str1 ;LEA DX,STR1
MOV AH,09H
INT 21H
MOV BX,0
MOV DX,0
DATA1:
MOV AH,01H
INT 21H
CMP AL,'-'
JZ OUT1
PUSH AX
INC BX
JMP DATA1
OUT1:
MOV CX,BX
MOV SI,0
L1:
POP AX
MOV X[SI],AL
INC SI
LOOP L1
MOV BX,0
DATA2:
MOV AH,01H
INT 21H
CMP AL,'='
JZ OUT2
PUSH AX
INC BX
JMP DATA2
OUT2:
MOV CX,BX
MOV SI,0
L2:
POP AX
MOV Y[SI],AL
INC SI
LOOP L2
MOV SI,0
MOV CX,100
l3:
MOV AL,X[SI]
MOV DL,Y[SI]
CMP AL,DL
JL RESULT2
INC SI
LOOP L3
RESULT1:
CLC
PUSHF
MOV CX,100
MOV DI,99
MOV SI,0
CLT1:
MOV AL,X[SI]
MOV DL,Y[SI]
POPF
SBB AL,DL
AAS
PUSHF
ADD AL,30H
MOV Z[DI],AL
DEC DI
INC SI
LOOP CLT1
MOV SI,0
JMP L4
RESULT2:
CLC
PUSHF
MOV CX,100
MOV DI,99
MOV SI,0
CLT2:
MOV AL,Y[SI]
MOV DL,X[SI]
POPF
SBB AL,DL
AAS
PUSHF
ADD AL,30H
MOV Z[DI],AL
DEC DI
INC SI
LOOP CLT2
MOV SI,0
JMP L5
L4:
CMP Z[SI],30H
JNZ SHOW1
INC SI
JMP L4
SHOW1:
LEA DX,Z[SI]
MOV AH,09H
INT 21H
JMP OUT3
L5:
CMP Z[SI],30H
JNZ SHOW2
INC SI
JMP L5
SHOW2:
MOV DL,'-'
MOV AH,02H
INT 21H
LEA DX,Z[SI]
MOV AH,09H
INT 21H
;此处输入代码段代码
OUT3:
MOV DX,OFFSET FNAME
MOV AH,3CH
INT 21H
JNC OKMSG
LEA DX,STR3
MOV AH,09H
INT 21H
JMP OVER
OKMSG:
LEA DX,STR2
MOV AH,09H
INT 21H
MOV AH,30H
MOV AL,1
INT 21H
MOV AH,40H ;X写
LEA DX,Z
MOV AL,2
MOV BX,AX
MOV CX,100
INT 21H ; 关闭
MOV AH,3EH
INT 21H
MOV AH,30H
MOV AL,1
INT 21H
OVER:MOV AH,4CH
INT 21H
CODES ENDS
END START
前面的减法是对的 但是不知道文件的操作 怎么写进文件 怎么读取 还有文件在哪啊? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询