Mail Archives: djgpp/1999/05/05/03:42:13
From: | Matthias Skobowsky <skymac AT cs DOT tu-berlin DOT de>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Assembly in Libraries
|
Date: | Wed, 05 May 1999 01:13:31 +0200
|
Organization: | Technische Universitaet Berlin, Deutschland
|
Lines: | 62
|
Message-ID: | <372F7F1B.3F0F12C0@cs.tu-berlin.de>
|
NNTP-Posting-Host: | 130-149-145-71.dialup.cs.tu-berlin.de.
|
Mime-Version: | 1.0
|
X-Trace: | news.cs.tu-berlin.de 925859707 4122 130.149.145.71 (4 May 1999 23:15:07 GMT)
|
X-Complaints-To: | news AT cs DOT tu-berlin DOT de
|
NNTP-Posting-Date: | 4 May 1999 23:15:07 GMT
|
X-Mailer: | Mozilla 4.5 [de]C-CCK-MCD QXW0320i (Win95; I)
|
X-Accept-Language: | de
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Hi,
I got a nice library and a nice program, but the library is written
using Borlands Inline Assembly. So I went to the news group and read a
lot of mails concerning assembly. I looked at the FAQ chapter 17 and
tried to change it to the AT&T syntax. After some trying there were no
more syntax errors but a general protection fault. That's why I'm asking
some questions:
1. Is it possible to use those assembly a library? (In my \include are
only constructions like __asm__ __volatile__("...))
2.What about the header? Will it work with DJ C?
3. Does anybody has experiences in changing Borland to AT&T?
Thanks, Matthias
/***********************Something of the header**********/
#if!defined(__STRING_H)
#include <string.h>
#endif
#define VIDEO 0x10
/********Think it's like Intel (from the Borland
Code)*****************************/
void writetovideo(int len, int code, int color) {
int address = ((wherex() - 1) * 2) + ((wherey() -1) * 160);
int videoSeg = videoAddress(); /* Is a colour card on system? */
asm {
mov ah, BYTE PTR color
mov al, BYTE PTR code /* The character to display */
mov cx, WORD PTR len /* cx determines number of loops */
mov dx, WORD PTR videoSeg
push es
mov es, dx
mov di, WORD PTR address
rep stosw
pop es
}
}
/********Tried to change to AT&T*****************************/
void writetovideo(int len, int code, int color) {
int address = ((wherex() - 1) * 2) + ((wherey() -1) * 160);
int videoSeg = videoAddress(); /* Is a colour card on system? */
asm("movb color, %ah");
asm("movb code, %al");
asm("movw len, %cx");
asm("move videoSeg, %es");
asm("push %es");
asm("mov? %dx, %es"); /*What about the length by registers
asm("movw adress, %di");
asm("rep stosw");
asm("pop %es");
}
- Raw text -