Lecture 0:Introduction
约 123 个字 22 行代码 4 张图片 预计阅读时间 1 分钟
Goals of CS 106L
- Learn what features are out there in C++ and why they exist.
- Become comfortable with reading C++ documentation.
- Become familiar with the design philosophy of modern C++.
- NOT: memorize the syntax of C++.
Assembly¶
An example of inline assembly in C++ to print "Hello, world!" to the console:
#include "stdio.h"
#include "stdlib.h"
extern "C" void myputs(char* str) {
printf("%s\n", str);
}
int main(int argc, char *argv[]) {
asm(
"sub $0x20,%rsp\n\t"
"movabs $0x77202c6f6c6c6548,%rax\n\t"
"mov %rax,(%rsp)\n\t"
"movl $0x646c726f, 0x8(%rsp)\n\t"
"movw $0x21, 0xc(%rsp)\n\t"
"movb $0x0,0xd(%rsp)\n\t"
"leaq (%rsp),%rax\n\t"
"mov %rax,%rdi\n\t"
"call myputs\n\t"
"add $0x20, %rsp\n\t"
);
return EXIT_SUCCESS;
}
For the reason that people use different assembly syntax, a code work well on others computer may not work on your machine. C++ is Cross-platform.
Here is a x86 Assembly Guide
Design Philosophy of C++¶
Performance! Performance! Performance!
Smome Command¶
About compiling command
g++ -std=c++17 -Wall streams.cpp -o streams
References¶
Here is the slides of lecture 1
Here is Cpp Core Guidence wirtten by Bjarne Stroustrup and Herb Sutter.



