OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

[/] [eco32/] [trunk/] [stdalone/] [hello/] [hello.s] - Blame information for rev 245

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 18 hellwig
;
2
; hello.s -- Hello, world!
3
;
4
 
5
        .set    tba,0xF0300000          ; terminal base address
6 94 hellwig
        .set    tos,0xC0020000          ; top of stack
7 18 hellwig
 
8
        ; get some addresses listed in the load map
9
        .export start
10 94 hellwig
        .export main
11 18 hellwig
        .export out
12
        .export hello
13
 
14
        ; minimal execution environment
15 94 hellwig
start:
16 18 hellwig
        add     $29,$0,tos               ; setup stack
17 94 hellwig
        jal     main                    ; do useful work
18
start1:
19
        j       start1                  ; halt by looping
20 18 hellwig
 
21
        ; main program
22 94 hellwig
main:
23 18 hellwig
        sub     $29,$29,8               ; create stack frame
24
        stw     $31,$29,0                ; save return register
25
        stw     $16,$29,4               ; save register variable
26
        add     $16,$0,hello             ; pointer to string
27
loop:
28
        ldbu    $4,$16,0         ; get char
29
        beq     $4,$0,stop               ; null - finished
30
        jal     out                     ; output char
31
        add     $16,$16,1               ; bump pointer
32
        j       loop                    ; next char
33
stop:
34
        ldw     $31,$29,0                ; restore return register
35
        ldw     $16,$29,4               ; restore register variable
36
        add     $29,$29,8               ; release stack frame
37
        jr      $31                     ; return
38
 
39
        ; output a character to the terminal
40
out:
41
        add     $8,$0,tba                ; set I/O base address
42
out1:
43
        ldw     $9,$8,8                 ; get xmtr status
44
        and     $9,$9,1                 ; xmtr ready?
45
        beq     $9,$0,out1               ; no - wait
46
        stw     $4,$8,12                ; send char
47
        jr      $31                     ; return
48
 
49
        ; a very famous little string...
50
hello:
51
        .byte   0x0D, 0x0A
52
        .byte   "Hello, world!"
53
        .byte   0x0D, 0x0A
54
        .byte   0x0D, 0x0A, 0

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.