5.56 · exercise

How many minutes old?

Read an age in whole years with scanf and print how many minutes that is, counting every year as 365 days. For the input 19:

19 years is 9986400 minutes

The starter has both format strings and a 4-byte slot in .bss, years_in. Call scanf with fmt_in in x0 and the address of years_in in x1, then load the age into years_r.

A year has 525600 minutes, so at 4086 years the answer no longer fits in 32 bits (the largest 32-bit int is 2147483647). Widen the age first: sxtw copies a 32-bit w value into a 64-bit x register and keeps its sign, and mul on x registers then gives the full 64-bit product. %ld prints a 64-bit x register. 525600 is too wide for one mov, so build it with mul from 1440 (minutes in a day) and 365.

What is checked

  • with input 19 the line above is printed
  • the program exits cleanly
  • sxtw widens the age
  • the program also runs on ages you do not see: zero, a negative number, and ages whose minutes do not fit in 32 bits

specification

stdin19
stdoutprints the right output
exitexits with the right code
sourceuses sxtw
hiddenright output and exit code on 5 more inputs you do not see

We run your program on the input above and on the hidden ones, and compare what it does. Nothing is matched against a stored solution.

loading editor...

regfile

N clearZ clearC clearV clear

x0–x30 are the integer registers.

X0arg00x0000000000000000
X1arg10x0000000000000000
X2arg20x0000000000000000
X3arg30x0000000000000000
X4arg40x0000000000000000
X5arg50x0000000000000000
X6arg60x0000000000000000
X7arg70x0000000000000000
X8ind0x0000000000000000
X90x0000000000000000
X100x0000000000000000
X110x0000000000000000
X120x0000000000000000
X130x0000000000000000
X140x0000000000000000
X150x0000000000000000
X16ip00x0000000000000000
X17ip10x0000000000000000
X18pr0x0000000000000000
X190x0000000000000000
X200x0000000000000000
X210x0000000000000000
X220x0000000000000000
X230x0000000000000000
X240x0000000000000000
X250x0000000000000000
X260x0000000000000000
X270x0000000000000000
X280x0000000000000000
X29fp0x0000000000000000
X30lr0x0000000000000000
SP0x0000000080000000
PC0x0000000000400000
console

Output prints here as your program runs.

Press step or run under the editor, or feed stdin from the box below.

not assembled

Open in playground