| delorie.com/archives/browse.cgi | search |
| From: | "lewi9908" <lewi9908 AT ghc DOT ctc DOT edu> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | AT&T inline asm in DJGPP... |
| Date: | Sat, 30 Nov 2002 08:50:31 -0800 |
| Organization: | Posted via Supernews, http://www.supernews.com |
| Message-ID: | <uuhr3lgi6qsc7f@corp.supernews.com> |
| X-Priority: | 3 |
| X-MSMail-Priority: | Normal |
| X-Newsreader: | Microsoft Outlook Express 6.00.2600.0000 |
| X-MimeOLE: | Produced By Microsoft MimeOLE V6.00.2600.0000 |
| X-Complaints-To: | abuse AT supernews DOT com |
| Lines: | 79 |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
I am tring to build an OS...
I have a bootsector that loads a loader that setup PMode and loads the DJGPP
built program(not yet a real OS kernel)...
Using the next code
CStartup.asm (NASM)
[BITS 32]
extern _main
call _main
retf
Ker.cpp (DJGPP)
int main()
{
char* screen = (char*)0xb8000;
const char* msg = "Hello, world!";
while (*msg)
{
*screen++ = *msg++;
*screen++ = 0x4f;
}
return 0;
}
This allows me to make a far call to FLAT_CCODE:0x0000 which FLAT_CCODE is
the PMode gdt based at 0x20000 When main() return the CStartup.asm use retf
to return to loader...
Now before moving to DJGPP I was using Borland C++ 3.1 which is 16-bit so
main() had to loop for forever and not end the function and it used asm to
print to print to screen...
void main()
{
char* pC = "Hello World";
asm {
mov si, word ptr pC
cld
}
PrintAgain:
asm {
lodsb
or al,al
jz short PrintOver
mov ah,0Eh
mov bl,4fh
int 10h
jmp short PrintAgain
}
PrintOver:
for(;;);
}
Note: there was some rule that inline asm couldn't have labels so C labels
are used and the asm is broken up in to two...
Now I have looked into AT&T inline asm in serveral online docs and haven't
found a real good source of infomation and examples...
Also I was thinking about just using NASM to make to asm code to link with
the C code and setup gobal/extern to make funtion call to the asm from C.
But I don't know if this is best but looking at Mixed ASM/C it look easier
to do...
That is all I have...
Any more help...
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |