C Programming Language. Please write the two programs in C.
Digits
Write this program in a file named digits.c
.
As input, you will define a quad word integer variable named input
in the initialized data section. Choose 0 <= input < 1000 so that the value is representable in three decimal digits.
As output, you will have three quad word integer variables named ones
, tens
, and hundreds
in the uninitialized data section (bss). Your program should calculate the decimal representation of input
, putting the ones place in ones
and so on. The div
instruction will be your primary mathematical tool.
Height
Write this program in a file named height.c
.
The height in an object will reach if it is thrown straight up depends on its initial velocity and the force of gravity, g. The value of g varies depending on what planet/body you are on: on Earth, g is 9.8 m/s^2; on Mars, 3.7 m/s^2; on the Moon, it is 1.6m/s^2.
As input, you will define a double-precision floating-point variable named velocity
in the initialized data section. Similarly define the constant g
(based on Earth).
As output, you will define a double-precision floating-point variable named height
. Calculate height from velocity and g using this formula:
height = (1/2) * (((velocity)^2)/g)
This will use the XMM registers for floating-point calculations.