Question

5. Assume double-word references to memory and that count is in ECX. Give a fragment of assembly code that implements the design structures shown. The code should flow the same as the design: a. Ifcoun> value then end if fa+b- count 0; b. Assume the character check is in AL Then Else end if f(ch 2 a) and (ch s z) check Y check N c. Assume ch is in AL then add 1 to lowerCount else f (ch 2 A) and (ch s z) then else end if add 1 tu upperCount; add I to otherCount; end if

In assembly code, and if you're writing it out please write neatly so I can be able to read it. Thank you.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

(a) :-

        cmp ecx,[value]   ;; compare value with ecx (if count>value)
        jle endif
        mov ecx,0         ;; make count (ecx) 0
endif:

(b) :-

        push ecx
        mov ecx,[a]
        add ecx,[b]        ;; add a with b to compare (a+b)
        cmp ecx,[c]       ;; check condition (a+b == c)
        jne else           ;; jmp to else if (a+b) not equal to c (a+b != c )
        mov al,'Y'         ;; move 'Y' in al (check = 'Y')
        jmp endif
else:
        mov al,'N'         ;; move 'N' in al (check = 'N')
endif:
        pop ecx

(c) : -

        cmp al,'a'       ;; compare al with 'a'
        jl else          ;; jump to label (else) if al < 'a'
        cmp al,'z'       ;; compare al with 'z'
        jg else          ;; jump to label (else) if al > 'z'
if:     
        mov ecx,lowerCount
        inc dword[ecx]   ;; increament lowerCount by 1 (add 1 into lowerCount)
        jmp endif
else:
        cmp al,'A'       ;; compare al with 'A'
        jl else1         ;; jump to label (else1) if al < 'A'
        cmp al,'Z'       ;; compare al with 'Z'
        jg else1         ;; jump to label (else1) if al > 'Z'
innerif:        
        mov ecx,upperCount
        inc dword[ecx]   ;; increament upperCount by 1 (add 1 into upperCount)
        jmp endif
else1:  
        mov ecx,otherCount
        inc dword[ecx]   ;; increament otherCount by 1 (add 1 into otherCount)
        jmp endif
endif:
Add a comment
Know the answer?
Add Answer to:
In assembly code, and if you're writing it out please write neatly so I can be...
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
  • 1. Assume that you are given values in eax, ebx, ecx. Write an assembly code that...

    1. Assume that you are given values in eax, ebx, ecx. Write an assembly code that does the following: eax = (ecx + edx ) - (eax + ebx) 2. Write a piece of code that copies the number inside al to ch. Example: Assume that Initially eax = 0x15DBCB19. At the end of your code ecx = 0x00001900. Your code must be as efficient as possible. 3. You are given eax = 0x5. Write one line of code in...

  • Can someone please edit my current code to accept a user input for the text file...

    Can someone please edit my current code to accept a user input for the text file name in lieu of how it currently will read data1.txt. Also if the user enters a data file that isn't ready to be used, cout a statement "cout << "Could not open file " << userInputforData.txt << endl; Another condition that I need to add is if there is a special character anywhere in the word it cannot be an acceptable variable name. could...

  • 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...

  • C Language! Please, comment what each line of code does in the code below and answer...

    C Language! Please, comment what each line of code does in the code below and answer this question: (sentence is fine) 1. Aside from pressing ctrl-(d/z) at the beginning of a line causing the getnchar() function to return NULL, is there any way to enter less than 9 characters? Code: void exer1(void) {    char input[LEN];    char *check; getchar(); // Clearing character buffer. printf("Please enter 9 characters: "); // Prompting the user to enter // a specific input.   ...

  • I need help creating this code. Write an assembly program (MASM and Irvine's libraries) that calculates...

    I need help creating this code. Write an assembly program (MASM and Irvine's libraries) that calculates and prints out the first five Fibonacci numbers FO=0; F1=1; F2=1; F3=F1+F2; F4=F3+F2; F5=F4+F3 If we use 0, 1 and initial conditions the sequence would be: 0, 1, 1, 2, 3 Use the ebx, eax, and ecx registers. Note WriteHex, Writelnt, WriteDec, all use eax So use ebx for first and eax for second and ecx for temporary The calculation could go something like...

  • Write an assembly language code for the following pseudo code i. if(op1 == op2) x=1; else...

    Write an assembly language code for the following pseudo code i. if(op1 == op2) x=1; else x=2; using x86 assembly language

  • C++ problem where should I do overflow part? in this code do not write a new...

    C++ problem where should I do overflow part? in this code do not write a new code for me please /////////////////// // this program read two number from the user // and display the sum of the number #include <iostream> #include <string> using namespace std; const int MAX_DIGITS = 10; //10 digits void input_number(char num[MAX_DIGITS]); void output_number(char num[MAX_DIGITS]); void add(char num1[MAX_DIGITS], char num2[MAX_DIGITS], char result[MAX_DIGITS], int &base); int main() { // declare the array = {'0'} char num1[MAX_DIGITS] ={'0'}; char...

  • 01) Write PIC24 assembly language equivalents for the Sollowing C code fragments. Assume variables u16 iul...

    01) Write PIC24 assembly language equivalents for the Sollowing C code fragments. Assume variables u16 iul kal6 j.ul6 n are uintl6 variables, while uš p, u8 q, u8 rare uin variables 1. Code fragent 2. Code fragment . Code frapent (use place holders for if-body, else-body) if-body statements else-body statements 4. Code fragent (use place holders for if-body, else-body) if-body statements l else I else-body statenents 5. Code frapent (use place holders for loop-body) &. Code fragent (use place holders...

  • Write a program in 68K assembly code that adds an odd parity to each ASCII character....

    Write a program in 68K assembly code that adds an odd parity to each ASCII character. Your code must satisfy the following specifications: 1. Define the following 64 characters in the SRC address.SRC:DC.B 'Computing and Software Systems, University of Washington Bothell' 2. Define the 64-byte space.DST:DC.B 64 3. Read each of the 64 characters, (i.e., each byte) into D0, check the number of 1s in it, set 1 to the MSB with "ORI.B #$80, D0" to create an odd parity,...

  • Problem #2 (20pts) Please write the MIPS assembly code corresponding to the following C code segment....

    Problem #2 (20pts) Please write the MIPS assembly code corresponding to the following C code segment. Assume that f is assigned to register $s2 int Example int i, int j, int k) int f; f i+j-k-1: return fi

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