Writing text |
Binary data | Hex. data |
00000000 | $00 |
01110000 | $70 |
10001000 | $88 |
10001000 | $88 |
11111000 | $F8 |
10001000 | $88 |
10001000 | $88 |
Show one char
How are we going to show a string? He have to show each characters one by one. So how are we going to show one character? Consider the bitmap is a monochrom image. Now the required steps are
|
Well. It takes some instructions, but it's not as complex as it seems. Assume that ES:DI contains
the screen address (DESTADDR), AL has the ASCII code, while DL has the INK color. At the beginning
we save the used registers (SI,DI,CX) as we'll need them outside the procedure. Then we caluclate
the address for the chararcter. Because we have bitmaps only for the ASCII codeset 32..95, we have
to sub 32 from the code (a simple offset). Then a multiply by 7 gives the offset. The predefined
label chr6x7_dat is the address for the bitmap.
Now a really important detail: we store the bitmap data in the same code segment where the putchar
procedure is. This means that the bitmap is included into the unit GFX256, we don't need
to read it from a file. Storing data in the code segment is not a nice thing, you would say, but it
makes our life easier. Plus, in this case - as later you'll see - there is three different memory
area what we must deal with, that's why I prefer storing the bitmaps inside the code segment.
The instruction SEGCS LODSB loads the next byte from the bitmap. Then the internal loop checks all the bits. I use the SHL instruction so I shift bits left, then if the bit is one, the flag Carry will be 1. If this is one, we show the pixel, otherwise just skip that location. At the end of the procedure we load back the saved registers from the stack and return. Although the assembly procedure frame contain a ret intruction anyway, I use the RETN here, becuase I am going to call this function locally from this unit later. (It means, it's a local function and will not be available from outside.) |
Show string
Shoing a string now will be pretty strightforward. A pascal string is not too complicated. It has maximum 256 bytes. The first byte always contains the number of characters, and the rest of it is just the string itself.
|
Okay, do it then. Steps....
|
Test
|
The result as we see on the screen:
|
Downloads: [ Gfx256 unit | Print string ]