【2014-11-23】《The Hardware/Software Interface》– Section 7

摘要: Cache Definition: computer memory with short access time used for the storage of frequently or recently used instructions or data(i-cachhe and d-cache). more generally, used to optimiz... 阅读全文
posted @ 2014-11-23 14:22 sjtujoe 阅读(117) 评论(0) 推荐(0) 编辑

【2014-11-22】《The Hardware/Software Interface》– Section 6

摘要: Buffer Overflows IA32 Linux Memory Layout Stack Runtime stack (8MB limit) Heap Dynamically allocated storage Allocated by malloc(), calloc(), new()... 阅读全文
posted @ 2014-11-23 12:41 sjtujoe 阅读(105) 评论(0) 推荐(0) 编辑

【2014-11-22】《The Hardware/Software Interface》– Section 5

摘要: Stack-Based Languages Need some place to store state of each instantiation(实例) Arguments Local variables Return pointer 阅读全文
posted @ 2014-11-22 19:32 sjtujoe 阅读(92) 评论(0) 推荐(0) 编辑

【2014-11-22】《The Hardware/Software Interface》– Section 4

摘要: Moving Data: IA32 movx Source, Dest x is one of {b(1-byte), w(2-byte), l(4-byte)} Operand Types Immediate: Constant integer data Example: $0x400, $-533... 阅读全文
posted @ 2014-11-22 18:04 sjtujoe 阅读(135) 评论(0) 推荐(0) 编辑

【2014-11-22】《The Hardware/Software Interface》– Section 3

摘要: The time required to execute a program depends on: The program The compiler The instruction set architecture(ISA) The hardware implementation The ISA defines: T... 阅读全文
posted @ 2014-11-22 16:34 sjtujoe 阅读(216) 评论(0) 推荐(0) 编辑

【2014-11-21】《The Hardware/Software Interface》– Section 2

摘要: printf("Signed Max:%d\n", 0x7FFFFFFF); printf("Signed Min:%d\n", 0x80000000); printf("Unsigned Max:%u\n", 0xFFFFFFFF); printf("Unsigned Min:%u\n", 0x00000000); ... 阅读全文
posted @ 2014-11-22 01:25 sjtujoe 阅读(176) 评论(0) 推荐(0) 编辑

【2014-11-21】《The Hardware/Software Interface》– Section 1

摘要: There are a fixed number of registers in the CPU Registers hold data Data move from Memory to Registers Results move from Registers back to Memory There is an 1-cache in the... 阅读全文
posted @ 2014-11-21 22:31 sjtujoe 阅读(134) 评论(0) 推荐(0) 编辑

【2014-11-19】斐波那契数列

摘要: 1. 递归 f(n) = f(n-1) + f(n-2) 2. 从下向上计算 long long Fibonacci(int n) { int result[2] = { 0, 1 }; if (n < 2) { return result[n]; } long long fibNminusOne... 阅读全文
posted @ 2014-11-19 19:26 sjtujoe 阅读(111) 评论(0) 推荐(0) 编辑

【2014-11-19】字符串转化成整数

摘要: int StrToInt(const char* str) { long long num = 0; bool minus = false; if (str != NULL && *str != '\0') { if (*str == '+') str++; else i... 阅读全文
posted @ 2014-11-19 19:00 sjtujoe 阅读(148) 评论(0) 推荐(0) 编辑

【2014.11.19】程序员面试

摘要: 编写代码时,注意考虑边界条件,特殊输入(比如空指针,空字符串等)及错误处理。空类型。 空类型的实例中不包含任何信息,求sizeof应该是0,但是当我们声明该类型的实例的时候,它必须在内存中占有一定的空间,否则无法使用这些实例。占用多少内存由编译器决定。Visual Studio中,每个空类型的实例占... 阅读全文
posted @ 2014-11-19 16:46 sjtujoe 阅读(188) 评论(0) 推荐(0) 编辑