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

1) Write a function in assembly language. Input a sequence of positive numbers e

ID: 3683390 • Letter: 1

Question

1) Write a function in assembly language. Input a sequence of positive numbers ending with 0. Find the minimum and maximum. For example, input 4, 6, 2, 99, 21, 10, 0. min = 2 and max = 99. The main procedure reads the sequence of the numbers and output the results. The procedure min_max finds the minimum and maximum and return the results to the main procedure.

2) Reverse a string from user input. The main procedure reads the string from the user and pass it to the reverse procedure. The reverse procedure returns the reversed string back to main to be displayed. Example, input hello, output olleh.

Explanation / Answer

#include <conio.h>
#include <stdio.h>
#include <iostream.h>
void main() {
   int N = 10, i;
   clrscr();
   int a[] = { 4, 6, 2, 99, 21, 10, 0}, MAX, MIN, RESULT;

    __asm{
    mov cx, N
    lea si, a
    lodsw
    mov bx, ax
    mov dx, ax
    dec cx }
    m:
       __asm{
     lodsw
     cmp dx, ax
     jge m1
     mov dx, ax
       }
    m1:
       __asm{
       loop m
       mov MAX, dx
    }

cout << "Max = " << MAX;
//cout << "Min = " << MIN;
getch();
}

using c language :-

------------------------

2) String Reverse :-

--------------------------

package com.app;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class StringReverse {
   public static void main(String[] args) throws IOException {
       BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
       System.out.println("Please enter String :");
       String str=br.readLine();
       StringBuffer sf=new StringBuffer(str).reverse();
       System.out.println(sf);
   }

}

output :-

Please enter String :
Mahindra
ardnihaM