Show and tell: I was just plain lazy and didn't bring anything Maybe I'll bring a horrible hacked-together guitar amp next time... A helpful manual: https://ftp.gnu.org/old-gnu/Manuals/gas-2.9.1/html_chapter/as_7.html Note: It's old, but I don't actually think any of that stuff has changed Go read "Deep C Secrets" too, even though it's also old gas, gcc, ld, as, tools A few notes: .asciz and .ascii: .asciz null-terminates .global and .globl mean the same thing I've been paid money to write C/C++, but not assembly I'm sure it shows Alright, interop with C: No, you can't just do the class in C now I want to show the value of calling conventions I also want to show a way you can use a little assembly Call a C function we wrote from assembly: Write the C function in a .c file (NO main) Write the assembly program in a .s file (Include main here) Make sure the name of the function is global (or globl) Assume the C function follows x86-64 SysV calling convention Build like this: gcc -static -z noexecstack asm_file.s c_file.c gcc will (hopefully!) build you an a.out binary (maybe) big caveat: My demo was br0k3d on FreeBSD The heap doesn't work Let's make an example! Call an assembly function from a C program: Write the C program in a .c file (Include main here) (optional) Include a C function prototype If you don't do this, the compiler can't do type checking Write the assembly function in a .s file (do NOT include main) Assume x86-64 SysV calling convention Build like this (same as the previous example): gcc -static -z noexecstack asm_file.s c_file.c gcc will (hopefully!) build you an a.out binary Let's make an example of that too! Alright, how well do we understand assembly functions? Can we write a recursive factorial function? Do we have to: Actually denote sections? Declare main global? Trigger interrupt 80 at the end? Build with gcc? Did I get here early? Alright, let's make up an in-class exercise!