2012-09-23 45 views
4

嘿我試圖理解INT 10h,13h(19)寫入一個字符串與BIOS中斷10在13h在啊。我已經找到了關於不同標誌放置在不同寄存器中的信息。有一件事我仍然沒有得到的是BL中應該做什麼,如果我只是想用這個函數寫一個字符串,那麼應該在BL中作爲屬性呢? 現在它寫出了奇怪的閃爍符號,沒有任何意義。謝謝你,事先INT 10,13h如何處理屬性?

Writes a string of characters with specified attributes to any display 
page. 

    On entry:  AH   13h 
        AL   Subservice (0-3) 
        BH   Display page number 
        BL   Attribute (Subservices 0 and 1) 
        CX   Length of string 
        DH   Row position where string is to be written 
        DL   Column position where string is to be written 
        ES:BP  Pointer to string to write 

    Returns:  None 

    Notes:   This service is available only for XTs dated 1/19/86 
        and later, ATs, EGAs, and PC Convertibles. 

        The service has four subservices, as follows: 

        AL=00h: Assign all characters the attribute in BL; 
        do not update cursor 
        AL=01h: Assign all characters the attribute in BL; 
        update cursor 
        AL=02h: Use attributes in string; do not update 
        cursor 
        AL=03h: Use attributes in string; update cursor 

        In Subservices 0 and 1, all characters in the string 
        are written to the screen with the same attribute-- 
        the attribute specified in BL. 

        In Subservices 2 and 3, the attribute byte for each 
        character is found in the string itself. The string 
        itself consists of a character followed by its 
        attribute, another character followed by its 
        attribute, and so on. The string is copied directly 
        to the video buffer as is. 

        In Subservices 0 and 2, the cursor position is not 
        updated after the string is written. 

        In Subservices 1 and 3, the cursor is moved to the 
        first position following the last character in the 
        string. 

        Like Service 0Eh, Service 13h responds appropriately 
        to ASCII 07h (bell), 08h (backspace), 10h (line 
        feed), and 0Dh (carriage return). All other 
        characters are printed. 

回答

5

隨着int 10h,該BL寄存器用於顏色屬性。

除非你正在處理CGA,其中BL值是調色板號碼,BL值是表示前景色(4位 - 低部分)號和背景色(4位 - 高部分)。例如,如果您想要一個帶有紅色(0x04)文本顏色的藍色(0x01)背景,則需要將0x14放入BL寄存器中 - 二進制文件爲00010100

 0001    0100 
|_ Background _| |_ Foreground _| 

顏色通常是:

- Black   0x00 
- Blue    0x01 
- Green   0x02 
- Cyan    0x03 
- Red    0x04 
- Magenta   0x05 
- Brown   0x06 
- LightGray  0x07 
- DarkGray   0x08 
- LightBlue  0x09 
- LightGreen  0x0A 
- LightCyan  0x0B 
- LightRed   0x0C 
- LightMagenta  0x0D 
- LightBrown  0x0E 
- White   0x0F 
+0

這是正確的,但 「背景」 的高位是有點怪異。在某些情況下,我們會獲得「明亮」的背景,而在其他情況下,它會閃爍。我忘記了如何切換它,但我記得其他進程可能會「背後」惹惱它。最簡單的事情就是讓高位爲零。對於「普通」文本,使用bl 7,對於「明亮」使bl 0Fh。對於「彩虹」文本,請使用al 1的位1,並將您的字符串定義爲char,att,char,att ... cx只需要字符計數......我記得...... –