Compilation Experiment--classification statistics number of characters Count_char

Source: Internet
Author: User


; ************************************************************ Experiment Code

Datarea segment

Mess1 db ' Please enter character string: ', 13, 10, ' $ '

Mess2 DB ' The number is ', ' $ '

MESS3 DB ' The number of digit is ', ' $ '

MESS4 DB ' The number of other is ', ' $ '

CString label Byte

Max DB 80

Act DB?

CStr db 80D dup (?)

Letter db 0

Digit DB 0

Other DB 0

; number db ' 10 ', ' $ ', ' 11 ', ' $ ', ' 12 ', ' $ ', ' 13 ', ' $ ', ' 14 ', ' $ ', ' 15 ', ' $ '

Number db 41h,42h,43h,44h,45h,46h, ' $ '

Datarea ends

;************************************************************

;************************************************************

Prognam segment

Main Procfar

Assume Ds:datarea,cs:prognam

;--------------------------------------------------------------

Start

Push DS

Sub Ax,ax

Push AX

MOV Ax,datarea

MOV Ds,ax

Lea Dx,mess1; display string

MOV ah,09h

int 21h

Sub Ax,ax; Initial storage unit of count to 0

MOV Letter,al

MOV Digit,al

MOV Other,al

Lea dx,cstring; Type a line of characters

MOV ah,0ah

int 21h

Do you need to change the line?

MOV cl,[cstring+1]; Number of counts of classification

Lea si,cstring+2; The initial pointer points to

Call newline

;----------------------------------------------------------------

Begin

MOV Bl,[si]

;------------------------------------

CMP1:; classify characters

CMP bl, ' 0 '

JNB CMP2

JB Others

CMP2:

CMP bl, ' 9 '

JNA digits

JA cmp3

Cmp3:

CMP bl, ' A '

JNB Cmp4

JB Others

Cmp4:

CMP bl, ' Z '

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.