Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / devs / diskimage / support / amigaos / asprintf.s
blobd42640acd74eda56ad2aa3a0a2f116123b2d0380
1 ; Copyright 2007-2012 Fredrik Wikstrom. All rights reserved.
3 ; Redistribution and use in source and binary forms, with or without
4 ; modification, are permitted provided that the following conditions
5 ; are met:
7 ; 1. Redistributions of source code must retain the above copyright
8 ; notice, this list of conditions and the following disclaimer.
10 ; 2. Redistributions in binary form must reproduce the above copyright
11 ; notice, this list of conditions and the following disclaimer in the
12 ; documentation and/or other materials provided with the distribution.
14 ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
15 ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
18 ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 ; POSSIBILITY OF SUCH DAMAGE.
26 INCLUDE LVOs.i
28 XREF _SysBase
30 XDEF _SNPrintf
31 _SNPrintf:
32 pea 16(a7)
33 move.l 16(a7),-(a7)
34 move.l 16(a7),-(a7)
35 move.l 16(a7),-(a7)
36 bsr.s _VSNPrintf
37 add.l #16,a7
38 rts
40 XDEF _VSNPrintf
41 _VSNPrintf:
42 movem.l a2/a3/a6,-(a7)
43 move.l 24(a7),a0
44 move.l 28(a7),a1
45 lea SNPrintfPutCh(pc),a2
46 lea 16(a7),a3
47 move.l _SysBase,a6
48 jsr _LVORawDoFmt(a6)
49 movem.l (a7)+,a2/a3/a6
50 rts
52 XDEF _ASPrintf
53 _ASPrintf:
54 pea 8(a7)
55 move.l 8(a7),-(a7)
56 bsr.s _VASPrintf
57 addq.l #8,a7
58 rts
60 XDEF _VASPrintf
61 _VASPrintf:
62 movem.l a2/a3/a6,-(a7)
63 move.l 16(a7),a0
64 move.l 20(a7),a1
65 clr.l -(a7)
66 lea CountPutCh(pc),a2
67 move.l _SysBase,a6
68 move.l a7,a3
69 jsr _LVORawDoFmt(a6)
70 move.l (a7),d0
71 moveq.l #0,d1
72 jsr _LVOAllocVec(a6)
73 move.l d0,-(a7)
74 bne.s gotmem
75 addq.l #8,a7
76 movem.l (a7)+,a2/a3/a6
77 rts
78 gotmem:
79 move.l 24(a7),a0
80 move.l 28(a7),a1
81 lea SNPrintfPutCh(pc),a2
82 move.l a7,a3
83 move.l d0,-(a7)
84 jsr _LVORawDoFmt(a6)
85 move.l (a7)+,d0
86 addq.l #8,a7
87 movem.l (a7)+,a2/a3/a6
88 rts
90 XDEF CountPutCh
91 CountPutCh:
92 addq.l #1,(a3)
93 rts
95 XDEF SNPrintfPutCh
96 SNPrintfPutCh:
97 move.l (a3),a0
98 tst.l 4(a3)
99 beq.s noroom
100 subq.l #1,4(a3)
101 beq.s noroom
102 move.b d0,(a0)+
103 move.l a0,(a3)
105 noroom:
106 clr.b (a0)