]> Joshua Wise's Git repositories - jwcc.git/blame - examples/libblarg.s
update grammar a bit
[jwcc.git] / examples / libblarg.s
CommitLineData
933e60e3
JW
1 .extern main
2 .global start
3 .section .start
4start:
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
19malloc:
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
29free:
30 pop sp, pc
31
32 .global writestr
33writestr:
341:
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
442:
45 pop sp, pc
46
47 .global printint
48printint:
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
57stack:
58 .space 32*2 @ bytes, not words
59heapend:
60 .word 0
This page took 0.0275 seconds and 4 git commands to generate.