.MODEL small
.STACK 100h
.DATA
;Variables to store total counts
countAlpha DB ?
countNum DB '0'
countOperator DB '0'
;Message to be displayed with total counts
mesg1 DB "You entered:$"
alphaChars DB ": Alphabet Characters$"
numChars DB ": Numbers$"
operators DB ": Arithematic Characters$"
.CODE
MAIN PROC
MOV ax,@Data
MOV ds,ax
MOV countAlpha ,'0'
MOV Cx, 20
Loop1:
MOV ah,01
int 21h
CMP al,'A'
JGE goToAlpha
CMP al,'0'
JGE goToNum
CMP al,'+'
JE gotoOp
CMP al,'-'
JE gotoOp
CMP al,'*'
JE gotoOp
CMP al,'/'
JE gotoOp
Empty:
CMP al,0DH
JE CountNothing
loop Loop1
goToAlpha:
CMP al,'Z'
JLE gotToAlphaCount
gotToAlphaCount:
INC countAlpha
JMP Empty
goToNum:
CMP al,'9'
JLE gotToNumCount
gotToNumCount:
INC countNum
JMP Empty
gotoOp:
INC countOperator
JMP Empty
CountNothing:
MOV ah,02
MOV dl,0dh
int 21h
MOV dl,0ah
int 21h
MOV ah,09
Lea dx,mesg1
int 21h
;line feed
MOV ah,02
MOV dl,0dh
int 21h
MOV dl,0ah
int 21h
MOV bl,countAlpha
MOV ah,02
MOV dl,bl
int 21h
MOV ah,09
Lea dx,alphaChars
int 21h
MOV ah,02
MOV dl,0dh
int 21h
MOV dl,0ah
int 21h
MOV bl,countNum
MOV ah,02
MOV dl,bl
int 21h
MOV ah,09
Lea dx,numChars
int 21h
MOV ah,02
MOV dl,0dh
int 21h
MOV dl,0ah
int 21h
MOV bl,countOperator
MOV ah,02
MOV dl,bl
int 21h
MOV ah,09
Lea dx,operators
int 21h
MOV ah,4ch
int 21h
MAIN ENDP
END MAIN
Asked
Active
Viewed 33 times
0

David Wohlferd
- 7,110
- 2
- 29
- 56

Tania
- 3
- 3
-
i use emulator to code in Assembly language. – Tania Oct 12 '17 at 02:25
-
3You are using int 21 ah=2 to do the printing. That will print exactly 1 character. If you tell it to print [ascii](http://www.asciitable.com/) character 49 (aka `1`) then that's what it prints. If you tell it to print ascii character 58 (aka `:`) then that's what it prints. If you want to print 2 characters (for example `10`) using int 21 ah=2, you'll need to call it twice. Once for each character. See also [this](https://stackoverflow.com/questions/22909589/displaying-two-digit-numbers-in-assembly). – David Wohlferd Oct 12 '17 at 03:41
-
to add to David comment, you are initializing your counters to value 48, that's the value of ASCII character for digit zero (`48 == '0'`). – Ped7g Oct 12 '17 at 07:37
-
Yes, but I am unable to code the thing I want? Biy confused – Tania Oct 12 '17 at 08:20