Skip to content

Instantly share code, notes, and snippets.

@codekittie
Created December 6, 2020 02:49
Show Gist options
  • Save codekittie/4a7a26921cf3397458eb90173914fbb9 to your computer and use it in GitHub Desktop.
Save codekittie/4a7a26921cf3397458eb90173914fbb9 to your computer and use it in GitHub Desktop.
Print a pyramid of stars
global _start
SECTION .text
_start:
mov r8, 1
loop:
mov rax, 1
mov rdi, 1
mov rsi, star
mov rdx, r8
syscall
mov rax, 1
mov rdi, 1
mov rsi, newline
mov rdx, 1
syscall
add r8, 1
cmp r8, 10
jg return
jmp loop
return:
mov rax, 60
mov rdi, 0
syscall
section .data
star: db "**********"
newline: db 10
@codekittie
Copy link
Author

alex@fatima-Inspiron-5570:~/Code$ nasm -felf64 scratch.asm && ld -o scratch scratch.o && ./scratch
*
**
***
****
*****
******
*******
********
*********
**********

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment