Skip to content

Instantly share code, notes, and snippets.

@suqdiq
Created April 15, 2015 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suqdiq/3c5a971a138084f3e09f to your computer and use it in GitHub Desktop.
Save suqdiq/3c5a971a138084f3e09f to your computer and use it in GitHub Desktop.
arvorezinha v1 Alpha Assembly (May/2010)
true64> gcc arvore.S -o arvorezinha
true64> ./arvorezinha
*
**
***
****
*****
true64> cat arvore.S
.data
LF: .ascii "\n\0"
GAY: .ascii "*"
.text
.align 4
.set noreorder
.arch ev4
.globl main
.ent main
main:
ldgp $gp,0($27) # load ao global pointer
stq $26,0($sp) # inicializar o stack pointer (só naquela)
lda $10,5 # RFC_MAX para o loop principal
lda $9,0 # counter do loop1
loop1:
cmpeq $9,$10,$7 # se $9 igual $10, branchar para o final
bne $7,final
lda $11,0 # counter para o loop2
loop2:
cmple $11,$9,$7 # se $11 menor ou igual q $9, estrelar!
bne $7,estrela
lda $16,LF # new line pl0x
jsr $26,printf
ldgp $gp,0($26)
lda $9,1($9) # uma maneira gay de incrementar
br loop1
estrela:
lda $16,GAY # printar estrelinha...
jsr $26,printf # é sempre preciso fazer reset ao $gp
ldgp $gp,0($26) # depois de usar uma função
addq $11,1,$11 # outra maneira gay de incrementar :p
br loop2
final:
mov $31,$0 # return = 0
ldq $26,0($sp) # limpar a stacka, se bem q nao foi usado mas pronto..
ret $31,($26),1 # returnarrrrrrrrr
.end main
true64>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment