📗 -> End of Inline Assembly and Intro to I/O


[Lecture Slide Link]

🎤 Vocab

❗ Unit and Larger Context

Make sure to know:

  1. Structs and how they’re allocated

    1. 1D arrays, except the elements are of different size

      Structs:

      Structs are like 1D arrays with properties being different sizes

      FieldBytes Past Beginning of struct
      x0
      y4
      s5
      name7
      d17
      f25
      Typedef struct Struct_Type{
      	Int x;
      	Char y;
      	Short s;
      	Char name[10];
      	Double d;
      	Float f;
      } Example Struct; 
      
      Link to original
  2. Access memory

    Ordering of Variables

    Global Variables
    • Stored in order of appearance, so the first global will have the lowest address
    Arguments
    • Stored in order of appearance, so the first argument will have the lowest address
    Locals
    • Stored in reverse order of appearance, so the least local will have the lowest address
    Link to original

  3. GCC calling conventions

    • Caller Saved:
      • EAX, ECX, EDX
    • Callee Saved:
      • The rest
  4. How are functions called

    • Calling:
      • push $label_to_continue
      • jmp foo
        or
      • call foo
    • Returning
      • pop %eip
        or
      • ret

✒️ -> Scratch Notes

movs (move string) - Moves a value

  • can be used to implement memcopy
  • “moves a string of bytes, words, or double words from one location to another”
    stos (store string) - Copies
  • can be used for a memset instruction
  • “stores a value (byte, word, or double word) into a memory location, incrementing or decrementing the destination pointer (ES:DI) accordingly”

Resources

  • Put useful links here

Connections

  • Link all related words