Mais um blog inútil.

Abril 17, 2009

arvorezinha em pdp-11 assembly

Filed under: Arvorezinha — dongs @ 1:13

Exactamente como o título indica.

.globl
.data
star:.byte 52,0
newline:.byte 12,0

.globl  _main
.text
_main:
mov r0, -(sp)
mov r1, -(sp)
mov r2, -(sp)
mov r5, -(sp)

mov $1,r4
_loop1:
mov r4,r3
_loop2:
mov $star, (sp)
jsr pc, *$_printf
dec r3
tst r3
jne _loop2
mov $newline, (sp)
jsr pc, *$_printf
inc r4
cmp $5,r4
jge _loop1

mov (sp)+, r5
mov (sp)+, r2
mov (sp)+, r1
mov (sp)+, r0
rts pc

Testei isto no SIMH, a correr o glorioso 2.11BSD:

# cc -o x x.s
# ./x
*
**
***
****
*****
# uname -a
2.11BSD 2bsd 2.11BSD 2.11 BSD UNIX #1: Fri Jun 9 08:42:54 PDT 1995     root@SSU-64EN137:/usr/src/sys/SYSTEM  pdp11

Comentar

widgeon
widgeon
widgeon
widgeon