Turbo C++ 3.0 And BootProg

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
renovatio
Member
Member
Posts: 57
Joined: Fri May 23, 2008 5:13 am

Turbo C++ 3.0 And BootProg

Post by renovatio »

Hello,

I'm using bootprog to load STARTUP.BIN (compiled using Turbo C++ 3.0). After loading it nothing happens. I only used BIOS interrupts so everything should work properly. I'm using the Small Memory Model. The code works fine under MS-DOS. No warnings or errors while compiling. I would be very pleased if you help me with this. Thanks for your help.

crt.h

Code: Select all

byte X1 = 0, Y1 = 0, X2 = 79, Y2 = 24, TextAttr = 7;

enum {Black = 0, Blue, Green, Cyan, Red, Magenta, Brown, LightGray, DarkGray, LightBlue, LightGreen, LightCyan, LightRed, LightMagenta, Yellow, White, Blink = 128};

void ClrScr(void)
{
   _AH = 0x6;
   _AL = 0;
   _BH = TextAttr;
   _CH = Y1;
   _CL = X1;
   _DH = Y2;
   _DL = X2;
   asm int 0x10;
   _AH = 0x2;
   _BH = 0;
   _DH = Y1;
   _DL = X1;
   asm int 0x10;
}

void GotoXY(byte X, byte Y)
{
   _AH = 0x2;
   _BH = 0;
   _DH = Y1 + Y - 1;
   _DL = X1 + X - 1;
   asm int 0x10;
}

byte ReadKey(void)
{
   _AH = 0x0;
   asm int 0x16;
   return _AL;
}

void TextBackground(byte Color)
{
   TextAttr &= 0x0F;
   TextAttr |= Color << 4;
}

void TextColor(byte Color)
{
   TextAttr &= 0xF0;
   TextAttr |= Color;
}

byte WhereX(void)
{
   _AH = 0x3;
   _BH = 0;
   asm int 0x10;
   return _DL - X1 + 1;
}
byte WhereY(void)
{
   _AH = 0x3;
   _BH = 0;
   asm int 0x10;
   return _DH - Y1 + 1;
}

void Window(byte XA, byte YA, byte XB, byte YB)
{
   X1 = XA - 1;
   Y1 = YA - 1;
   X2 = XB - 1;
   Y2 = YB - 1;
}
startup.c

Code: Select all

typedef unsigned char byte;
typedef unsigned int  word;

#include <crt.h>

void main(void)
{
   _AH = 0x0; //Set 80x25x16 Text Mode
   _AL = 3;
   asm int 0x10;

   TextBackground(Blue);  //Do something
   TextColor(Cyan);
   Window(1, 1, 80, 1);
   ClrScr();
   Window(1, 25, 80, 25);
   ClrScr();
   TextBackground(Cyan);
   TextColor(Blue);
   Window(1, 2, 80, 24);
   ClrScr();

   while (1);    //stop
}
User avatar
Thor
Member
Member
Posts: 51
Joined: Mon Jul 06, 2009 12:55 am
Location: Kamloops, BC, Canada

Re: Turbo C++ 3.0 And BootProg

Post by Thor »

Are you sure that it is being loaded? I didn't look over your code because I'm too lazy, but ensuring that would be a good place to start.
Vancouver Canucks fan for life
renovatio
Member
Member
Posts: 57
Joined: Fri May 23, 2008 5:13 am

Re: Turbo C++ 3.0 And BootProg

Post by renovatio »

Yes I'm sure, Before posting I wrote a program that just print a character using bios and it worked.
User avatar
i586coder
Member
Member
Posts: 143
Joined: Sat Sep 20, 2008 6:43 am

Re: Turbo C++ 3.0 And BootProg

Post by i586coder »

Hi,

a lil bit comments :roll:

1. your code looks work probably and no problem with code
2. this is the important , what is your boot loader i guess BootProg by Alexei :wink: ,
make sure you have a formatted floppy disk with fat12 ,and compiled BootProg using nasm -fbin ...
and copy it to the first sector using e.g. bootable.exe or whatever you like
3.and this is my advice for you: if you want to develop an operating system using Turbo C x like me,you need
to understand how compiler compile you code to generate MZ executable
a. memory model ,please take look at http://wiki.osdev.org/Memory_model
and i recommend large memory model
b. CO?.OBJ C Startup Files Linked automatically,where ?=s,m,l <-(small,medium,large,...)
c. C0?.lib the standard static library for your memory model ,its include printf,setjmp,clrscr,and all functions
and i think you don't need them since you want to write OS so you need to write you own printf clone.
d. by default turbo c compiler fit debug-ing info in your .EXE and .OBJ files to allow TD.exe debug your code,
you can shut down debug-ing- within your IDE to reduce size and kill possibility of error
e. Turbo c version 3.0 use DOS extenders like DPMI.exe to run, be careful when develop PM code under
IDE,please take look at http://members.tripod.com/protected_mod ... mtuts.html

and always use #pragma inline to write inline assemble instructions in your code instead of BASM

Code: Select all

#pragma inline //use TASM to compile 32bit opcode

void main(void){ //we don't need an arguments or returned values
//since parsing argument required DOS interrupt

asm{.386 //386 opcode
mov eax,0x123456
//don't forget to add prefix opcode
.286 //286 opcode
}

//and use far instruction to reach address beyond 640KB
unsigned char far *v=(unsigned char far *)0x10000000L;

v[0x123]=0xff;//assign a value 0xff to 0x1000:0x123

}


hope the info. above useful and solve your problem :)

CheerS :mrgreen: ,
a.T.d
Distance doesn't make you any smaller,
but it does make you part of a larger picture.
Post Reply