Nios/tiling

From ASMBits

nios/shiftlPrevious

You are given a rectangle with width w and height h. There are also rectangular tiles of width w2 and height h2. How many columns and rows of these w2×h2 tiles does it take to completely cover the w×h rectangle?

Write a function that computes the number of columns and rows needed. The function has four parameters: w, h, w2, and h2. Return the number of columns (i.e., in the w direction) in r2, and the number of rows (in the h direction) in r3.

The tiles cannot be rotated. The four input parameters are 32-bit unsigned integers. w2 and h2 are guaranteed to not be zero.


Expected solution length: Around 10 lines.

Sample Input

9 × 8 rectangle, 3 × 2 tiles

Sample Output

r2=3, r3=4

This problem should use the division instructions.

Write your solution here

x
 
1
.global _start
2
_start:
3
    movia r4, 9
4
    movia r5, 8
5
    movia r6, 3
6
    movia r7, 2
7
    call tile
8
    1: br 1b    # Done
9
10
tile:
11
    
12
    
Upload a source file...