]> Joshua Wise's Git repositories - jwcc.git/blob - examples/libblarg.s
Add the break.c example
[jwcc.git] / examples / libblarg.s
1         .extern main
2         .global start
3         .section .start
4 start:
5         mov     r0, #_end
6         mov     r1, #heapend
7         sto     [r1], r0
8         mov     sp, #stack
9         mov     r0, #main
10         call    sp, r0
11         push    sp, r0          @ print the return value
12         mov     r0, #printint
13         call    sp, r0
14         mov     r0, #0x1234     @ store to rom to terminate
15         sto     [r0], r0
16
17         .section .text
18         .global malloc
19 malloc:
20         mov     r3, #heapend
21         ldr     r1, [r3]
22         mov     r2, r1
23         add     r2, r0
24         mov     r0, r1
25         sto     [r3], r2
26         pop     sp, pc
27
28         .global free
29 free:
30         pop     sp, pc
31         
32         .global writestr
33 writestr:
34 1:
35         ldr     r3, [r0]        @ load in data
36         mov     r1, #0x0        @ Is the loaded data equal to 0?
37         tst     r3, r1          @ "" ""  ""     ""   ""    "" ""
38         moveq   pc, #2f         @ If so, bail out
39         mov     r1, #0x4000     @ Write address
40         sto     [r1], r3        @ Write the data out
41         mov     r1, #0x1        @ Add one to the write address
42         add     r0, r1          @ ""  ""  "" ""  ""    ""
43         mov     pc, #1b         @ Loop again
44 2:
45         pop     sp, pc
46
47         .global printint
48 printint:
49         mov     r0, #-2
50         add     r0, sp
51         ldr     r0, [r0]
52         mov     r1, #0x4000
53         sto     [r1], r0
54         pop     sp, pc
55
56         .section .bss
57 stack:
58         .space  32*2            @ bytes, not words
59 heapend:
60         .word   0
This page took 0.027098 seconds and 4 git commands to generate.