Skip to content

Commit

Permalink
Adding of disassemble directory (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
cardil authored Mar 27, 2023
1 parent 132551d commit 30f2069
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/make.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:

steps:
- uses: ilammy/setup-nasm@v1
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Run test
run: make test
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

### Requirements:

You'd need to have a nasm compiler installed. On Fedora do:
You need to have a nasm compiler installed. On Fedora do:

```shell
dnf install nasm
dnf install -y nasm
```

Run:
Expand Down
19 changes: 19 additions & 0 deletions disassemble/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.PHONY: all
all: target/fib.asm

target/fib.asm: target/fib
objdump --disassemble target/fib > target/fib.asm

target/fib: target fib.c
gcc -Wall -o target/fib fib.c

target:
mkdir -p target

.PHONY: clean
clean:
rm -rf target

.PHONY: test
test: target/fib.asm
@echo -e "\033[92m>> Success!\033[0m"
16 changes: 16 additions & 0 deletions disassemble/fib.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <stdio.h>

int main(void) {
long x, y, z;

x = 0;
y = 1;
while (1) {
printf("%ld\n", x);

z = x + y;
x = y;
y = z;
}

}
2 changes: 1 addition & 1 deletion hello/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ target/hello: target/hello.o
-o target/hello \
target/hello.o

target/hello.o: target
target/hello.o: target hello.asm
nasm -f elf64 \
-o target/hello.o \
hello.asm
Expand Down

0 comments on commit 30f2069

Please sign in to comment.