summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2013-03-18 05:58:23 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2013-03-18 06:23:35 (GMT)
commitae2dc76478475a11656b2d7de03fba96d380f177 (patch)
tree48d2e55c4b85ef443eed2f0fa608b65e6b930563
parent5169e4e2b35b5364bae129bd14cc1ac8e9cb95b5 (diff)
downloadvirtio9p-ae2dc76478475a11656b2d7de03fba96d380f177.zip
virtio9p-ae2dc76478475a11656b2d7de03fba96d380f177.tar.gz
virtio9p-ae2dc76478475a11656b2d7de03fba96d380f177.tar.bz2
virtio9p-ae2dc76478475a11656b2d7de03fba96d380f177.tar.xz
printmsg: be more flexible with segments for the debugging functions
The debugging functions want minimal footprint, so make it possible to use with nonstandard segment configuration.
-rw-r--r--printmsg.asm70
1 files changed, 47 insertions, 23 deletions
diff --git a/printmsg.asm b/printmsg.asm
index 231f568..6e38dfb 100644
--- a/printmsg.asm
+++ b/printmsg.asm
@@ -211,6 +211,27 @@ GPROC(debug_puts)
retw $2
END(debug_puts)
+GPROC(debug_puts_far)
+ pushw %bp
+ movw %sp,%bp
+ pushw %ds
+ pushw %si
+ pushw %ax
+ ldsw 4(%bp),%si
+1:
+ lodsb
+ andb %al,%al
+ jz 2f
+ outb %al,$DEBUG_PORT
+ jmp 1b
+2:
+ popw %ax
+ popw %si
+ popw %ds
+ popw %bp
+ retw $4
+END(debug_puts_far)
+
/* ------------------------------------------------------------------------- *
* debug_printnum
*
@@ -221,28 +242,29 @@ GPROC(debug_printnum)
pushl %eax
pushl %edx
pushl %ecx
- pushw %di
- movw %sp,%di
- movl (2+1*2+3*4)(%di),%eax
+ pushw %bp
+ movw %sp,%bp
+ movl (2+1*2+3*4)(%bp),%eax
subw $12,%sp
- decw %di
+ decw %bp
xorl %ecx,%ecx
- movb %cl,(%di)
+ movb %cl,(%bp)
movb $10,%cl
1:
xorl %edx,%edx
divl %ecx
- decw %di
+ decw %bp
addb $0x30,%dl
- movb %dl,(%di)
+ movb %dl,(%bp)
andl %eax,%eax
jnz 1b
- pushw %di
- call debug_puts
+ pushw %ss
+ pushw %bp
+ call debug_puts_far
addw $12,%sp
- popw %di
+ popw %bp
popl %ecx
popl %edx
popl %eax
@@ -257,28 +279,27 @@ END(debug_printnum)
GPROC(debug_printhex2)
pushw %cx
- movw $0x208,%cx
+ movw $2,%cx
jmp debug_printhexn
END(debug_printhex2)
GPROC(debug_printhex4)
pushw %cx
- movw $0x400,%cx
+ movw $4,%cx
/* jmp debug_printhexn */
END(debug_printhex4)
LPROC(debug_printhexn)
pushw %ax
pushw %dx
- pushw %di
+ pushw %bp
cld
+ movw %sp,%bp
subw $6,%sp
- movw %sp,%di
- movw (2+4*2+6)(%di),%dx
- shlw %cl,%dx
- shrw $8,%cx
+ movw (2+4*2)(%bp),%dx
+ decw %bp
+ movb %ch,(%bp) /* %ch == 0 */
1:
- rolw $4,%dx
movb %dl,%al
andb $0x0f,%al
addb $0x30,%al
@@ -286,14 +307,17 @@ LPROC(debug_printhexn)
jb 2f
addb $(0x41-0x3a),%al
2:
- stosb
+ decw %bp
+ movb %al,(%bp)
+ shrw $4,%dx
loopw 1b
- movb %cl,(%di) /* %cl == 0 */
- pushw %sp /* %sp -> address of buffer */
- call debug_puts
+
+ pushw %ss
+ pushw %bp /* %bp -> first character */
+ call debug_puts_far
addw $6,%sp
- popw %di
+ popw %bp
popw %dx
popw %ax
popw %cx