Laboratory 12 - Problems

Multi-module programming (asm+C)

Problems

For the next problems, at least one subprogram should be implemented in a separated asm module and the main module should be implemented in C:
  1. An unsigned number a on 32 bits is given. Print the hexadecimal representation of a, but also the results of the circular permutations of its hex digits.
  2. Read from the keyboard a string of numbers, given in the base 10 as signed numbers (a string of characters is read from the keyboard and a string of numbers must be stored in the memory).
  3. Two strings containing characters are given. Calculate and display the result of the concatenation of all characters of type decimal number from the second string, and then followed by those from the first string, and vice versa, the result of concatenating the characters from the first string after those from the second string.
  4. A string of numbers is given. Show the values in base 16 and base 2.
  5. Read the signed numbers a, b and c on type byte; calculate and display a+b-c.
  6. Three strings (of characters) are read from the keyboard. Identify and display the result of their concatenation.
  7. Three strings (of characters) are given. Show the longest prefix for each of the three pairs of two strings that can be formed.
  8. Show for each number from 32 to 126 the value of the number (in base 8) and the character with that ASCII code.
  9. Read from the keyboard a string of numbers, given in the base 16 (a string of characters is read from the keyboard and a string of numbers must be stored in memory). Show the decimal value of the number both as unsigned and signed numbers.
  10. Multiple strings of characters are being read. Determine whether the first appears as a subsequence in each of the others and give an appropriate message.
  11. Multiple numbers in base 2 are read from the keyboard. Display these numbers in the base 16.
  12. Two strings of characters of equal length are given. Calculate and display the results of the interleaving of the letters, for the two possible interlaces (the letters of the first string in an even position, respectively the letters from the first string in an odd positions). Where no character exist in the source string, the ‘ ’ character will replace it in the destination string.
  13. Three strings of characters are given. Show the longest common suffix for each of the three pairs of two strings that can be formed
  14. Multiple numbers in base 2 are read from the keyboard. Display these numbers in the base 8.
  15. Read an integer (positive number) n from keyboard. Then read n sentences containing at least n words (no validation needed).
    Print the string containing the concatenation of the word i of the sentence i, for i=1,n (separated by a space).
    Example: n=5
    We read the following 5 sentences:
    We read the following 5 sentences.
    Today is monday and it is raining.
    My favorite book is the one I just showed you.
    It is pretty cold today.
    Tomorrow I am going shopping.

    The string printed on the screen should be:
    We is book cold shopping.

  16. A string containing n binary representations on 8 bits is given as a character string.
    Obtain the string containing the numbers corresponding to the given binary representations.
    Example:
    Given: '10100111b', '01100011b', '110b', '101011b'
    Obtain: 10100111b, 01100011b, 110b, 101011b
  17. Read a string of unsigned numbers in base 10 from keyboard. Determine the maximum value of the string and write it in the file max.txt (it will be created) in 16  base.
  18. Read a string of unsigned numbers in base 10 from keyboard. Determine the minimum value of the string and write it in the file min.txt (it will be created) in 16 base.
  19. Read from file numbers.txt a string of numbers (positive and negative). Build two strings using readen numbers:
    P – only with positive numbers
    N – only with negative numbers
    Display the strings on the screen.
  20. Read from file numbers.txt a string of numbers. Build a string D wich contains the readen numbers doubled and in reverse order that they were read. Display the string on the screen.
    Ex: s: 12, 2, 4, 5, 0, 7 => 14, 0, 10, 8, 4, 24
  21. Read from the console a list of numbers in base 10. Write to the console only the prime numbers.
  22. It is given a number in base 2 represented on 32 bits. Write to the console the number in base 16. (use the quick conversion)
  23. Read a string of integers s1 (represented on doublewords) in base 10. Determine and display the string s2 composed by the digits in the hundreds place of each integer in the string s1.
    Example:    The string s1: 5892, 456, 33, 7, 245
    The string s2: 8,    4,   0,  0, 2

  24. Read a string s1 (which contains only lowercase letters). Using an alphabet (defined in the data segment), determine and display the string s2 obtained by substitution of each letter of the string s1 with the corresponding letter in the given alphabet.
    Example:
    The alphabet:  OPQRSTUVWXYZABCDEFGHIJKLMN
    The string s1: anaaremere
    The string s2: OBOOFSASFS
  25. Read a string of signed numbers in base 10 from keyboard. Determine the maximum value of the string and write it in the file max.txt (it will be created) in 16  base.
  26. Read a string of signed numbers in base 10 from keyboard. Determine the minimum value of the string and write it in the file min.txt (it will be created) in 16 base.
  27. Read from file numbers.txt a string of numbers (odd and even). Build two strings using readen numbers:
    P – only with even numbers
    N – only with odd numbers
    Display the strings on the screen.

  28. Read a sentence from the keyboard containing different characters (lowercase letters, big letters, numbers, special ones, etc). Obtain a new string with only the small case letters and another string with only the big case letters. Print both strings on the screen.
  29. Read a sentence from the keyboard. Count the letters from each word and print the numbers on the screen.
  30. Read a sentence from the keyboard. For each word, obtain a new one by taking the letters in reverse order and print each new word. 

Observatii

  • Se da inseamna ca acele date pot fi puse direct in segmentul de date; se citesc inseamna ca acele date trebuie citite de la tastatura.
  • Daca nu este precizat altfel, numerele se considera reprezentate pe 32 biti fara semn, iar sirurile de caractere de pana la 100 de caractere (sirul propriu-zis).