User Tools

Site Tools


notes:notes:comporg:fall2023:projects:cta1

CTA1

Assembly

Storing Data Within the Stack:

With 16 Registers, and only 11 of which can be used for general purpose value storage, it's impossible to store every variable one might need within the Registers only. This can be mediated by using the Stack.

At the beginning of the main function, it's optimal to shove SP down the stack quite a ways, and store your variables within the stack between BP and SP. Use BP as a reference point to access each individual value on the stack.

Note: You'll only be able to access these variables within the main function. Once you enter a sub-function with a sub-stack, you can't use BP as a reference. Thus, when passing variables into functions as parameters, copy and push those variables to the stack first.

Integers and Floats

Upon coding using trigonometry with angle conversions between integers and floats, making use of the CIF (convert int to float) and CFI (convert float to int) instructions was key, along with using the appropriate arithmetic instructions depending on the type of the data contained within registers.

If Statements

If statements in assembly are fairly straightforward:

  1. Declare the If Start
  2. Declare the If End
  3. Use Comparison Operators as you would in C for the If condition
  4. Use a Jump Instruction to check the comparison that points towards the End.
notes/notes/comporg/fall2023/projects/cta1.txt · Last modified: 2023/09/20 20:56 by 127.0.0.1