2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: screen support functions ripped from the 32-bit native target.
13 #define __save_flags(x) __asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */)
14 #define __restore_flags(x) __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory", "cc")
15 #define __cli() __asm__ __volatile__("cli": : :"memory")
16 #define __sti() __asm__ __volatile__("sti": : :"memory")
26 static struct scr
*view
= (struct scr
*)0xb8000;
36 if (!dead
) for (i
=0; i
<80*25; i
++)
44 __restore_flags(flags
);
53 if (chr
== 3) /* die / CTRL-C / "signal" */
59 asm volatile ("out %b0,%w1"::"a"(chr
),"Nd"(0x3f8));
84 for (i
=0; i
<80*24; i
++)
85 view
[i
].sign
= view
[i
+80].sign
;
86 for (i
=80*24; i
<80*25; i
++)
90 __restore_flags(flags
);
93 /* Convert the integer D to a string and save the string in BUF. If
94 BASE is equal to 'd', interpret that D is decimal, and if BASE is
95 equal to 'x', interpret that D is hexadecimal. */
96 static void __itoa (char *buf
, int base
, int d
)
100 unsigned long ud
= d
;
103 /* If %d is specified and D is minus, put `-' in the head. */
104 if (base
== 'd' && d
< 0)
110 else if (base
== 'x')
112 else if (base
== 'p')
117 char v
= (d
>> (28-i
*4)) & 0xf;
118 *p
++ = (v
< 10) ? v
+ '0' : v
+ 'A' - 10;
124 /* Divide UD by DIVISOR until UD == 0. */
127 int remainder
= ud
% divisor
;
129 *p
++ = (remainder
< 10) ? remainder
+ '0' : remainder
+ 'a' - 10;
131 while (ud
/= divisor
);
149 void kprintf(const char *format
, ...)
151 unsigned long *ptr
= (unsigned long *)&format
+ 1;
155 while ((c
= *format
++) != 0)
170 __itoa (buf
, c
, (int)*ptr
++);