home *** CD-ROM | disk | FTP | other *** search
- ===========================================================================
- BBS: The Abacus * HST/DS * Potterville, MI
- Date: 06-06-93 (18:59) Number: 130
- From: TOM DONAHUE Refer#: NONE
- To: JOHN CROUCH Recvd: NO
- Subj: Help With .Asm 2 C Conf: (36) C Language
- ---------------------------------------------------------------------------
- John Crouch (1:282/115) writes to All:
-
- > The following code is from the Programmer's Guide to EGA and VGA
- > Cards, by Richard F. Ferraro. I have had trouble getting this
- > code to work. Can someone supply the C code for this .asm code,
- > compatible with Borland 3.0? Using inline assembly or whatever
- > is fine, I just need it working.
- >
- > ; Calling protocol:
- > ; RdFont(input_segment,input_offset,output,nchar,bpc);
- >
- > _RdFont proc far
- > Prefix ; Register saving macro I have NOT included.
- >
- > mov ax,[bp+14] ; do for "nchar" characters
- > mul word ptr [bp+16] ; " characters * bytes/character
- > mov cx,ax ; into counter for number of bytes
- > mov ds,[bp+6] ; point to source segment
- > mov si,[bp+8] ; point to source offset
- > les di,[bp+10] ; point to destination
- > rep movsb
- >
- > Postfix ; Register restoring macro I have NOT included
- > _RdFont endp
-
- OK, essentially this is a far memcpy so you have to be careful of
- pointer sizes. Here are three ways to do it.
-
- 1) In C with conditional compilation
-
- char output[FONTSIZE];
-
- #if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
- /* near data, stack segment == data segment */
- movedata(inseg, inofs, _DS, (unsigned)output, nchar*bpc);
- #else
- memcpy((void *)output, (void *)MK_FP(inseg, inofs), nchar*bpc);
- #endif
-
- 2) Use Ferraro's _RdFont as is but add "far" to the prootype
- since it's hard wired for far code (the "far" after proc) and
- far data pointers (les di). This works for all models.
-
- void far RdFont(unsigned int inseg, unsigned int inofs,
- char far *output, int nchar, int bpc);
-
- 3) Take advantage of MASM/TASM support for C names and memory models.
- This works in all models for MASM 5.0 and TASM 2.0 and later.
- To use another model just change the "small" in the .model
- directive to "large" etc. For small models this will be a tad
- more efficient than method 2) and IMO it's better anyway, but
- I guess if you're writing for publication then you have to
- consider other (or older) assemblers.
-
- ; void RdFont(unsigned int inseg, unsigned int inofs,
- ; char *output, int nchar, int bpc);
-
- .model small, c
- .code
-
- RdFont proc ; near or far, depending on model
-
- arg inseg:word, inofs:word, output:ptr, nchar:word, bpc:word
- uses ds,si,di ; save these registers at entry/exit
-
- if @DataSize EQ 0 ; tiny, small, medium model
- push ds ; assumes ds == ss
- pop es
- mov di,output
- else ; compact, large, huge model
- les di,output ; load far pointer
- endif
- mov ax,nchar
- mul word ptr bpc
- mov ds,inseg
- mov si,inofs
- rep movsb
- ret
- RdFont endp
-
- ends
- end
-
- > A related question: According to the book it is possible to have
- > 2 fonts loaded at one time, for a total of a possible 512 different
- > characters on the screen. My need for the previous .asm code to be
- > translated is that I have the C code to make a text font italic, and
- > would like the ability to load 2 of the same font, and make 1 of
- > them italic.
-
- Sorry I can't answer that, but I'd be interested in seeing the code.
- Is it generally available?
-
- --- SuperBBS 1.17-2
- * Origin: SuperBBS Support/Sales/Beta Avxia_bbs Tokyo Line 1 (6:730/9)
- SEEN-BY: 1/211 11/2 4 13/13 101/1 108/89 109/25 110/69 114/5 123/19 124/1
- SEEN-BY: 153/752 154/40 77 157/110 159/100 125 430 575 950 203/23 209/209
- SEEN-BY: 261/1023 280/1 390/1 396/1 5 15 2270/1 2440/5 3603/20
-