1168457Skato# Copyright (c) KATO Takenori, 2007. 2168457Skato# 3168457Skato# All rights reserved. Unpublished rights reserved under the copyright 4168457Skato# laws of Japan. 5168457Skato# 6168457Skato# Redistribution and use in source and binary forms, with or without 7168457Skato# modification, are permitted provided that the following conditions 8168457Skato# are met: 9168457Skato# 10168457Skato# 1. Redistributions of source code must retain the above copyright 11168457Skato# notice, this list of conditions and the following disclaimer as 12168457Skato# the first lines of this file unmodified. 13168457Skato# 2. Redistributions in binary form must reproduce the above copyright 14168457Skato# notice, this list of conditions and the following disclaimer in the 15168457Skato# documentation and/or other materials provided with the distribution. 16168457Skato# 17168457Skato# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18168457Skato# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19168457Skato# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20168457Skato# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21168457Skato# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22168457Skato# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23168457Skato# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24168457Skato# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25168457Skato# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26168457Skato# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27168457Skato# 28168457Skato# $FreeBSD: stable/11/stand/pc98/boot0.5/putssjis.s 298826 2016-04-30 00:26:38Z pfg $ 29168457Skato# 30168457Skato 31168457Skato .code16 32168457Skato .section .putssjis, "awx", @progbits 33168457Skato 34168457Skato # 35168457Skato # Display string with Shift-JIS support 36298826Spfg # %si: address of string, %di: T-VRAM address, %cx: count 37168457Skato # 38168457Skato 39168457Skato # Absolute address of putssjis_entry must be 0x1243. 40168457Skatoputssjis_entry: 41168457Skato push %es 42168457Skato push %ax 43168457Skato # Setup the T-VRAM segement address. 44168457Skato xorw %ax, %ax 45168457Skato movw %ax, %es 46168457Skato movw $0xa000, %ax 47168457Skato testb $0x08, %es:0x501 48168457Skato jz normalmode 49168457Skato movw $0xe000, %ax 50168457Skatonormalmode: 51168457Skato movw %ax, %es 52168457Skato 53168457Skatoputssjis_loop: 54168457Skato lodsw 55168457Skato call check_sjis 56168457Skato jc put_2byte_char 57168457Skato 58168457Skato # 1 byte character 59168457Skato xorb %ah, %ah 60168457Skato testb $0xe0, %al # Check control code. 61168457Skato jnz put_1byte_char 62168457Skato movb $0x20, %al # Convert control code into the space. 63168457Skatoput_1byte_char: 64168457Skato stosw 65168457Skato decw %si 66168457Skato jmp putssjis_loop_end 67168457Skato 68168457Skatoput_2byte_char: 69168457Skato subb $0x20, %al 70168457Skato 71168457Skato # Check 2byte "hankaku" 72168457Skato cmp $0x09, %al 73168457Skato je put_2byte_hankaku 74168457Skato cmp $0x0a, %al 75168457Skato je put_2byte_hankaku 76168457Skato cmp $0x0b, %al 77168457Skato je put_2byte_hankaku 78168457Skato jmp put_2byte_zenkaku 79168457Skato 80168457Skatoput_2byte_hankaku: 81168457Skato stosw 82168457Skato jmp putssjis_loop_end 83168457Skato 84168457Skatoput_2byte_zenkaku: 85168457Skato stosw 86168457Skato orb $0x80, %ah 87168457Skato stosw 88168457Skato decw %cx 89168457Skato 90168457Skatoputssjis_loop_end: 91168457Skato loop putssjis_loop 92168457Skato 93168457Skato pop %ax 94168457Skato pop %es 95168457Skato ret 96168457Skato 97168457Skato # Check 2-byte code. 98168457Skatocheck_sjis: 99168457Skato cmpb $0x80, %al 100168457Skato jbe found_ank_kana 101168457Skato cmpb $0xa0, %al 102168457Skato jb found_2byte_char 103168457Skato cmpb $0xe0, %al 104168457Skato jb found_ank_kana 105168457Skato cmpb $0xf0, %al 106168457Skato jae found_ank_kana 107168457Skato jmp found_2byte_char 108168457Skatofound_ank_kana: 109168457Skato clc 110168457Skato ret 111168457Skato 112168457Skatofound_2byte_char: 113168457Skato # Convert Shift-JIS into JIS. 114168457Skato cmpb $0x9f, %al 115168457Skato ja sjis_h_2 # Upper > 0x9f 116168457Skato subb $0x71, %al # Upper -= 0x71 117168457Skato jmp sjis_lower 118168457Skatosjis_h_2: 119168457Skato subb $0xb1, %al # Upper -= 0xb1 120168457Skatosjis_lower: 121168457Skato salb %al # Upper *= 2 122168457Skato incb %al # Upper += 1 123168457Skato 124168457Skato cmpb $0x7f, %ah 125168457Skato jbe sjis_l_2 126168457Skato decb %ah # Lower -= 1 if lower > 0x7f 127168457Skatosjis_l_2: 128168457Skato cmpb $0x9e, %ah 129168457Skato jb sjis_l_3 130168457Skato subb $0x7d, %ah # Lower -= 0x7d 131168457Skato incb %al # Upper += 1 132168457Skato jmp check_2byte_end 133168457Skatosjis_l_3: 134168457Skato subb $0x1f, %ah # Lower -= 0x1f 135168457Skatocheck_2byte_end: 136168457Skato stc 137168457Skato ret 138