Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an assembly program (Include coments for the code and a flow chart) that w

ID: 3869938 • Letter: W

Question

Write an assembly program (Include coments for the code and a flow chart) that will examine an input string. Assume that a string does not include more than one line. Assume the input string is “ Welcome to Assembly Programming @ MSP430! ”. Your program should count the number of total characters, number of uppercase vowels , and number of special characters ( other than characters and digits). Set the port P1 to display the number of special characters , and port P2 to display the number of vowels . Storethe total number of characters in register R10.If you are using the sample string given above for testing, the correct results are shown below (in decimal):

Total Characters:40

Total Uppercase Vowels:1

Total Special Characters:6

Explanation / Answer

title check number of vowels

dosseg

.model small

.stack 100H

.code

main proc

mov ax,@data ;intitialize ds register

mov ds, ax

mov si, offset string

mov cx,length :length in cx register

mov bl,00 ;vowel=0

BACK: mov al,[si]

cmp al,'a' ; alternatively cmp al, 41h for comparing if al =41h

jb AHEAD ;jump below if al<41,discard

cmp al,'z' ; convert the character to upper case

ja VOWEL

sub al, 20h

VOWEL:cmp al, 'A'

jnz a3 ;go to a3 to check nextvowel character

inc bl ; vowel =vowel + 1

jmp a2 ; jump to increment pointer

a3: cmp al,'E'

jnz a4 ;go to a4 to check next vowel charecter

inc bl ;vowel = vowel +1

jmp a2 ; jump to increment pointer

a4: cmp al,'l'

jnz a5; go to a5 to checknext vowel charecter

inc bl ; vowel = vowel +1

jmp a2 ;jump to increment pointer

a5: cmp al, 'o'

jnz a6 ; go to a6 to check next vowel charecter

inc bl ;vowel = vowel +1

jmp a2 ; jump to increment pointer

a6: cmp al,'U'

jmp a2 ; jump to increment pointer

inc bl; vowel =vowel +1

a2: inc si

loop BACK

mov VOWEL, bl

mov ax, 4C00H ; return to DOS

int 21H

main endp

.data

string db 'the quick brown fox jumped over the lazy sleeping dog','s'

length dw $ string

VOWEL db ?

end main

title sample .prog

cstack segment para stack 'stack'

dw 200h

cstack ends

cdata segment para 'data'

msg1 db 'ENTER 9CHARECTER: $',10,13

msg2 db 10,13,'NUMBER OF a: $'

cdata ends

ccode segment para 'code'

assume cs : ccode,ds :cdata,ss: cstack

main:

mov ax , cdata

mov ds , ax

mov ah, 09h

lea dx, msg1

int 21h

mov cl,0

mov bl, 30h

input:

mov ah, 01

int 21h

inc cl

cmp al,61h

je incre

cmp cl,9

je incre

jmp input

incre:

inc bl

cmp cl, 9

jne input

mov ah ,09h

lea dx,msg2

int 21h

mov ah, 02h

mov dh, bl

int21h

mov ah, 4ch

int 21h

ccode ends

end main