修改项目结构
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import UIKit
|
||||
|
||||
var greeting = "Hello, playground"
|
||||
|
||||
|
||||
import UIKit
|
||||
|
||||
// 注释的几种类型
|
||||
// 单行注释
|
||||
|
4
01 注释.playground/contents.xcplayground
Normal file
4
01 注释.playground/contents.xcplayground
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<playground version='5.0' target-platform='ios' buildActiveScheme='true' importAppTypes='true'>
|
||||
<timeline fileName='timeline.xctimeline'/>
|
||||
</playground>
|
BIN
01 注释.playground/playground.xcworkspace/xcuserdata/jiulinxiri.xcuserdatad/UserInterfaceState.xcuserstate
generated
Normal file
BIN
01 注释.playground/playground.xcworkspace/xcuserdata/jiulinxiri.xcuserdatad/UserInterfaceState.xcuserstate
generated
Normal file
Binary file not shown.
@@ -4,7 +4,7 @@
|
||||
<dict>
|
||||
<key>SchemeUserState</key>
|
||||
<dict>
|
||||
<key>SwiftStudy (Playground).xcscheme</key>
|
||||
<key>01 注释 (Playground).xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false/>
|
@@ -1,3 +1,7 @@
|
||||
import UIKit
|
||||
|
||||
var greeting = "Hello, playground"
|
||||
|
||||
//: [Previous](@previous)
|
||||
|
||||
//: ### 常量
|
4
02 数据类型.playground/contents.xcplayground
Normal file
4
02 数据类型.playground/contents.xcplayground
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<playground version='5.0' target-platform='ios' buildActiveScheme='true' importAppTypes='true'>
|
||||
<timeline fileName='timeline.xctimeline'/>
|
||||
</playground>
|
7
02 数据类型.playground/playground.xcworkspace/contents.xcworkspacedata
generated
Normal file
7
02 数据类型.playground/playground.xcworkspace/contents.xcworkspacedata
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:">
|
||||
</FileRef>
|
||||
</Workspace>
|
Binary file not shown.
@@ -1,3 +1,7 @@
|
||||
import UIKit
|
||||
|
||||
var greeting = "Hello, playground"
|
||||
|
||||
//: [Previous](@previous)
|
||||
|
||||
//: ## 区间运算符
|
4
03 流程控制.playground/contents.xcplayground
Normal file
4
03 流程控制.playground/contents.xcplayground
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<playground version='5.0' target-platform='ios' buildActiveScheme='true' importAppTypes='true'>
|
||||
<timeline fileName='timeline.xctimeline'/>
|
||||
</playground>
|
7
03 流程控制.playground/playground.xcworkspace/contents.xcworkspacedata
generated
Normal file
7
03 流程控制.playground/playground.xcworkspace/contents.xcworkspacedata
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:">
|
||||
</FileRef>
|
||||
</Workspace>
|
Binary file not shown.
@@ -1,3 +1,7 @@
|
||||
import UIKit
|
||||
|
||||
var greeting = "Hello, playground"
|
||||
|
||||
//: [Previous](@previous)
|
||||
|
||||
import Darwin
|
4
04 函数.playground/contents.xcplayground
Normal file
4
04 函数.playground/contents.xcplayground
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<playground version='5.0' target-platform='ios' buildActiveScheme='true' importAppTypes='true'>
|
||||
<timeline fileName='timeline.xctimeline'/>
|
||||
</playground>
|
7
04 函数.playground/playground.xcworkspace/contents.xcworkspacedata
generated
Normal file
7
04 函数.playground/playground.xcworkspace/contents.xcworkspacedata
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:">
|
||||
</FileRef>
|
||||
</Workspace>
|
BIN
04 函数.playground/playground.xcworkspace/xcuserdata/jiulinxiri.xcuserdatad/UserInterfaceState.xcuserstate
generated
Normal file
BIN
04 函数.playground/playground.xcworkspace/xcuserdata/jiulinxiri.xcuserdatad/UserInterfaceState.xcuserstate
generated
Normal file
Binary file not shown.
@@ -1,3 +1,7 @@
|
||||
import UIKit
|
||||
|
||||
var greeting = "Hello, playground"
|
||||
|
||||
//: [Previous](@previous)
|
||||
|
||||
import Foundation
|
4
05 枚举.playground/contents.xcplayground
Normal file
4
05 枚举.playground/contents.xcplayground
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<playground version='5.0' target-platform='ios' buildActiveScheme='true' importAppTypes='true'>
|
||||
<timeline fileName='timeline.xctimeline'/>
|
||||
</playground>
|
7
05 枚举.playground/playground.xcworkspace/contents.xcworkspacedata
generated
Normal file
7
05 枚举.playground/playground.xcworkspace/contents.xcworkspacedata
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:">
|
||||
</FileRef>
|
||||
</Workspace>
|
BIN
05 枚举.playground/playground.xcworkspace/xcuserdata/jiulinxiri.xcuserdatad/UserInterfaceState.xcuserstate
generated
Normal file
BIN
05 枚举.playground/playground.xcworkspace/xcuserdata/jiulinxiri.xcuserdatad/UserInterfaceState.xcuserstate
generated
Normal file
Binary file not shown.
@@ -1,9 +1,11 @@
|
||||
import UIKit
|
||||
|
||||
var greeting = "Hello, playground"
|
||||
|
||||
//: [Previous](@previous)
|
||||
|
||||
import Foundation
|
||||
|
||||
var greeting = "Hello, playground"
|
||||
|
||||
//: #### 可选项
|
||||
/*:
|
||||
可选项: 一般也叫可选类型,它允许将值设值为nil
|
4
06 可选项.playground/contents.xcplayground
Normal file
4
06 可选项.playground/contents.xcplayground
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<playground version='5.0' target-platform='ios' buildActiveScheme='true' importAppTypes='true'>
|
||||
<timeline fileName='timeline.xctimeline'/>
|
||||
</playground>
|
7
06 可选项.playground/playground.xcworkspace/contents.xcworkspacedata
generated
Normal file
7
06 可选项.playground/playground.xcworkspace/contents.xcworkspacedata
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:">
|
||||
</FileRef>
|
||||
</Workspace>
|
Binary file not shown.
87
README.md
87
README.md
@@ -1,43 +1,44 @@
|
||||
//## 汇编语言
|
||||
//iOS使用的是AT&T的汇编语言
|
||||
//### 常见的寄存器
|
||||
//16个常用的寄存器
|
||||
//* rax、rbx、rcx 、rdx、rsi、rdi、rbp、rsp
|
||||
//* r8、r9、r10、r11、r12、r13、r14、r15
|
||||
//
|
||||
//寄存器的具体用途
|
||||
//* rax、rdx常作为函数的返回值使用
|
||||
//* rdi、rsi、rdx、rcx、r8、r9等寄存器常用于函数的参数
|
||||
//* rbp、rsp用于栈操作
|
||||
//* rip作为指令指针
|
||||
// * 存储着CPU下一条要执行的指令的地址
|
||||
// * 一旦CPU读取一条指令,rip会自动指向下一条指令
|
||||
//
|
||||
//```java
|
||||
//r开头: 64bit, 8字节
|
||||
//e开头: 32bit, 4字节
|
||||
//ax bx cx: 16bit, 2字节
|
||||
//ah al: 8bit,1字节
|
||||
//bh bl
|
||||
//```
|
||||
//
|
||||
//### 常见的汇编指令
|
||||
//
|
||||
//| 项目名称 | AT&T | Intel | 说明 |
|
||||
//|:-----------:|:---------------------------------------------------:|:----------------------------------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||
//| 寄存器名称 | %rax | rax| |
|
||||
//| 操作数顺序 | mvq %rax, %rdx | mv rdx, rax | 将rax的值赋给rdx|
|
||||
//| 常数\立即数 | movq $3, %rax <br> movq $0x10, %rax | mov rax, 3<br>mov rax, 0x10 | 将3赋值给rax<br>将0x10赋值给rax|
|
||||
//| 内存赋值 | movq $0xa, 0x1ff7(%rip) | mov qword ptr [rip+0x1ff7], 0xa | 将0xa赋值给地址为rip + 0x1ff7的内存空间 |
|
||||
//| 取内存地址 | leaq -0x18(%rbp), %rax | leaq -0x18(%rbp), %rax | 将rbp – 0x18这个地址值赋值给rax |
|
||||
//| jmp指令 | jmp *%rdx <br> jmp 0x4001002 <br> jmp *(%rax) | jmp rdx <br>jmp 0x4001002 <br>jmp [rax] | call和jmp写法类似 |
|
||||
//| 操作数长度 | movl %eax, %edx <br>movb $0x10, %al <br>eaw 0x10(%dx),%ax | mov edx, eax <br> mov al, 0x10 <br> lea ax, [dx + 0x10] | b = byte (8-bit) <br>s = short (16-bit integer or 32-bit floating point) <br>w = word (16-bit) <br>l = long (32-bit integer or 64-bit floating point) <br>q = quad (64 bit) <br>t = ten bytes (80-bit floating point) |
|
||||
//
|
||||
//
|
||||
//### lldb常见的命令
|
||||
//* thread step-over、next、n: 单步运⾏行行,把子函数当做整体⼀一步执⾏行行(源码级别)
|
||||
//* thread step-in、step、s: 单步运⾏行行,遇到子函数会进⼊入子函数(源码级别)
|
||||
//* thread step-inst-over、nexti、ni: 单步运⾏行行,把子函数当做整体⼀一步执⾏行行(汇编级别)
|
||||
//* thread step-inst、stepi、si: 单步运⾏行行,遇到子函数会进⼊入子函数(汇编级别)
|
||||
//* thread step-out、finish: 直接执⾏行行完当前函数的所有代码,返回到上一个函数(遇到断点会卡住)
|
||||
//
|
||||
## 汇编语言
|
||||
iOS使用的是AT&T的汇编语言
|
||||
### 常见的寄存器
|
||||
16个常用的寄存器
|
||||
* rax、rbx、rcx 、rdx、rsi、rdi、rbp、rsp
|
||||
* r8、r9、r10、r11、r12、r13、r14、r15
|
||||
|
||||
寄存器的具体用途
|
||||
* rax、rdx常作为函数的返回值使用
|
||||
* rdi、rsi、rdx、rcx、r8、r9等寄存器常用于函数的参数
|
||||
* rbp、rsp用于栈操作
|
||||
* rip作为指令指针
|
||||
* 存储着CPU下一条要执行的指令的地址
|
||||
* 一旦CPU读取一条指令,rip会自动指向下一条指令
|
||||
|
||||
```java
|
||||
r开头: 64bit, 8字节
|
||||
e开头: 32bit, 4字节
|
||||
ax bx cx: 16bit, 2字节
|
||||
ah al: 8bit,1字节
|
||||
bh bl
|
||||
```
|
||||
|
||||
### 常见的汇编指令
|
||||
|
||||
| 项目名称 | AT&T | Intel | 说明 |
|
||||
|:-----------:|:---------------------------------------------------:|:----------------------------------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||
| 寄存器名称 | %rax | rax| |
|
||||
| 操作数顺序 | mvq %rax, %rdx | mv rdx, rax | 将rax的值赋给rdx|
|
||||
| 常数\立即数 | movq $3, %rax <br> movq $0x10, %rax | mov rax, 3<br>mov rax, 0x10 | 将3赋值给rax<br>将0x10赋值给rax|
|
||||
| 内存赋值 | movq $0xa, 0x1ff7(%rip) | mov qword ptr [rip+0x1ff7], 0xa | 将0xa赋值给地址为rip + 0x1ff7的内存空间 |
|
||||
| 取内存地址 | leaq -0x18(%rbp), %rax | leaq -0x18(%rbp), %rax | 将rbp – 0x18这个地址值赋值给rax |
|
||||
| jmp指令 | jmp *%rdx <br> jmp 0x4001002 <br> jmp *(%rax) | jmp rdx <br>jmp 0x4001002 <br>jmp [rax] | call和jmp写法类似 |
|
||||
| 操作数长度 | movl %eax, %edx <br>movb $0x10, %al <br>eaw 0x10(%dx),%ax | mov edx, eax <br> mov al, 0x10 <br> lea ax, [dx + 0x10] | b = byte (8-bit) <br>s = short (16-bit integer or 32-bit floating point) <br>w = word (16-bit) <br>l = long (32-bit integer or 64-bit floating point) <br>q = quad (64 bit) <br>t = ten bytes (80-bit floating point) |
|
||||
|
||||
|
||||
|
||||
### lldb常见的命令
|
||||
* thread step-over、next、n: 单步运⾏行行,把子函数当做整体⼀一步执⾏行行(源码级别)
|
||||
* thread step-in、step、s: 单步运⾏行行,遇到子函数会进⼊入子函数(源码级别)
|
||||
* thread step-inst-over、nexti、ni: 单步运⾏行行,把子函数当做整体⼀一步执⾏行行(汇编级别)
|
||||
* thread step-inst、stepi、si: 单步运⾏行行,遇到子函数会进⼊入子函数(汇编级别)
|
||||
* thread step-out、finish: 直接执⾏行行完当前函数的所有代码,返回到上一个函数(遇到断点会卡住)
|
||||
|
||||
|
@@ -1,7 +0,0 @@
|
||||
//: [Previous](@previous)
|
||||
|
||||
import Foundation
|
||||
|
||||
var greeting = "Hello, playground"
|
||||
|
||||
//: [Next](@next)
|
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<playground version='6.0' target-platform='ios' display-mode='raw' buildActiveScheme='true' importAppTypes='true'>
|
||||
<pages>
|
||||
<page name='01 注释'/>
|
||||
<page name='02 数据类型'/>
|
||||
<page name='03 流程控制'/>
|
||||
<page name='04 函数'/>
|
||||
<page name='05 枚举'/>
|
||||
<page name='06 可选项'/>
|
||||
<page name='07 汇编分析枚举'/>
|
||||
</pages>
|
||||
</playground>
|
Binary file not shown.
Reference in New Issue
Block a user