Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- EXIT = 1
- READ = 3
- WRITE = 4
- STDIN = 0
- STDOUT = 1
- .data
- star: .ascii "*"
- space: .ascii " "
- new_line: .ascii "\n"
- start_height: .long 0
- height: .long 0
- star_countner: .long 1
- .text
- .global _start
- _start:
- movl $READ, %eax # GETTING USER INPUT
- movl $STDIN, %ebx
- movl $height, %ecx
- movl $1, %edx
- int $0x80
- movl height, %esi
- subl $48, %esi # ASCII -> LONG XD
- movl %esi, height
- movl %esi, start_height
- space_loop: # PRINTING SPACES
- movl height, %esi
- cmpl $0, %esi
- je print_trunk # END OF TREE -> PRINT TRUNK
- pushl %esi # 2ND ARGUMENT - NUMBER OF SIGNS TO PRINT
- movl $space, %ecx
- pushl %ecx # 1ST ARGUMENT - SIGN TO PRINT
- decl %esi
- movl %esi, height
- call print
- star_loop: # PRINTING STARS
- movl star_countner, %esi
- pushl %esi
- movl $star, %ecx
- pushl %ecx
- add $2, %esi
- movl %esi, star_countner
- call print
- call print_new_line
- jmp space_loop
- print_trunk:
- movl start_height, %esi
- pushl %esi
- movl $space, %ecx
- pushl %ecx
- call print
- pushl $1
- movl $star, %ecx
- pushl %ecx
- call print
- call print_new_line
- quit:
- movl $EXIT, %eax
- int $0x80
- .type print, @function
- print:
- pushl %ebp
- movl %esp, %ebp
- movl 12(%ebp), %esi
- print_loop:
- cmpl $0, %esi
- je end_loop
- decl %esi
- movl $WRITE, %eax
- movl $STDOUT, %ebx
- movl 8(%ebp), %ecx
- movl $1, %edx
- int $0x80
- jmp print_loop
- end_loop:
- movl %ebp, %esp
- popl %ebp
- ret
- .type print_new_line, @function
- print_new_line:
- movl $WRITE, %eax
- movl $STDOUT, %ebx
- movl $new_line, %ecx
- movl $1, %edx
- int $0x80
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement