Skip to content

Commit

Permalink
add assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
acheronfail committed Dec 19, 2023
1 parent fae1675 commit fae1292
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
strategy:
matrix:
build:
- assembly
- bun
- clang
- crystal
Expand Down Expand Up @@ -61,7 +62,7 @@ jobs:
curl -fsSL https://crystal-lang.org/install.sh | sudo bash
sudo apt-get update
sudo apt-get install -y build-essential cargo clang curl erlang gfortran haskell-platform jq kotlin moreutils nodejs php rustc scala tar wget xz-utils
sudo apt-get install -y build-essential cargo clang curl erlang gfortran haskell-platform jq kotlin moreutils nasm nodejs php rustc scala tar wget xz-utils
cargo install timers
cargo install hyperfine
cargo install ripgrep --features 'pcre2'
Expand Down
25 changes: 25 additions & 0 deletions count.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
section .data
format db "%d", 10, 0

section .text
extern printf
global _start

_start:
xor ecx, ecx

start_loop:
inc ecx
cmp ecx, 1000000000
jl start_loop

; print
mov rdi, format ; rdi: first argument
mov esi, ecx ; esi: second argument
xor eax, eax ; number of vector registers used is 0
call printf

; exit
mov eax, 60 ; system call number for exit
xor edi, edi ; exit code 0
syscall
5 changes: 5 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,8 @@ build-erlang: (_check "erlc erl")

build-crystal: (_check "crystal")
echo 'crystal run ./count.cr' > CMD

build-assembly: (_check "nasm")
nasm -f elf64 count.asm
ld count.o -o count -lc -I/lib64/ld-linux-x86-64.so.2
echo './count' > CMD

0 comments on commit fae1292

Please sign in to comment.