https://github.com/xgqfrms/assembly
assembly & 汇编
https://github.com/xgqfrms/assembly
assembly c c-plus-plus c-sharp rust webassembly
Last synced: 2 months ago
JSON representation
assembly & 汇编
- Host: GitHub
- URL: https://github.com/xgqfrms/assembly
- Owner: xgqfrms
- License: mit
- Created: 2018-10-20T16:09:16.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-09-07T14:19:53.000Z (almost 4 years ago)
- Last Synced: 2025-06-10T14:07:00.868Z (about 1 year ago)
- Topics: assembly, c, c-plus-plus, c-sharp, rust, webassembly
- Language: C#
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# assembly
> assembly & 汇编
## C language `.c`
> C
## C Plus Plus `.cpp`
> C ++
## C Sharp `.cs`
> C#
https://www.w3schools.com/cs/
## Objective C `.oc`
> OC
https://www.runoob.com/ios/ios-objective-c.html
***
## 汇编语言
https://www.bilibili.com/video/av28132657
http://c.biancheng.net/view/3294.html
https://zhuanlan.zhihu.com/p/23618489
```sh
# 环境安装
$ brew install gcc nasm gcc-multilib -y
# $ sudo apt-get install gcc nasm vim gcc-multilib -y
# 重装 nasm
$ brew reinstall nasm
$ nasm -v
# NASM version 2.14.02 compiled on Dec 27 2018
$ gcc -v
# Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
# Apple LLVM version 10.0.1 (clang-1001.0.46.4)
# Target: x86_64-apple-darwin18.7.0
# Thread model: posix
# InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ which nasm
# /usr/bin/nasm
$ which gcc
# /usr/bin/gcc
```
```sh
# 编译
# abc.asm => abc.o
$ nasm -f elf abc.asm -o abc.o
# abc.o => abc
$ gcc -m32 abc.o -o abc
# The i386 architecture is deprecated for macOS, ..., symbol(s) not found for architecture i386
$ gcc -m64 abc.o -o abc
# Undefined symbols for architecture x86_64:
$ gcc macho64 abc.o -o abc
# clang: error: no such file or directory: 'macho64'
# 查看编译后的文件
$ ls -al
# abc abc.o abc.asm
# 运行
$ ./abc ; echo $?
```
```sh
$ nasm -f macho64 -o hello-world.o hello-world.asm
$ ld -o hello-world -e _main hello-world.o
# ld: warning: No version-min specified on command line
# ld: dynamic main executables must link with libSystem.dylib for inferred architecture x86_64
$ ./hello-world
```