汇编语言设计题:从键盘输入一组不超过3位的十进制数,并保存到Array内存单元中,并判断其中的奇数,同时显示到屏幕。(用子程序做)
又是过来要代码的
现在的"大"学生啊
动动脑子写这玩意能用5分钟么
DATA SEGMENT
MSG1 DB 'ENTER NUM:$'
MSG2 DB 'ODDS:$'
MSG3 DB 'ERROR!$'
ARRAY DW 100 DUP(?)
JISHU DW 100 DUP(?)
COUNT DW ?
GeShu DW ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
CALL INPUT
CALL DeJiShu
CALL OUTPUT
GOEND: MOV AH,4CH
INT 21H
DeJiShu PROC NEAR
PUSH CX
PUSH BX
PUSH AX
PUSH SI
MOV CX,COUNT
MOV BX,OFFSET ARRAY
MOV SI,0
MOV GeShu,0
LOP:MOV AX,[BX]
TEST AX,0001H
JZ ADD6
MOV JISHU[SI],AX
ADD SI,2
INC GeShu
ADD6: ADD BX,2
LOOP LOP
POP SI
POP AX
POP BX
POP CX
RET
DeJiShu ENDP
INPUT PROC NEAR
LEA DX,MSG1
MOV AH,09H
INT 21H
MOV SI,0
MOV COUNT,0
INPUT1: CALL DEC_BIN
INC COUNT
CMP DL,','
JE STORE
CMP DL,13
JE EXIT
JMP ERROR
STORE: MOV ARRAY[SI],BX
ADD SI,2
JMP INPUT1
ERROR: CALL CRLF
LEA DX,MSG3
MOV AH,09H
INT 21H
JMP GOEND
EXIT: MOV ARRAY[SI],BX
CALL CRLF
CALL CRLF
RET
INPUT ENDP
DEC_BIN PROC NEAR
MOV BX,0
NEWCHAR:MOV AH,1
INT 21H
MOV DL,AL
SUB AL,30H
JL EXIT1
CMP AL,9D
JG EXIT1
CBW
XCHG AX,BX
MOV CX,10
MUL CX
XCHG AX,BX
ADD BX,AX
JMP NEWCHAR
EXIT1: RET
DEC_BIN ENDP
OUTPUT PROC NEAR
LEA DX,MSG2
MOV AH,09H
INT 21H
MOV SI,0
MOV DI,GeShu
NEXT3:MOV BX,JISHU[SI]
CALL BIN_DEC
MOV DL,','
MOV AH,02H
INT 21H
ADD SI,2
DEC DI
JNE NEXT3
CALL CRLF
RET
OUTPUT ENDP
BIN_DEC PROC NEAR
PUSH BX
PUSH CX
PUSH SI
PUSH DI
MOV CX,100
CALL DEC_DIV
MOV CX,10
CALL DEC_DIV
MOV CX,1
CALL DEC_DIV
POP DI
POP SI
POP CX
POP BX
RET
BIN_DEC ENDP
DEC_DIV PROC NEAR
MOV AX,BX
MOV DX,0
DIV CX
MOV BX,DX
ADD AL,30H
MOV DL,AL
MOV AH,2
INT 21H
RET
DEC_DIV ENDP
CRLF PROC NEAR
PUSH DX
PUSH AX
MOV DL,0DH
MOV AH,2
INT 21H
MOV DL,0AH
MOV AH,2
INT 21H
POP AX
POP DX
RET
CRLF ENDP
CODE ENDS
END START
很简单的题目
没人回答我
只好放答案出来了
不会的就参考一下吧
代码能正常运行的了