Home > other >  Keyboard input/assembly language programming statistics. Statistical keyboard input. Any string of c
Keyboard input/assembly language programming statistics. Statistical keyboard input. Any string of c

Time:11-04

Assembly language programming statistical keyboard input,
Statistics and keyboard input from the keyboard input any string of characters, statistics of the number of Numbers, and the number of real-time display on the screen, when the input number is equal to the number 10 end input,
Bosses give directions, and suggests that to use REP MOVSB.

CodePudding user response:

Don't use rep movsb

CodePudding user response:

The DATA SEGMENT
BUF DB 255;
The DB?
The DB 255 DUP (' $')
C DW 0; Digital
M 0 DB dh, 0 ah, "DIGITA: $
"The DATA ENDS

The STACK SEGMENT STACK
The DB 100 DUP (?)
STACK ENDS

CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START:
MOV AX, DATA
MOV DS, AX
MOV ES, AX

; The input string
LEA DX, BUF
MOV AH, AH 0
INT 21 h

CX, XOR CX
MOV CL, BUF + 1
MOV SI, 0
LOOP1:
MOV AL, BUF [SI + 2]
CMP AL, '
JZ LOPEND

INC C; Digital
JMP LOP
LOP:
INC SI
LOOP LOOP1

LOPEND:
; The output

LEA DX, M
MOV AH, 9
INT 21 h

MOV AX, C
CALL the PRINT


; The EXIT TO OS
MOV AH, 4 ch
INT 21 h

PRINT the PROC NEAR
MOV BX, 10
CX, XOR CX
Q0:
XOR DX, DX
DIV BX
The OR DX, 0 e30h
PUSH DX
CX
INC.CMP AX, 0
JNZ Q0
Q1:
POP AX
INT 10 h
LOOP Q1
RET
PRINT ENDP

CODE ENDS

END START

CodePudding user response:

The DATA SEGMENT
BUF DB 255;
The DB?
The DB 255 DUP (' $')

C DW 0; Digital

M 0 DB dh, 0 ah, "DIGITA: $
"The DATA ENDS

The STACK SEGMENT STACK
The DB 100 DUP (?)
STACK ENDS

CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START:
MOV AX, DATA
MOV DS, AX
MOV ES, AX

; The input string
LEA DX, BUF
MOV AH, AH 0
INT 21 h


CX, XOR CX
MOV CL, BUF + 1
MOV SI, 0
LOOP1:
MOV AL, BUF [SI + 2]
CMP AL, '#'
JZ LOPEND
CMP AL, 20 h
JZ T
CMP AL, '0'
JB T1
CMP AL, '9'
JA T1
INC C; Digital
JMP LOP
T:

JMP LOP
T1:

LOP:
INC SI
LOOP LOOP1

LOPEND:

; The output



LEA DX, M
MOV AH, 9
INT 21 h

MOV AX, C
CALL the PRINT


; The EXIT TO OS
MOV AH, 4 ch
INT 21 h

PRINT the PROC NEAR
MOV BX, 10
CX, XOR CX
Q0:
XOR DX, DX
DIV BX
The OR DX, 0 e30h
PUSH DX
CX
INC.CMP AX, 0
JNZ Q0
Q1:
POP AX
INT 10 h
LOOP Q1
RET
PRINT ENDP

CODE ENDS

END START

CodePudding user response:

 
The DATA SEGMENT
BUF DB 255;
The DB?
The DB 255 DUP (' $')

C DW 0; Digital

M 0 DB dh, 0 ah, "DIGITA: $
"The DATA ENDS

The STACK SEGMENT STACK
The DB 100 DUP (?)
STACK ENDS

CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START:
MOV AX, DATA
MOV DS, AX
MOV ES, AX

; The input string
LEA DX, BUF
MOV AH, AH 0
INT 21 h


CX, XOR CX
MOV CL, BUF + 1
MOV SI, 0
LOOP1:
MOV AL, BUF [SI + 2]
CMP AL, '#'
JZ LOPEND
CMP AL, 20 h
JZ T
CMP AL, '0'
JB T1
CMP AL, '9'
JA T1
INC C; Digital
JMP LOP
T:

JMP LOP
T1:

LOP:
INC SI
LOOP LOOP1

LOPEND:

; The output



LEA DX, M
MOV AH, 9
INT 21 h

MOV AX, C
CALL the PRINT


; The EXIT TO OS
MOV AH, 4 ch
INT 21 h

PRINT the PROC NEAR
MOV BX, 10
CX, XOR CX
Q0:
XOR DX, DX
DIV BX
The OR DX, 0 e30h
PUSH DX
CX
INC.CMP AX, 0
JNZ Q0
Q1:
POP AX
INT 10 h
LOOP Q1
RET
PRINT ENDP

CODE ENDS

The END START
  • Related