CS208 Introduction to Computer Systems Monday, 14 October 2024 ----- TO FIND THIS DOCUMENT: - search online for "Jeff Ondich" - go to my homepage - click on the link for this course (CS208 Bridger's section) - click on Class Notes ----- + Today - Assembly language intro & experiments - Some pitfalls + General architecture - Registers - Memory - Some special registers: rip, rsp, EFLAGS - Tanya's diagram and the history of Intel chips (see the history notes below) - Conventional register uses - rax/eax -- return value - rdi/edi -- first parameter of a function - rsi/esi -- second parameter of a function - [see Tanya's diagram] + Playing with Compiler Explorer - Settings (-Og flag; *not* Intel syntax; C, not C++) - Write a function int f(int a, int b) that does: return a + b What does the corresponding assembly look like? - Try some more return a * b return 5 * a + 9 * b - 50 try other formulas - Some of the instructions you might see - mov - add - leal - sub - ret - ... + History: Intel instruction set 1971: 4004 1970s-1980s: 8008, 8080, 8086 8-bit registers registers named a, b, c, etc. 1975: AMD cloned the 8080 1982: 80186, 80286 16-bit registers registers named ax, bx, cx, etc. (x = "extended") 1985: 80386 32-bit registers registers named eax, ebx, ecx, etc. (e = "extended", x = "extended") this language is called "x86" 1991: AMD vs. Intel monopoly lawsuit 1999: x86-64 (also known as x64) 64-bit registers: rax, rbx, etc. (r = register) + Instruction-name weirdness movq $3, %rax -- the q and the rax both say "64 bits" movl $3, %eax -- the l and the eax both say "32 bits" movw $3, %ax -- the w and the ax both say "16 bits" movb $3, %al -- the b and the al both say "8 bits"