Assignment Help, Cloud Based ERP System, Microsoft NAV Certification
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.

Assignment Help, Cloud Based ERP System, Microsoft NAV Certification

Stock Market, Online Tutoring, Cloud Based ERP System, Microsoft Dynamics Reporting, Microsoft Nav Certification


You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

1 Assessment Question (8086) on 20th March 2009, 5:05 pm

diadem59

avatar
Administrator
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, 4:32 pm; edited 2 times in total

View user profile

2 Re: Assessment Question (8086) on 20th March 2009, 5:37 pm

diadem59

avatar
Administrator
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.

View user profile

3 Re: Assessment Question (8086) on 20th March 2009, 10:46 pm

jaiparivesh

avatar
Administrator
dhanye baad saathi

View user profile https://www.alertpay.com/?ExlPku5EtIiST4N2a1hiEg%3d%3d

4 Re: Assessment Question (8086) on 24th October 2010, 3:26 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



View user profile

Sponsored content


View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum