Difference between revisions of "CSC231 Exercises with conditional jumps"
(→Characters and lower/upper case conversion) |
|||
Line 1: | Line 1: | ||
+ | __TOC__ | ||
=Exercises on Conditional Jumps= | =Exercises on Conditional Jumps= | ||
Line 15: | Line 16: | ||
Same question, but with '''unsigned double words'''. | Same question, but with '''unsigned double words'''. | ||
+ | |||
+ | |||
+ | ==Characters and lower/upper case conversion== | ||
+ | |||
+ | 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. | ||
+ | |||
+ | Modify the program so that it modifies only characters between 'a' and 'z' included. | ||
+ | |||
+ | ==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? | ||
==Print 2-dimensional arrays== | ==Print 2-dimensional arrays== | ||
Line 38: | Line 59: | ||
j dd 0 | j dd 0 | ||
</pre></code> | </pre></code> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 09:11, 27 October 2008
Contents
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 signed double-words.
Same question, but with unsigned double words.
Characters and lower/upper case conversion
The program makeUpper.asm transforms all characters in a string to uppercase, but will also transform other characters that are not letters.
Modify the program so that it modifies only characters between 'a' and 'z' included.
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?
Print 2-dimensional arrays
Write the code necessary for printing an array of chars (maze) using for-loops depending on i and j indexes.
;;; ------------------------------------------------------------
;;; data areas
;;; ------------------------------------------------------------
section .data
maze db "################################"
maze2 db " # # # "
db "######### # # ####### # #"
db "# # # # #"
db "######### ##############"
db "# #### #"
db "################################"
C equ maze2-maze ; num of columns
R equ 7 ; num of rows
i dd 0
j dd 0