我想通过BP修改buf中的内容,程序如下,哪错了?
;输入一个n,显示1-n的所有素数,n最大为65537;n用DB定义即可
ASSUME CS:code,DS:data,SS:stack
stack SEGMENT
SLEN EQU 200
DW SLEN DUP(?)
stack ENDS
data SEGMENT
;'-'==2dH
;'0'==30H
buf DB 10 ;DS:0000H
len DB ?
DB 10 DUP(0)
DB '$'
data ENDS
code SEGMENT
start:
MOV AX,data
MOV DS,AX
MOV ES,AX
MOV AX,stack
MOV SS,AX
MOV SP,SLEN
;---Code Begin
;输入字符串
LEA DX,buf
MOV AH,10
INT 21H
LEA SI,buf
CALL MToNum
;LEA BX,len
;INC BX
;MOV AX,[BX]
;---Code End
MOV AX,0
CALL MCrlf
LEA DX,buf
MOV AH,9
INT 21H
MOV AH,4CH
INT 21H
;***********************************
;-----------------------------------
;ASCII码转数字,覆盖原来的结果
;如:a='1',调用后:a=01H
;void MToNum(Char* bufStr)
;@Pram:
;SI---bufStr
; E.x: LEA SI,bufStr
; CALL MToNum
;-----------------------------------
MToNum PROC
PUSH BP
PUSH CX
INC SI
;取得字符个数,不含回车符
MOV CL,BYTE PTR [SI]
L_MToNum1:
MOV BP,SI
ADD BP,CX
MOV CH,BYTE PTR DS:[BP]
SUB CH,30H
MOV DS:[BP],CH
MOV CH,0
LOOP L_MToNum1
POP CX
POP BP
ret
MToNum ENDP
;-----------------------------------
;数字转ASCII码
;-----------------------------------
MToASCII PROC
ret ;adsf
MToASCII ENDP
;-----------------------------------
;输出回车换行
;-----------------------------------
MCrlf PROC ;asdfa
PUSH DX
PUSH AX
MOV DL, 13
MOV AH, 2
INT 21H
MOV DL, 10
MOV AH, 2
INT 21H
POP AX
POP DX
RET
MCrlf ENDP
code ENDS
END start