1# 2# Copyright (c) 1999 Global Technology Associates, Inc. 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions 7# are met: 8# 1. Redistributions of source code must retain the above copyright 9# 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. 13# 14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS``AS IS'' AND 15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS 18# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 19# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 20# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 21# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 23# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 24# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25# 26# From: btx.s 1.10 1999/02/25 16:27:41 rnordier 27# $FreeBSD$ 28# 29 30# Screen defaults and assumptions. 31 32 .set SCR_MAT,0x7 # Mode/attribute 33 .set SCR_COL,0x50 # Columns per row 34 .set SCR_ROW,0x19 # Rows per screen 35 36# BIOS Data Area locations. 37 38 .set BDA_SCR,0x449 # Video mode 39 .set BDA_POS,0x450 # Cursor position 40 41 .globl crt_putchr 42 43# void crt_putchr(int c) 44 45crt_putchr: movb 0x4(%esp,1),%al # Get character 46 pusha # Save 47 xorl %ecx,%ecx # Zero for loops 48 movb $SCR_MAT,%ah # Mode/attribute 49 movl $BDA_POS,%ebx # BDA pointer 50 movw (%ebx),%dx # Cursor position 51 movl $0xb8000,%edi # Regen buffer (color) 52 cmpb %ah,BDA_SCR-BDA_POS(%ebx) # Mono mode? 53 jne crt_putchr.1 # No 54 xorw %di,%di # Regen buffer (mono) 55crt_putchr.1: cmpb $0xa,%al # New line? 56 je crt_putchr.2 # Yes 57 xchgl %eax,%ecx # Save char 58 movb $SCR_COL,%al # Columns per row 59 mulb %dh # * row position 60 addb %dl,%al # + column 61 adcb $0x0,%ah # position 62 shll %eax # * 2 63 xchgl %eax,%ecx # Swap char, offset 64 movw %ax,(%edi,%ecx,1) # Write attr:char 65 incl %edx # Bump cursor 66 cmpb $SCR_COL,%dl # Beyond row? 67 jb crt_putchr.3 # No 68crt_putchr.2: xorb %dl,%dl # Zero column 69 incb %dh # Bump row 70crt_putchr.3: cmpb $SCR_ROW,%dh # Beyond screen? 71 jb crt_putchr.4 # No 72 leal 2*SCR_COL(%edi),%esi # New top line 73 movw $(SCR_ROW-1)*SCR_COL/2,%cx # Words to move 74 rep # Scroll 75 movsl # screen 76 movb $' ',%al # Space 77 movb $SCR_COL,%cl # Columns to clear 78 rep # Clear 79 stosw # line 80 movb $SCR_ROW-1,%dh # Bottom line 81crt_putchr.4: movw %dx,(%ebx) # Update position 82 popa # Restore 83 ret # To caller 84