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

Subversion Repositories light52

[/] [light52/] [trunk/] [test/] [hello_asm/] [src/] [hello.a51] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 ja_rd
; hello.a51 -- 'Hello World' on serial console.
2
;
3
; This small program is meant to be run on a light52 MCU on actual hardware,
4
; as a first sanity check.
5
;
6
; This version of the program does not use interrupts.
7
;
8
; If this program runs and displays its message on a terminal, you may then be
9
; sure that your development environment is working.
10
 
11
 
12
        ; Include the definitions for the light52 derivative
13
        $nomod51
14
        $include (light52.mcu)
15
 
16
        ;-- Data variable definitions ------------------------------------------
17
 
18
        ; These are general purpose variables for use in subroutines.
19
        ; They must be saved and restored before use.
20
        var0    data    030h
21
 
22
        ; We'll place the stack above the reg banks and bit addressable area,
23
        ; leaving some space for our stuff (030h to 03fh).
24
        stack   set     040h
25
 
26
        ;-- Macros -------------------------------------------------------------
27
 
28
 
29
        ;-- Reset & interrupt vectors ------------------------------------------
30
 
31
        org     00h
32
        ljmp    start               ;
33
        org     03h
34
        ljmp    irq_unused
35
        org     0bh
36
        ljmp    irq_timer
37
        org     13h
38
        ljmp    irq_unused
39
        org     1bh
40
        ljmp    irq_unused
41
        org     23h
42
        ljmp    irq_uart
43
 
44
        ;-- Main test program --------------------------------------------------
45
        org     30h
46
start:
47
 
48
        ; Set up stack.
49
        mov     SP,#stack
50
 
51
        ; Clear ports P0 and P1, bearing in mind that on the demo platform,
52
        ; P0 is looped back into P2 and P1 to P3, and P1 is also connected to
53
        ; the external irq inputs.
54
        mov     P0,#000h
55
        mov     P1,#000h
56
 
57
        ; Initialize serial port...
58
        ; (actually, leave it with its default configuration: 19200-8-N-1)
59
 
60
        ; ...and dump the hello string to the serial port.
61
        mov     DPTR,#text0
62
        call    po_cstr
63
 
64
 
65
        ; Ok, now
66
        mov     IE,#000h
67
        mov     TSTAT,#000h
68
        mov     TCH,#0fch
69
        mov     TCL,#050h
70
        ; Enable timer interrupts and interrupts globally...
71
        mov     IE,#082h
72
        ; ...and start the timer with autoreload.
73
        mov     TSTAT,#030h
74
 
75
 
76
        ; End of test program, enter single-instruction endless loop.
77
        ; The timer will keep triggering interrupts indefinitely.
78
quit:   ajmp    $
79
 
80
; po_char:  Print character in ACC to console.
81
po_char:
82
        mov     SBUF,a
83
po_char_loop:
84
        jnb     TXRDY,po_char_loop
85
        ret
86
 
87
; po_cstr:  Prints zero-terminated string at XCODE:DPTR to console.
88
;           Returns after the whole string has been output.
89
po_cstr:
90
        push    var0
91
        mov     var0,#000h
92
po_cstr_loop:
93
        mov     a,var0
94
        inc     var0
95
        movc    a,@a+DPTR
96
        jz      po_cstr_done
97
        call    po_char
98
        sjmp    po_cstr_loop
99
po_cstr_done:
100
        pop     var0
101
        ret
102
 
103
        ; Unused interrupt routines, will never be reached.
104
irq_unused:
105
        reti
106
irq_uart:
107
        reti
108
 
109
        ; This timer routine is meant to show that the timer works; all it
110
        ; does is display a message every timer interrupt.
111
irq_timer:
112
        setb    TSTAT.0         ; Clear the timer irq flag writing a 1 on it
113
        push    DPH             ; Write a short message to the console...
114
        push    DPL
115
        mov     DPTR,#text1
116
        call    po_cstr
117
        pop     DPL             ; ...and quit
118
        pop     DPH
119
        reti
120
 
121
text0:  db      'Hello World!',13,10,00h,00h
122
text1:  db      'Tick!',13,10,00h
123
        end

powered by: WebSVN 2.1.0

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