News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How print a symbol?

Started by ss-00, March 16, 2010, 09:44:25 PM

Previous topic - Next topic

ss-00

hello
i want to print a symbol or chinese character or arabic for example but i don't now how i represent it?   :'( could you help me



FORTRANS

Hi,

   I believe there exist Arabic fonts that you can load and use.
Chinese characters are a bit more complex.  You can make a set of
images and display them in a graphics mode.

   Or if you want to use text modes on an EGA/VGA/SVGA card:

- - -
   Information from "The Undocumented PC", 2nd edition, by Frank van
Gilluwe says that a special version of MS-DOS for the "far east" was
made to support Double Byte Character Set (DBCS) video display to
display Japanese characters called DOS/V.  (There were versions of
DOS for Korean and Chinese as well, he does not mention them.)  (IBM
had a DBCS version of OS/2 as well.  Windows went with Unicode.)  A
special set of Int 10H video functions were supported by DOS/V and
special versions of the VGA display to display the DBCS.  So if you
have that functionality plus the fonts, the following functions are
available.

   Int 10H Fn 0H;  Set video mode, special DBCS modes.
   Int 10H Fn 13H Subfn 10H;  Read DBCS and attributes.
   Int 10H Fn 13H Subfn 11H;  Read DBCS and attributes.
   Int 10H Fn 13H Subfn 20H;  Write DBCS and attributes.
   Int 10H Fn 13H Subfn 21H;  Write DBCS and attributes.
   Int 10H Fn 18H Subfn 0;  Request for font pattern, get font.
   Int 10H Fn 18H Subfn 1;  Request for font pattern, set font.
   Int 10H Fn 1DH Subfn 0, 1, 2; Shift status line functions.

   If your video card supports these functions, get Ralf Brown's
Interrupt List (RIBL) for further information.

   Otherwise use the standard VGA font functions to load a custom
font.  And do everything with your own code.  See RIBL, "Programmer's
Guide to PC Video Systems" by Richard Wilton, or another guide to the
video BIOS functions.

   Int 10H Fn 11H Subfn 0;  Load user-specified character definition.
   Int 10H Fn 11H Subfn 1;  Load 8x14 font.
   Int 10H Fn 11H Subfn 2;  Load 8x8 font.
   Int 10H Fn 11H Subfn 4;  Load 8x16 font.
   Int 10H Fn 11H Subfn 3;  Select displayed EGA/VGA font.
   Int 10H Fn 11H Subfn 10H, 11H, 12H, 14H;  Load font and program
                                             CRT controller.
   Int 10H Fn 11H Subfn 20H;  Load 8x8 graphic character set for Int
                              15H vector.
   Int 10H Fn 11H Subfn 21H, 22H, 23H, 24H;  Load graphics font.
   Int 10H Fn 11H Subfn 30H;  Get character generator information.

- - -

HTH,

Steve

ss-00

THANK YOU FORTRANS FOR YOUR HELP

let's take this example it is a lower-case A

00000000       
00111000   *** 
00000100      *
00000100      *
00111100   ****
01000100  *   *
01000100  *   *
00111110   *****
00000000       

how can i display it on the screen?

MichaelW

#3
At it simplest loading and using user-defined character sets is easy.

;=========================================================================
.model small, c
.386
.stack
;=========================================================================
.data

    bitPatterns label byte

    db 00000000b
    db 00000000b
    db 00000000b
    db 00000000b
    db 00000000b
    db 00011000b
    db 00011000b
    db 01100110b
    db 01100110b
    db 00011000b
    db 00011000b
    db 00000000b
    db 00000000b
    db 00000000b
    db 00000000b
    db 00000000b

    db 00000000b
    db 00000000b
    db 00000000b
    db 00011000b
    db 00100100b
    db 00011000b
    db 00011000b
    db 00100100b
    db 00100100b
    db 01000010b
    db 01000010b
    db 10000001b
    db 11000011b
    db 00000000b
    db 00000000b
    db 00000000b

    db 00000000b
    db 11111111b
    db 11111111b
    db 00111100b
    db 00111100b
    db 00111100b
    db 00111100b
    db 00111100b
    db 00111100b
    db 00111100b
    db 00111100b
    db 00111100b
    db 00111100b
    db 11111111b
    db 11111111b
    db 00000000b

    db 11111111b
    db 10000001b
    db 10000001b
    db 10000001b
    db 10000001b
    db 10000001b
    db 10000001b
    db 10000001b
    db 10000001b
    db 10000001b
    db 10000001b
    db 10000001b
    db 10000001b
    db 10000001b
    db 10000001b
    db 11111111b

    db 00011000b
    db 00111100b
    db 01111110b
    db 11111111b
    db 01111110b
    db 00111100b
    db 00011000b
    db 00111100b
    db 01111110b
    db 11111111b
    db 01111110b
    db 00111100b
    db 00011000b
    db 00111100b
    db 01111110b
    db 11111111b

.code
;=========================================================================


LoadUserCharacterSet proc uses ax bx cx dx bp es bitPatternsSeg:WORD,
                                                 bitPatternsOffset:WORD,
                                                 characterCount:WORD,
                                                 startingCharacter:WORD,
                                                 blockNumber:BYTE,
                                                 bytesPerCharacter:BYTE

    mov cx, characterCount
    mov dx, startingCharacter
    mov bl, blockNumber
    mov bh, bytesPerCharacter
    mov es, bitPatternsSeg
    mov bp, bitPatternsOffset
    mov ax, 1100h
    int 10h
    ret

LoadUserCharacterSet endp

;=========================================================================
.startup
;=========================================================================

    ;----------------------------
    ; Make the cursor invisible.
    ;----------------------------

    mov ah, 1
    mov ch, 00100000b
    int 10h

    ;-----------------------------------------------
    ; Set the cursor position to row 10, column 32.
    ;-----------------------------------------------

    mov ah, 2
    mov bh, 0
    mov dh, 10
    mov dl, 32
    int 10h

    ;---------------------------------------------------------
    ; Under Windows the loaded characters will not be used if
    ; the app is running in a window. Delay for ~5 seconds to
    ; give the user time to switch to full-screen mode.
    ;---------------------------------------------------------

    push 40h
    pop es
    mov bx, 6ch
    mov ecx, es:[bx]
    add ecx, 18*5
    .REPEAT
        mov eax, es:[bx]
    .UNTIL eax > ecx

    ;-----------------------------------------------------
    ; Load the bit patterns for 5 characters, starting at
    ; character offset 224 in block 0 of the area of the
    ; display memory that is used to store loaded fonts.
    ;-----------------------------------------------------

    invoke LoadUserCharacterSet, ds,
                                 OFFSET bitPatterns,
                                 5,
                                 224,
                                 0,
                                 16

    ;-----------------------------
    ; Display the new characters.
    ;-----------------------------

    N=224
    REPEAT 5
        mov ah, 2
        mov dl, N
        int 21h
        mov ah, 2
        mov dl, 32
        int 21h
        mov ah, 2
        mov dl, 32
        int 21h
        N=N+1
    ENDM

    ;--------------------------------------
    ; Wait for a key press before exiting.
    ;--------------------------------------

    xor ah, ah
    int 16h

;=========================================================================
.exit
end


Some limitations are:

The default character box is 9x16, but the pixel patterns can specify only 8 pixels per row.

The number of scan lines is limited to 32.

Using any number of scan lines other than 16 (the default) will require additional programming.

It is possible to create characters that span two character boxes, for a total of 18 pixels, but if the scan lines must be continuous across the ninth pixel there are only 32 character codes in each font block that can accommodate this. And because of the way the ninth pixel is generated, some pixel patterns are not possible.

It is possible to have two 256-character fonts active at a time, but because the foreground intensity bit of the attribute byte is then used to specify the font, you loose the ability to display intensified foregrounds.
eschew obfuscation

oex

I have no experience of this but as a suggestion there must be an equivalent dos prompt program that does support the Chinese character sets? Considering Chinese is the second most spoken language on the internet it would be a good program for someone to write if not.
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

dedndave

in some font sets, it might be hard to fit all the Chinese characters into the pixels provided   :P
but, they do have code-pages - i have never tried Chinese
for windows, there is unicode and font sets for this kind of thing
for DOS mode, you may well have to roll your own like he is suggesting

in DOS text modes, you can define the font for the upper 128 characters only - not enough to express Chinese
if you re-define it, i think the previously displayed characters would change

in DOS graphics modes, you can individually program pixels

MichaelW

Quotein DOS text modes, you can define the font for the upper 128 characters only - not enough to express Chinese
if you re-define it, i think the previously displayed characters would change

in DOS graphics modes, you can individually program pixels

In the alphanumeric modes you can define the font for the entire range. And if you are willing to accept the limitation on the number of foreground colors you can have up to 512 characters available at a time, or 448 if you avoid the control characters.

The hardware is "wired" to use these fonts when it refreshes the screen, so yes, redefining them will change the displayed characters. The VGA can store a total of 8 256-character fonts, and there is a function to select which of the loaded fonts will be used. It might be possible to switch fonts in sync with the screen refresh, potentially allowing up to 2048 simultaneous characters.

I find the alphanumeric font capabilities interesting, but given the limitations I think graphics is the way to go.
eschew obfuscation

ss-00

thank you very much MichaelW

i didn't understand this procedure!

LoadUserCharacterSet proc uses ax bx cx dx bp es bitPatternsSeg:WORD,
                                                 bitPatternsOffset:WORD,
                                                 characterCount:WORD,
                                                 startingCharacter:WORD,
                                                 blockNumber:BYTE,
                                                 bytesPerCharacter:BYTE

    mov cx, characterCount
    mov dx, startingCharacter
    mov bl, blockNumber
    mov bh, bytesPerCharacter
    mov es, bitPatternsSeg
    mov bp, bitPatternsOffset
    mov ax, 1100h
    int 10h
    ret

LoadUserCharacterSet endp


and this part of the code
could you explain it to me ,please
    invoke LoadUserCharacterSet, ds,
                                 OFFSET bitPatterns,
                                 5,
                                 224,
                                 0,
                                 16

    ;-----------------------------
    ; Display the new characters.
    ;-----------------------------

    N=224
    REPEAT 5
        mov ah, 2
        mov dl, N
        int 21h
        mov ah, 2
        mov dl, 32
        int 21h
        mov ah, 2
        mov dl, 32
        int 21h
        N=N+1
    ENDM

which compiler you use because i use masm 5.10 and i have errors when i compiled it

FORTRANS

Quote from: ss-00 on March 18, 2010, 09:02:43 PM
i didn't understand this procedure!


    mov ax, 1100h
    int 10h
    ret


Hi,

   He is using the video BIOS interrupt 10H, function 11H,
subfunction zero to load some custom glyphs into a character
set in the VGA character memory.

Quote
which compiler you use because i use masm 5.10 and i have errors when i compiled it

   You need MASM version 6.0 or newer because earlier versions
do not support the INVOKE directive.  Nor multiple line code entries
if I remember.  Look for the MASM32 SDK or the GeneSys project
to get a newer version.

Regards,

Steve N.

MichaelW

ss-00,

The LoadUserCharacterSet procedure is just a wrapper for this VGA BIOS function. The procedure makes calling the function somewhat easier, and the names make it easier to understand what each of the parameters is.

For this I used ML 6.15, but any version 6.0 or later should work. For MASM 5.1 try:

;=========================================================================
.model small, c
.386
.stack
;=========================================================================
.data

    bitPatterns label byte

    db 00000000b
    db 00000000b
    db 00000000b
    db 00000000b
    db 00000000b
    db 00011000b
    db 00011000b
    db 01100110b
    db 01100110b
    db 00011000b
    db 00011000b
    db 00000000b
    db 00000000b
    db 00000000b
    db 00000000b
    db 00000000b

    db 00000000b
    db 00000000b
    db 00000000b
    db 00011000b
    db 00100100b
    db 00011000b
    db 00011000b
    db 00100100b
    db 00100100b
    db 01000010b
    db 01000010b
    db 10000001b
    db 11000011b
    db 00000000b
    db 00000000b
    db 00000000b

    db 00000000b
    db 11111111b
    db 11111111b
    db 00111100b
    db 00111100b
    db 00111100b
    db 00111100b
    db 00111100b
    db 00111100b
    db 00111100b
    db 00111100b
    db 00111100b
    db 00111100b
    db 11111111b
    db 11111111b
    db 00000000b

    db 11111111b
    db 10000001b
    db 10000001b
    db 10000001b
    db 10000001b
    db 10000001b
    db 10000001b
    db 10000001b
    db 10000001b
    db 10000001b
    db 10000001b
    db 10000001b
    db 10000001b
    db 10000001b
    db 10000001b
    db 11111111b

    db 00011000b
    db 00111100b
    db 01111110b
    db 11111111b
    db 01111110b
    db 00111100b
    db 00011000b
    db 00111100b
    db 01111110b
    db 11111111b
    db 01111110b
    db 00111100b
    db 00011000b
    db 00111100b
    db 01111110b
    db 11111111b

.code
;=========================================================================

  start:

    ;-------------------------------------------------------
    ; When the OS loads the program it leaves DS and ES set
    ; to the segment address of the Program Segment Prefix.
    ; To access the program's data we must set DS to the
    ; segment address of the program's data segment.
    ;
    ; ML 6.0 and later provides a .STARTUP directive that
    ; can be used to do this.
    ;-------------------------------------------------------

    mov ax, DGROUP
    mov ds, ax

    ;----------------------------
    ; Make the cursor invisible.
    ;----------------------------

    mov ah, 1
    mov ch, 00100000b
    int 10h

    ;-----------------------------------------------
    ; Set the cursor position to row 10, column 32.
    ;-----------------------------------------------

    mov ah, 2
    mov bh, 0
    mov dh, 10
    mov dl, 32
    int 10h

    ;---------------------------------------------------------
    ; Under Windows the loaded characters will not be used if
    ; the app is running in a window. Delay for ~5 seconds to
    ; give the user time to switch to full-screen mode.
    ;---------------------------------------------------------

    push 40h
    pop es
    mov bx, 6ch
    mov ecx, es:[bx]
    add ecx, 18*5
  L1:
    mov eax, es:[bx]
    cmp eax, ecx
    jb  L1

    ;-----------------------------------------------------
    ; Load the bit patterns for 5 characters, starting at
    ; character offset 224 in block 0 of the area of the
    ; display memory that is used to store loaded fonts.
    ;-----------------------------------------------------

    mov cx, 5
    mov dx, 224
    mov bl, 0
    mov bh, 16
    push ds
    pop es
    mov bp, OFFSET bitPatterns
    mov ax, 1100h
    int 10h

    ;------------------------------------------------------------
    ; Display the new characters. The REPT directive repeats the
    ; statements between it and the ENDM directive the specified
    ; number of times. For each repeat the current value of N is
    ; substutited in the mov dl, N statement. So the first block
    ; will be assembled as:
    ;   mov ah, 2
    ;   mov dl, 224
    ;   int 21h
    ;   mov ah, 2
    ;   mov dl, 32
    ;   int 21h
    ;   mov ah, 2
    ;   mov dl, 32
    ;   int 21h
    ; The next as:
    ;   mov ah, 2
    ;   mov dl, 225
    ;   int 21h
    ;   . . .
    ; And so on.
    ;------------------------------------------------------------

    N=224
    REPT 5
        mov ah, 2
        mov dl, N
        int 21h
        mov ah, 2
        mov dl, 32
        int 21h
        mov ah, 2
        mov dl, 32
        int 21h
        N=N+1
    ENDM

    ;--------------------------------------
    ; Wait for a key press before exiting.
    ;--------------------------------------

    xor ah, ah
    int 16h

    ;----------------------------------------------------------------
    ; Terminate the program by calling the DOS End Program function.
    ;
    ; ML 6.0 and later provides a .EXIT directive that can be used
    ; to do this.
    ;----------------------------------------------------------------

    mov ax, 4c00h
    int 21h

;=========================================================================
end start


Assembled with this batch file:

masm test.asm;
pause
link test.obj;
pause

eschew obfuscation

ss-00

thank you very much for your help

   db 00000000b
    db 00000000b
    db 00000000b
    db 00000000b
    db 00000000b
    db 00011000b
    db 00011000b
    db 01100110b
    db 01100110b
    db 00011000b
    db 00011000b
    db 00000000b
    db 00000000b
    db 00000000b
    db 00000000b
    db 00000000b
_______________________
    db 00000000b
    db 11111111b
    db 11111111b
    db 00111100b
    db 00111100b
    db 00111100b
    db 00111100b
    db 00111100b
    db 00111100b
    db 00111100b
    db 00111100b
    db 00111100b
    db 00111100b
    db 11111111b
    db 11111111b
    db 00000000b

but why i didn't see the symbol 'I' like above for example even when i change it i have always the same symbol!!!!


MichaelW

If you are running under Windows and the app is in windowed mode, then Windows will use its own fonts, and the characters that you see will be the normal characters for those character codes. The delay was added to allow the user time to hit Alt+Enter to shift the app to full-screen mode before it loads the new characters.


eschew obfuscation

ss-00