Logo 
Search:

Assembly Language Articles

Submit Article
Home » Articles » Assembly Language » Homework HelpRSS Feeds

Count number of a and A from string ”Application of Microprocessor” and give appropriate message

Posted By: Ashton Evans     Category: Assembly Language     Views: 7648

Count number of a and A from string ”Application of Microprocessor” and give appropriate message.

Code for Count number of a and A from string ”Application of Microprocessor” and give appropriate message in Assembly Language

data segment
    string db 'AaaaAAa','$'
    s_size dw $-string
    check1 db 'a'
    check2 db 'A'
    msg1 db 'Total a occurances : $'
    msg2 db 0ah, 0dh, 'Total A occurances : $'
    count_a dw ?
    count_aa dw ?
    count dw 2 dup ('$')
data ends

code segment
    assume cs:code, ds:data
begin:
    mov ax, data
    mov ds, ax
    
    lea si, string
    sub s_size, 01h
    mov cx, s_size

        
counter:
    mov al, [si]

    cmp al, check1
    je check_1

    cmp al, check2
    je check_2

    inc si
    dec cx
    jnz counter
    jmp exit    

check_1:
    add count_a, 01h
    inc si
    dec cx
    jnz counter
    jmp exit

check_2:
    add count_aa, 01h
    inc si
    dec cx
    jnz counter        

exit:
    mov ah, 09h
    lea dx, msg1
    int 21h

mov ax, count_a
or ax, 30h
mov count, ax

    mov ah, 09h
    lea dx, count
    int 21h

    mov ah, 09h
    lea dx, msg2
    int 21h

mov ax, count_aa
or ax, 30h
mov count, ax

    mov ah, 09h
    lea dx, count
    int 21h

    mov ax, 4c00h
    int 21h

code ends
end begin
  
Share: 



Ashton Evans
Ashton Evans author of Count number of a and A from string ”Application of Microprocessor” and give appropriate message is from London, United Kingdom.
 
View All Articles

 

Other Interesting Articles in Assembly Language:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!