Kantipur Forum - a real solution
WELCOME !!

Please Register, ask for assignment solutions & post the solutions if you know any.

LETS START POSTING YOUR IDEAS AND THOUGHTS AND BUILD THE COMMUNITY OF EXPERTS.



ASK FOR SOLUTION YOU WILL BE SATISFIED
HomeGalleryFAQSearchCalendarRegisterLog in

Assessment Question (8086) 5 5 1
Share | 
 

 Assessment Question (8086)

View previous topic View next topic Go down 
AuthorMessage
diadem59
Administrator


Number of posts: 35
Age: 24
Location: Kathmandu
faculty: BCT III/I
Points: 256
Reputation: 14
Registration date: 2009-03-01

PostSubject: Assessment Question (8086)   20th March 2009, 1:50 pm

Write an assembly language program for 8086 to read a string, count the number of lowercase characters, uppercase characters, digits and other characters present in the string and display in the following format in a clear screen-

Entered String- We have to pay 13% VAT.
Uppercase Characters- 4
Lowercase Characters- 10
Digits- 2
Others- 7

SOLUTION:
Code:

TITLE READ AND COUNT CHARACTERS
;DOSSEG ;Use for DOS Debug
.MODEL SMALL
.STACK 64H
.DATA
    REQ    DB    'Enter a String:',0AH,0DH,'$'
    ENST    DB    'Entered string- ','$'
    UC    DB    0AH,0DH,'Uppercase Characters- ','$'
    LC    DB    0AH,0DH,'Lowercase Characters- ','$'
    DG    DB    0AH,0DH, 'Digits- ','$'
    OT    DB    0AH,0DH,'Others- ','$'

    MAX    DB    50H
    ACT    DB    ?
    CHAR    DB    50H DUP (?)
   
    COUNTS    DB    4H DUP (0)
    TEMP    DB    3H DUP (?)
    DIVS    DB    0AH
   

.CODE
MAIN    PROC
    MOV AX,@DATA
    MOV DS,AX
   
    MOV AH,09H    ;Displays Request
    LEA DX,REQ
    INT 21H

    MOV AH,0AH    ;Reads String
    LEA DX, MAX
    INT 21H

    MOV CH,00H
    MOV CL,ACT
    MOV DI,00H

Agn:    CMP CHAR[DI],'0'   
    JB Others
    CMP CHAR[DI],'9'
    JA CmpUp
    INC COUNTS[2]    ;Increases Digit's Count
    JMP NxtChar

CmpUp:    CMP CHAR[DI],'A'
    JB Others
    CMP CHAR[DI],'Z'
    JA CmpLo
    INC COUNTS[0]    ;Increases Uppercase Character's Count
    JMP NxtChar


CmpLo:    CMP CHAR[DI],'a'
    JB Others
    CMP CHAR[DI],'z'
    JA Others
    INC COUNTS[1]    ;Increases Lowercase Character's Count
    JMP NxtChar

Others:    INC COUNTS[3]    ;Increases Other's Count
NxtChar:    INC DI
    LOOP Agn
    MOV CHAR[DI],'$'
   
    MOV AX,0600H    ;Clear Screen
    MOV BH,07H
    MOV CX,0000H
    MOV DX,184FH
    INT 10H   
   
    MOV AH,02H  ;Set Cursor Position
    MOV BH,00H  ;Page
    MOV DX,00H
    INT 10H

    MOV AH,09H    ;Displays First Line of Output
    LEA DX,ENST
    INT 21H
    LEA DX,CHAR
    INT 21H

    LEA DX,UC    ;Displays Second Line of Output
    INT 21H
    MOV DI,00H
    CALL DISPCOUNT   
   
    MOV AH,09H    ;Displays Third Line of Output
    LEA DX,LC
    INT 21H
    MOV DI,01H
    CALL DISPCOUNT
   
    MOV AH,09H    ;Displays Forth Line of Output
    LEA DX,DG
    INT 21H
    MOV DI,02H
    CALL DISPCOUNT

    MOV AH,09H    ;Displays Fifth Line of Output
    LEA DX,OT
    INT 21H
    MOV DI,03H
    CALL DISPCOUNT   

    MOV AX,4C00H
    INT 21H
MAIN    ENDP


DISPCOUNT PROC;Displays the Content of array 'COUNTS' as indicated by 'DI'

    MOV SI,00H
    MOV AH,00H
    MOV AL,COUNTS[DI]
Rediv:    DIV DIVS
    MOV TEMP[SI],AH
    INC SI
    MOV AH,00H
    TEST AL,0FFH
    JNZ Rediv
   
    MOV AH,02H
Nxt:    DEC SI
    MOV DL,TEMP[SI]
    ADD DL,30H
    INT 21H
    TEST SI,0FFFFH
    JNZ Nxt

    RET   
DISPCOUNT    ENDP

END    MAIN




Last edited by diadem59 on 21st March 2009, 1:17 pm; edited 2 times in total
Back to top Go down
View user profile
diadem59
Administrator


Number of posts: 35
Age: 24
Location: Kathmandu
faculty: BCT III/I
Points: 256
Reputation: 14
Registration date: 2009-03-01

PostSubject: Re: Assessment Question (8086)   20th March 2009, 2:22 pm

NOTE: In above Program, if You type '$' inside a string then it will display only the characters before '$'. You can modify it to display '$' by using function 13H of INT 10H.


Back to top Go down
View user profile
jaiparivesh
Administrator


Number of posts: 75
Age: 25
Location: earth
faculty: bct/2/2
Points: 89
Reputation: 1
Registration date: 2009-02-28

PostSubject: Re: Assessment Question (8086)   20th March 2009, 7:31 pm

dhanye baad saathi


Back to top Go down
View user profile https://www.alertpay.com/?ExlPku5EtIiST4N2a1hiEg%3d%3d
vatansever223



Number of posts: 3
Location: gagawga
faculty: Computer
Points: 3
Reputation: 0
Registration date: 2010-10-24

PostSubject: Re: Assessment Question (8086)   24th October 2010, 12:11 pm

if You type '$' inside a string then it will display only the characters before '$'. You can modify it to display '$' by using function 13H of INT 10H.

____________
bwin poker telecharger
neon signs





Back to top Go down
View user profile
 

Assessment Question (8086)

View previous topic View next topic Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Kantipur Forum - a real solution :: Computer and Technology :: Programming :: Application Development :: Assembly Langauge :: 8086 Solutions-
Jump to:  
Free forum | © phpBB | Free forum support | Contact | Report an abuse | Free forums