Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Kyle after assembly mentoring

TODO List for Kyle - Mentoring

"Finish out" the assembly courses

  1. Take your assembly courses and convert your notes into markdown in Github gists.
  2. Pin those gists to your Github profile.

Complete 2 C++ assignments

  1. Assignment 1: Create a class with 2-3 member functions and initialize an instance of the class in main()
  2. Assignment 2: Operator overloading (look at my github for an example!)

Back to JS / React

C++ assignment 1

THE CODE:

Write a HelloWorld C++ class that has two member functions. One function should be called helloWorld() and should print out “Hello World.” The second member function should create a static array of integers and print that out.

  • TIP: First write a C++ function.
  • Then print basic stuff out. LIke the tutorials you'll see on Youtube. PLAY around! This is a good start too! http://cpp.sh/
  • After you can print basic stuff and write a function, stopping at each little step to compile and run your code one line at a time,
  • Then, write a C++ class.
  • But first, get super basic stuff working. Make one line work.
g++ myfile.cpp

^ I compiled this file!

// to run the file, Windows will show you how to run the actual executable file. It's hard to do in Windows.

Test those member functions out by making an instance of the class inside of your main() function. Print basic shit. Get paid. The end.

SECTION 3 CODE: Nice to have/stretch goal: Make a third member function.

The third member function will dynamically create an array of integers. The size of the array will be determined by the user. This function will take a string as an input.

When you call this third member function from main(), you will ask the user “how long should the magic array be?” Then the user will input a number. You’ll probably read this in using stdin or something, and you’ll probably ask the user for input using cout << or something.

Take that number that the user gave you and pass that into the third member function as an argument.

The third member function body (in the class) will dynamically create an array using the “new” keyword. The array will be sized according to the argument passed into the third member function. The function will print out the entire array.

@abstractmachines

This comment has been minimized.

Copy link
Owner Author

@abstractmachines abstractmachines commented Oct 24, 2020

@abstractmachines

This comment has been minimized.

Copy link
Owner Author

@abstractmachines abstractmachines commented Oct 24, 2020

Truth table and Boolean Logic Operators: AND and OR.

AND, OR, NOT .... these are "operators."

1 + 1 = 2
^ The operator there is +.

"Who wrote the rules?"

1 is true.
0 is false.

AND is inclusive. It means BOTH. So we need a "lot to get there" to end up with "true."

  • True AND true = true. 1 AND 1 = 1
  • True AND false = false. 1 AND 0 = 0
  • False AND false = false. 0 AND 0 = 0

OR is "one or the other." It's pretty easy to get "true" with the OR operator.

  • True OR true = true
  • True OR false = true
  • False OR false = false

XOR is "exclusive OR." It means "one or the other, but not both." Very hard to get true.

  • True XOR false = true
  • True XOR true = false
  • False XOR false = false

NAND is "NOT AND."

The "NOT" part is called the complement, which is the engineering word for opposite.

  • True AND true = true. 1 AND 1 = 1
    ^ What's the opposite of that? It's 0.
  • So .... True NAND true = false.

NOR is NOT-OR, and XNOR is NOT-XOR.

Assignment operator =

var a = 1

^ You use an operator =.

const a = 1 // same as var only you can't change a later because it's a constant.

Your crazy assembly question

012B100B  xor         eax,eax 

^ "Why does this zero everything out?"

A = 010
B = 000

What is the result of "A XOR B"? 000.

Let's talk about ASM instructions.

012B100B  xor         eax,eax 
  • xor is the operator.
  • eax,eax are the operands.

In a normal language that's high-level, we would think of this / write it out like eax XOR eax. But ASM is weird and puts the instruction first.

@abstractmachines

This comment has been minimized.

Copy link
Owner Author

@abstractmachines abstractmachines commented Oct 24, 2020

maybe someday stuffs:

  • twos complement
@abstractmachines

This comment has been minimized.

Copy link
Owner Author

@abstractmachines abstractmachines commented Oct 24, 2020

Next up/soon:

  • “what is a variable?”
  • “what is a function?” Talk about the stack
  • heap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment