Question

I need the following done in MASM (Assmebly or ASM) This program must use Irvine Library and the outline for the code is...

I need the following done in MASM (Assmebly or ASM)

This program must use Irvine Library and the outline for the code is below (Kip irvine)

Write an assembly language program to input a string from the user. Your program should do these two things:

1. count and display the number of words in the user input string.

2. Flip the case of each character from upper to lower or lower to upper.

For example if the user types in:   "Hello thEre. How aRe yOu?"

Your output should be:

The number of words in the input string is: 5

The output string is : hELLO THeRE. hOW ArE YoU?

Include Irvine32.inc

.data

-

-

-

.code

main proc

-

-

-

-

exit

main ENDP

functions_go_here PROC

-

-

-

ret

functions_go_here ENDP

END main

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:-

1)

DATA SEGMENT
        STR1 DB "ENTER YOUR STRING HERE ->$"
        STR2 DB "YOUR STRING IS ->$"
        STR3 DB "LENGTH OF STRING IS(DIRECT) ->$"
        STR4 DB "LENGTH OF STRING IS(COUNT) ->$"
        INSTR1 DB 20 DUP("$")
        NEWLINE DB 10,13,"$"
        LN DB 5 DUP("$")
        N DB "$"
        S DB ?

DATA ENDS

CODE SEGMENT
        ASSUME DS:DATA,CS:CODE
START:

        MOV AX,DATA
        MOV DS,AX

        LEA SI,INSTR1

;GET STRING
        MOV AH,09H
        LEA DX,STR1
        INT 21H

        MOV AH,0AH
        MOV DX,SI
        INT 21H


        MOV AH,09H
        LEA DX,NEWLINE
        INT 21H

;PRINT THE STRING

        MOV AH,09H
        LEA DX,STR2
        INT 21H

        MOV AH,09H
        LEA DX,INSTR1+2
        INT 21H

        MOV AH,09H
        LEA DX,NEWLINE
        INT 21H

;PRINT LENGTH OF STRING (DIRECT)
        MOV AH,09H
        LEA DX,STR3
        INT 21H

        MOV BL,INSTR1+1

        ADD BL,30H
        MOV AH,02H
        MOV DL,BL
        INT 21H

        MOV AH,09H
        LEA DX,NEWLINE
        INT 21H


;PRINT LENGTH OF STRING ANOTHER WAY

        MOV AH,09H
        LEA DX,STR4
        INT 21H
        
        ADD SI,2
        MOV AX,00


     L2:CMP BYTE PTR[SI],"$"
        JE L1
        INC SI
        ADD AL,1
        JMP L2

     L1:SUB AL,1
        ADD AL,30H
                       
        MOV AH,02H
        MOV DL,AL
        INT 21H


        MOV AH,4CH
        INT 21H


CODE ENDS
END START


;OUTPUT:-
;Z:\SEM3\SS\21-30>P24
;ENTER YOUR STRING HERE ->hELLO THeRE. hOW ArE YoU?
;YOUR STRING IS ->JINESH
;LENGTH OF STRING IS(DIRECT) ->: 25
;LENGTH OF STRING IS(COUNT) ->: 25

2)

.MODEL SMALL
        .DATA

                MSG  DB  0DH,0AH, \' ENTER THE STRING :-----> :  $\'
                MSG2 DB  0DH,0AH, \' YOUR STRING IS  :-----> :  $\'
                STR1 DB  255 DUP(?)
                ONE  DB ?
                TWO  DB ?
          .CODE

BEGIN:
          MOV AX,@DATA
          MOV DS,AX

          LEA DX,MSG
          MOV AH,09H
          INT 21H

          LEA SI,STR1
          MOV AH,01H

READ:
          INT 21H
          MOV BL,AL

          CMP AL,0DH
          JE  DISPLAY

          XOR AL,20H
          MOV [SI],AL
          INC SI

          ;CMP BL,0DH
          JMP READ



DISPLAY:

          MOV AL,\'$\'
          MOV [SI],AL

          LEA DX,MSG2
          MOV AH,09H
          INT 21H


          LEA DX,STR1
          MOV AH,09H
          INT 21H



         ; MOV AH,4CH
         ; INT 21H
          .EXIT



END BEGIN 

;**********************************OUTPUT******************************
;ENTER THE STRING :-----> hELLO THeRE. hOW ArE YoU?
;YOUR STRING IS  :-----> Hello thEre .How arE yOu?
Add a comment
Know the answer?
Add Answer to:
I need the following done in MASM (Assmebly or ASM) This program must use Irvine Library and the outline for the code is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need my c++ code converted to MASM (assembly language). The instructions below: write an assembly...

    I need my c++ code converted to MASM (assembly language). The instructions below: write an assembly program that does the following; 1. count and display the number of words in the user input string. 2. Flip the case of each character from upper to lower or lower to upper. For example if the user types in:   "Hello thEre. How aRe yOu?" Your output should be: The number of words in the input string is: 5 The output string is : hELLO...

  • The program needs to be written in C. Write a function void camelCase(char* word) where word...

    The program needs to be written in C. Write a function void camelCase(char* word) where word consists of more than two words separated by underscore such as “random_word” or "hello_world_my_name_is_sam". camelCase() should remove underscores from the sentence and rewrite in lower camel case” (https:// en.wikipedia.org/wiki/Camel_case). Watch out for the end of the string, which is denoted by ‘\0’. You have to ensure that legal strings are given to the camelCase() function. The program should only run when the input is...

  • //I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which...

    //I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which manipulates text from an input file using the string library. Your program will accept command line arguments for the input and output file names as well as a list of blacklisted words. There are two major features in this programming: 1. Given an input file with text and a list of words, find and replace every use of these blacklisted words with the string...

  • Your program must prompt the user to enter a string. The program must then test the...

    Your program must prompt the user to enter a string. The program must then test the string entered by the user to determine whether it is a palindrome. A palindrome is a string that reads the same backwards and forwards, such as "radar", "racecar", and "able was I ere I saw elba". It is customary to ignore spaces, punctuation, and capitalization when looking for palindromes. For example, "A man, a plan, a canal. Panama!" is considered to be a palindrome....

  • I need this done in C++ No global variables No labels or go-to statements No infinite loops, examples include: for(;;...

    I need this done in C++ No global variables No labels or go-to statements No infinite loops, examples include: for(;;) while(1) while(true) do{//code}while(1); No break statements to exit loops Write a program with three functions: upper, lower, and reverse. The upper function should accept a pointer to a C-string as an argument. It should step through each character in the string, converting it to uppercase. The lower function, too, should accept a pointer to a C-string as an argument. It...

  • Write a program **(IN C)** that displays all the phone numbers in a file that match the area code...

    Write a program **(IN C)** that displays all the phone numbers in a file that match the area code that the user is searching for. The program prompts the user to enter the phone number and the name of a file. The program writes the matching phone numbers to the output file. For example, Enter the file name: phone_numbers.txt Enter the area code: 813 Output: encoded words are written to file: 813_phone_numbers.txt The program reads the content of the file...

  • I need help with a code in assembly language MASM (x86)

    write an assembly language (x86) program to input in a string 10 multi-digit integers and displays them in ascending order. Modify the code below to comply with the requirement..model small.stack 100h.datastrg1 DB 'Insert numbers: $'strg2 DB 'Sorted numbers: $'Arr Db 10 dup(?)v dw ?.codemain procmov ax,@datamov ds,axmov ah,9lea dx,strg1int 21hmov dl,0ahmov ah,2int 21h;inputsmov di,0mov cx,10Input_loop:mov ah,1int 21hmov arr[di],almov dl,0ahmov ah,2int 21hinc diloop Input_loopmov v,0sort:mov di,0mov cx,10sub cx,vB:mov al,Arr[di]cmp al,Arr[di+1]jng Cmov al,Arr[di]xchg al,Arr[di+1]mov Arr[di],alc:inc diloop Binc vcmp v,10jne sort;Outputmov ah,9lea dx,strg2int...

  • LANGUAGE = C i. Write a program that takes int numbers from user until user gives...

    LANGUAGE = C i. Write a program that takes int numbers from user until user gives a sentinel value (loop terminating condition). Sort the numbers in ascending order using Insertion sort method. Sorting part should be done in different function named insertionSort(). Your code should count the number of swaps required to sort the numbers. Print the sorted list and total number of swaps that was required to sort those numbers. (4 marks) ii. In this part take another number...

  • CODE: def censor_words(sentence, list_of_words): """ The function takes a sentence and a list of words as...

    CODE: def censor_words(sentence, list_of_words): """ The function takes a sentence and a list of words as input. The output is the sentence after censoring all the matching words in the sentence. Censoring is done by replacing each character in the censored word with a * sign. For example, the sentence "hello yes no", if we censor the word yes, will become "hello *** no" Note: do not censor the word if it is part of a larger word. For example,...

  • Write the following program in MIPS for use in the SPIM simulator. 1) Determine the number...

    Write the following program in MIPS for use in the SPIM simulator. 1) Determine the number of occurrences of a specific character in a string. The character and the string are input by the user. The program should output Character <ch> occurs in string <string> <n> times.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT