Difference between revisions of "CSC231 Exercises with conditional jumps"
(→Finding the minimum) |
|||
Line 9: | Line 9: | ||
==Finding the minimum== | ==Finding the minimum== | ||
<br /> | <br /> | ||
− | + | :Find the minimum of 3 signed int variables a, b, and c | |
<br /> | <br /> | ||
− | + | <!-- | |
==Loop until overflow== | ==Loop until overflow== | ||
<br /> | <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 /> | <br /> | ||
− | + | --> | |
==Scanning an array== | ==Scanning an array== | ||
<br /> | <br /> | ||
− | + | :Find the '''largest''' element of a 1-dimensional array of integers. | |
− | Find the '''largest''' element of a 1-dimensional array of integers. | ||
<br /> | <br /> | ||
==Characters and lower/upper case conversion== | ==Characters and lower/upper case conversion== | ||
<br /> | <br /> | ||
− | + | :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. | |
− | 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 /> | <br /> | ||
− | |||
==Characters and lower/upper case conversion. Version 2== | ==Characters and lower/upper case conversion. Version 2== | ||
− | + | <br /> | |
− | Use a boolean function that returns true or false depending on whether the character it receives is lowercase or not. | + | :Use a boolean function that returns true or false depending on whether the character it receives is lowercase or not. |
− | + | <br /> | |
==Long/short jumps== | ==Long/short jumps== | ||
− | + | <br /> | |
− | Conditional jumps can jump only +127 bytes down, -128 bytes up in the code. How can we code something like this: | + | :Conditional jumps can jump only +127 bytes down, -128 bytes up in the code. How can we code something like this: |
− | + | <br /> | |
+ | ::<source lang="asm"> | ||
cmp eax,10 | cmp eax,10 | ||
jl there | jl there | ||
Line 45: | Line 43: | ||
there: ... | there: ... | ||
− | + | </source> | |
− | when the instruction at Label ''there'' is 1000 bytes away from the jl conditional jump? | + | <br /> |
+ | :when the instruction at Label ''there'' is 1000 bytes away from the jl conditional jump? | ||
<!-- | <!-- | ||
Line 72: | Line 71: | ||
</pre></code> | </pre></code> | ||
--> | --> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | [[Category:CSC231]][[Category:nasm]][[Category:Exercise]] |
Revision as of 08:13, 4 November 2014
Exercises on Conditional Jumps
Contents
Finding the minimum
- Find the minimum of 3 signed int variables a, b, and c
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?