Skip to content

Commit 8ad29e0

Browse files
committed
started to change formatting to be shown on personal website
1 parent dd08a56 commit 8ad29e0

File tree

148 files changed

+1581
-1568
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+1581
-1568
lines changed

Assembly/x86/_hello

32.1 KB
Binary file not shown.

Assembly/x86/_hello.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// gcc _hello.c -S -O0 -masm=intel -fno-stack-protector
2+
3+
#include <unistd.h>
4+
5+
int main() {
6+
const char message[] = "hello assembly";
7+
syscall(4, STDOUT_FILENO, message, sizeof(message) - 1);
8+
return 0;
9+
}

Assembly/x86/_hello.s

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
.section __TEXT,__text,regular,pure_instructions
2+
.build_version macos, 13, 0 sdk_version 13, 3
3+
.intel_syntax noprefix
4+
.globl _main ## -- Begin function main
5+
.p2align 4, 0x90
6+
_main: ## @main
7+
.cfi_startproc
8+
## %bb.0:
9+
push rbp
10+
.cfi_def_cfa_offset 16
11+
.cfi_offset rbp, -16
12+
mov rbp, rsp
13+
.cfi_def_cfa_register rbp
14+
sub rsp, 32
15+
mov dword ptr [rbp - 4], 0
16+
mov rax, qword ptr [rip + L___const.main.message]
17+
mov qword ptr [rbp - 19], rax
18+
mov eax, dword ptr [rip + L___const.main.message+8]
19+
mov dword ptr [rbp - 11], eax
20+
mov ax, word ptr [rip + L___const.main.message+12]
21+
mov word ptr [rbp - 7], ax
22+
mov al, byte ptr [rip + L___const.main.message+14]
23+
mov byte ptr [rbp - 5], al
24+
lea rdx, [rbp - 19]
25+
mov edi, 4
26+
mov esi, 1
27+
mov ecx, 14
28+
mov al, 0
29+
call _syscall
30+
xor eax, eax
31+
add rsp, 32
32+
pop rbp
33+
ret
34+
.cfi_endproc
35+
## -- End function
36+
.section __TEXT,__cstring,cstring_literals
37+
L___const.main.message: ## @__const.main.message
38+
.asciz "hello assembly"
39+
40+
.subsections_via_symbols

Assembly/x86/hello-x86.asm

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
; 2021-05
2+
; x86-64 (intel syntax)
3+
section .text
4+
global _main
5+
6+
_main:
7+
mov rax, 0x02000004 ; write (4)
8+
mov rdi, 1 ; stdout
9+
mov rsi, message ; address of output
10+
mov rdx, 10 ; bytes : "hello x86" + /n = 10
11+
syscall ; invoke write
12+
mov rax, 0x02000001 ; exit (1)
13+
xor rdi, rdi ; 0
14+
syscall ; invoke to exit
15+
16+
section .data
17+
18+
message:
19+
db "hello x86", 10 ; define byte : text, \n (10)
20+
21+
; $ nasm -f macho64 hello-x86.asm
22+
; $ ld hello-x86.o -o _hello -lSystem -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
23+
; $ ./_hello
24+
; hello x86

C++/basics/_test.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <iostream>
2+
#include <fstream>
3+
#include <ctime>
4+
#include <string>
5+
#include <cmath>
6+
#include <algorithm>
7+
#include <csignal>
8+
#include <vector>
9+
// sleep
10+
#include <unistd.h>
11+
// multithreading
12+
#include <pthread.h>
13+
14+
using namespace std;
15+
16+
int main(int argc, char** argv) {
17+
18+
19+
return 0;
20+
}

0 commit comments

Comments
 (0)