Difference between revisions of "CSC231 Exercises with conditional jumps"

From dftwiki3
Jump to: navigation, search
(Scanning an array)
Line 1: Line 1:
 
=Exercises on Conditional Jumps=
 
=Exercises on Conditional Jumps=
  
 +
<br />
  
 
__TOC__
 
__TOC__
 +
<br />
 +
<br />
 +
<br />
 
==Finding the minimum==
 
==Finding the minimum==
 +
<br />
  
 
Find the minimum of 3 signed int variables a, b, and c
 
Find the minimum of 3 signed int variables a, b, and c
 +
<br />
  
 
==Loop until overflow==
 
==Loop until overflow==
 +
<br />
  
 
Print fibonacci numbers coded as unsigned words until the result overflows. Don't print erroneous numbers!
 
Print fibonacci numbers coded as unsigned words until the result overflows. Don't print erroneous numbers!
  
 +
<br />
  
 
==Scanning an array==
 
==Scanning an array==
 +
<br />
  
Find the '''largest''' element of a 1-dimensional array of '''signed double-words'''.  
+
Find the '''largest''' element of a 1-dimensional array of integers.
 
+
<br />
Same question, but with  '''unsigned double-words'''.
 
  
 
==Characters and lower/upper case conversion==
 
==Characters and lower/upper case conversion==
 +
<br />
  
The program [[CSC231_makeUpper.asm | makeUpper.asm]] transforms all characters in a string to uppercase, but will also transform other characters that are not letters.
+
Write the code necessary to transform a character from lower- to upper-case, if the character is a letter.  The character should not be changed if it is not a letter.
 
+
<br />
Modify the program so that it modifies only characters between 'a' and 'z' included.
 
  
 
==Characters and lower/upper case conversion. Version 2==
 
==Characters and lower/upper case conversion. Version 2==

Revision as of 08:11, 4 November 2014

Exercises on Conditional Jumps





Finding the minimum


Find the minimum of 3 signed int variables a, b, and c

Loop until overflow


Print fibonacci numbers coded as unsigned words until the result overflows. Don't print erroneous numbers!


Scanning an array


Find the largest element of a 1-dimensional array of integers.

Characters and lower/upper case conversion


Write the code necessary to transform a character from lower- to upper-case, if the character is a letter. The character should not be changed if it is not a letter.

Characters and lower/upper case conversion. Version 2

Use a boolean function that returns true or false depending on whether the character it receives is lowercase or not.

Long/short jumps

Conditional jumps can jump only +127 bytes down, -128 bytes up in the code. How can we code something like this:

                 cmp     eax,10
                 jl      there
                 ...
                 ...
        there:   ...


when the instruction at Label there is 1000 bytes away from the jl conditional jump?