📗 -> 11/18/24: ECS50-L14


🎤 Vocab

❗ Unit and Larger Context

Small summary

✒️ -> Scratch Notes

Syntax For Inline

  • Read inputs section first
  • Inline will save registers you “tell them about” and restore them after execution
    • Could mess things up if you don’t tell it about it and use it anyway
  • Does not follow GCC calling conventions
  • +a (a)
    • Applied in output section
    • Before runs a will go to EAX (a -> EAX)
    • EAX will be copied to a (EAX -> a)
  • can use “r” to refer to any register
    • “+r” (a), “=r” (temp)
      • // a -> random register, random register -> a on output
      • // random register -> temp
  • m - Memory
  • g - General?
  • “Compiler assumes that you will not write to outputs before you are done using all of your inputs”
  • [b] "m" (b) - m makes b be stored in memory
__asm__(
assembly code :
outputs :
inputs : 
clobbered 
);
// outputs,inputs, and clobbered are all optional
int abcAdd(int a, int b) {
	int result;
	__asm__(
	"movl eax;"
	"addl eax;"
	"movl $12, %%edx;" :
	"=a (result)" : // = sign means that result will be overwritten
	// After code runs, copy EAX into result
	// =S (result) would mean copy ESI into result
	"b" (b), "c" (a) : // b -> EBX and c -> ECX
	"cc", "%edi" // This tells it things to modify
	// modify "cc" flags
	// modify "edi"
	)
}

🧪 -> Refresh the Info

Did you generally find the overall content understandable or compelling or relevant or not, and why, or which aspects of the reading were most novel or challenging for you and which aspects were most familiar or straightforward?)

Did a specific aspect of the reading raise questions for you or relate to other ideas and findings you’ve encountered, or are there other related issues you wish had been covered?)

Resources

  • Put useful links here

Connections

  • Link all related words