Skip to content

This is my final project for Robert Antonetti's Spring 2022 Assembly class. I am not using the c library, and the only non-asm code is a python script used for verification

Notifications You must be signed in to change notification settings

msmit5/Assembly_Final-Spring2022

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FINAL 2022

Instructions:

Welcome to the Final Exam!

You have been hired as a Contractor by Stark Industries to help with the development of the Jarvis-2022 Bomb Sight.

Your job will be be write the most critical elements of the Bomb Sight Code.

These include the elements that will retrieve the target data, calculate the drop solution and finally pass the data on for use by other systems.

Good Luck Tony Stark is watching!

Detailed instructions with extra info

The angle of the Target from the Aircraft is A1 and the angle of the Aircraft relative to the vertical y is 90-A1.

The direct distance of the Aircraft to the Target or Range is d.

The Aircraft drops the ordnance, allowing it to free fall to the target.

The Aircraft is traveling a a speed of Vx m/s.

The important equations are;

  1. y=d*cos(90-A1), where A1 is in degrees
  2. x=d*sin(90-A1), where A1 is in degrees
  3. y=0.5*a*t^2, where a=9.8 m/s^2
  4. x’=Vx*t

The vertical distance above ground is measured by a radar altimeter and provided in meters.

Given the knowns above x’, t and d can be solved for.

Note x’ does not equal x.

x’ is the distance the ordinance will travel in time t (the time the ordinance is in free fall).

x is the current x distance to the target.

1a. d=y/cos(90-A1)

2a. From 1a and 1 above solve for x

3a. y is given solve for t or t=sqrt(2y/a)

The cos(x) and sin(x) can be solved for from a Taylor Series Expansion.

sin(x)=(-1^n/(2*n+1)!)*x^(2*n+1) for n=0…

cos(x)=(-1^n/(2*n)!)*x^(2*n) for n=0…

Note x above is in radians where 2*PI radians = 360 degrees…all angles need to be converted to radians from degrees and back!

To restate the following data is provided to the Jarvis-2022.

  1. Vx i m/s
  2. y in m
  3. A1 in degrees

Data will be received as ASC encoded characters in a buffer in the following format;

“UPDATE A1:XXX DEGREES, Y XXX METERS, VX XXX M/S”

Where the X’s indicate ASC digits for the A1, Y and VX values.

The input string must be decoded to extract the required data for calculations.

For the exam simply create test buffers for use in testing your application.

The output of the Jarvis-2022 must be another ASC buffer in the following format;

“SOLUTION DROP IN XXX SECS”

Where XXX represents the drop time in seconds.

The drop time is the time given by (x-x’)/Vx and represents the time delay required to ensure when the ordinance is dropped that it will free fall on to the target.

Note if the drop time is negative this represents the case where the Aircraft is too close for a free fall drop.

The output should be “SOLUTION ABORT!” in this case.

Your application should support a test mode to allow the input of the target data from STDIN (keyboard) and display the results to STDOUT (monitor).

Test mode should be entered by the user inputting ‘TEST’ from STDIN (keyboard).

Test mode should be exited by the user inputting ‘NORMAL’ from STDIN (keyboard).

Please submit your s files, demo snips of your application in operation using the test mode and normal mode along with a word document detailing your design.

Submit all of your results in a single zip file.

Good Luck & have a nice summer break!

Documentation:

CONSTRAINTS:

  • The maximum amount of leading 0s before a number is 12
  • The input into normal mode is assumed to be valid
  • stdout is used as the buffer for normal mode due to time constraints
    • had I been able to use the clib, I would have used sprintf and been done :(
    • it is also possible to read from stdout, so I am assuming that is possible that the other systems could listen to it

Modules

exit.s

exit.s exits the program. It has multiple different versions of the function. All use raw service calls to exit.

exit

exit is the most simple way of exiting, and exits with an exit code of 0

exit_f

Exit syscall but with an exit code of 1

exit_c

exit syscall, but the exit code is expected in r0

ARGUMENTS
  • r0 <– exit code

exit_p

exit syscall, however we will write a message to stdout in the process.

ARGUMENTS

Stack:

  • length of error message (pop 1)
  • address of error message (pop 2)

    r0 <– Exit code

asciiToInt.s

ascii to int takes in an addr of a string of an integer, and returns the integer contained in the string as an integer

asciiToInt

ARGUMENTS
  • r0 <– addr of str
  • r1 <– len of str
RETURNS
  • r0 <– integer

cos.s

cos is a wrapper for sin. It uses trig identities to map all inputs of cos to sin, so I don’t need to implement cosine :)

cos

ARGUMENTS
  • r0 <– input
RETURNS
  • r0 <– result

sin.s

sin uses the taylor series to calculate the sin function. It runs for 35 iterations of it

sin

ARGUMENTS
  • r0 <– input
RETURNS
  • r0 <– result

deg2rad.s

converts degrees to radians, accepting either an int or a float as an arg

deg2rad_int

ARGUMENTS
  • r0 <– integer
RETURNS
  • r0 <– result (float)

deg2rad_float

ARGUMENTS
  • r0 <– float
RETURNS
  • r0 <– result (float)

factorial.s

runs the factorial operation on r0

fac_float

ARGUMENTS
  • r0 <– float
RETURNS
  • r0 <– result (float)

fac_int

ARGUMENTS
  • r0 <– int
RETURNS
  • r0 <– result (int)

fac_int2float

ARGUMENTS
  • r0 <– int
RETURNS
  • r0 <– result (float)

getDropTime.s

runs the calculations to determine when to drop the bomb. I do things very slightly differently than the question calls for, because I use trig identities. Further, I use a slightly different method of getting the final answer (I subtract time to target from drop time)

getDropTime

ARGUMENTS
  • r0 <– angle (degrees, float)
  • r1 <– height (meters, float)
  • r2 <– velocity (m/s, float)
RETURNS
  • r0 <– result

getLeadingZeros.s

gets the amount of leading 0s in the decimal part of a floating point number

getLeadingZeros

ARGUMENTS
  • r0 <– address of float
RETURNS
  • r0 <– result (int)

getLeadingZerosDereferenced

ARGUMENTS
  • r0 <– float
RETURNS
  • r0 <– result (int)

getPart.s

Retrieves the decimal and integral parts of a float. The integral part is returned as an integer, and the decimal part is returned as a float

getIntegralPart

ARGUMENTS
  • r0 <– float
RETURNS
  • r1 <– result (int)

getDecimalPart

ARGUMENTS
  • r0 <– float
RETURNS
  • r1 <– result (float)

getParts

ARGUMENTS
  • r0 <– float
RETURNS
  • r1 <– integral part
  • r2 <– decimal part

main.s

The driver of the program. Reads input, checks modes. CONTAINS THE ENTRY POINT _start

parseNormal.s

parses the string passed in during normal mode operation

parseNormal

ARGUMENTS
  • r0 <– pointer to string
  • r1 <– address of where to store A1
  • r2 <– address of where to store Y
  • r3 <– address of where to store vx
RETURNS:
  • This function does not return anything. Instead, it
    • writes to the mem addresses specified in r1, r2, and r3
    • modifies the string pointed to at r0, such that verifyInput.s can prepare the data for strToFloat.s

pow.s

gets the power of a number

pow_float

ARGUMENTS
  • r0 <– base (float)
  • r1 <– eponent (int)
RETURNS
  • r0 <– result

printDecimal.s

this is the very same printDecimal that I used for program 5. It prints a decimal to stdout

printDecimal

ARGUMENTS
  • r0 <– int (to print)

strToFloat.s

takes in a string and returns the float contained in the str

strtoFloat

ARGUMENTS
  • r0 <– addr of integral part
  • r1 <– len of integral part
  • r2 <– addr of decimal part
  • r3 <– len of decimal part
RETURNS:
  • r0 <– result (float)

verifyInput.s

takes in a string of either an int or a float and verifies that it is a valid number. MUST BE CALLED BEFORE strToFloat or asciiToInt

verifyInputInt

ARGUMENTS
  • r0 <– addr of string
RETURNS
  • r1 <– len of int

verifyInputFloat

ARGUMENTS
  • r0 <– addr of string
RETURNS
  • r0 <– addr of integral part of float (unchanged)
  • r1 <– len of integral part of float
  • r2 <– addr of decimal part of float
  • r3 <– len of decimal part of float

write-float.s

write-float.s prints a floating point number as decimal to stdount.

writeFloat

ARGUMENTS
  • r0 <– address of float

Usage

NORMAL MODE

  • when prompted type NORM

TEST MODE

  • when prmpted type TEST
  • when inputting the number, type in a floating point number WITH THE DECIMAL, it is expected.

About

This is my final project for Robert Antonetti's Spring 2022 Assembly class. I am not using the c library, and the only non-asm code is a python script used for verification

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published