evian-zhang / assembly-on-macos Goto Github PK
View Code? Open in Web Editor NEWIntroduction to assembly on macOS
Introduction to assembly on macOS
章节:第五章
无法链接对象文件:
❯ ld exit.o -o exit -lSystem
ld: library not found for -lSystem
系统:macOS 12.0.1
有一处小细节,原文:
「比如说八进制数的一位5就代表二进制数的三位011」
5对应的三位二进制应该是101
章节:macOS上的汇编入门(九)——跳转与函数
环境:Mac OS 12.1
# Fibonacci.s
.text
.globl _main
_main:
movq $13, %rdi
callq _Fibonacci
retq
_Fibonacci:
movq $1, %rax
movq $1, %rbx
compare:
cmp $2, %rdi
jg loop_continue
retq
loop_continue:
movq %rax, %rcx
addq %rbx, %rax
movq %rcx, %rbx
decq %rdi
jmp compare
rbx
寄存器(基地址寄存器),最好修改成:rdx
寄存器(数据寄存器),当前版本的系统,退出程序的时候会有以下异常:
Process 82482 launched: '/Users/jaryoung/work/project/c_project/Fibonacci' (x86_64)
Process 82482 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x98)
frame #0: 0x000000010000d501 dyld`start + 465
dyld`start:
-> 0x10000d501 <+465>: movq 0x8(%rbx), %rax
0x10000d505 <+469>: movl 0x34(%rax), %edi
0x10000d508 <+472>: xorl %esi, %esi
0x10000d50a <+474>: callq 0x100039a26 ; dyld3::MachOFile::isSimulatorPlatform(dyld3::Platform, dyld3::Platform*)
Target 0: (Fibonacci) stopped.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.