473,320 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

how run c program in protect mode with out OS

Now, the situation is I have two program, one is bootloader, it run
in
a floppy disk at 0x7c00, it works greak, it function is load the fd's
second and third sector into memory(2nd sector at 0x8000, 3rd sector
at 0x9000), the code at 0x8000 is used for enable the protect mode,
after that, GD-CODE segment in GDT is from 0 to 4GB, GD-DATA is same,
too. Then jump to 0x9000 and execute my program was loaded from fd's
3rd sector. I want to run a C-compiled program, is it's format must
be
'32bit plain binary file', and I'm using gcc, ld, objcopy to make it.

gcc -c test.c
ld test -o test.o -e my -Ttext 0x9000 -i
objcopy test.o test.bin -R .note -R .comment -S -O binary
the complete C code is here:
---------------------------------------------------------------------------*-------------------------------------------
void my()
{
unsigned char *vm=(unsigned char *)0xb8000;
*(vm++)='a';
*(vm++)=0xc;
*(vm++)=0xc;
*(vm++)='d';
while(1);
}
---------------------------------------------------------------------------*--------------------------------------------
it doesn't work~~!
and my assemble file works fine.

code is here:
(nasm)
---------------------------------------------------------------------------*----------------------------------------------
bits 32
org 09000h
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;*;;;;;;;;
mov edi, (80 * 0 + 0) * 2 + 0b8000h
mov ah, 0Ch
mov al, 'a'
mov [ds:edi], ax
mov edi, (80 * 0 + 1) * 2 + 0b8000h
mov ah, 0Ch
mov al, 'b'
mov [ds:edi], ax
mov edi, (80 * 0 + 2) * 2 + 0b8000h
mov ah, 0Ch
mov al, 'c'
mov [ds:edi], ax
mov edi, (80 * 0 + 3) * 2 + 0b8000h
mov ah, 0Ch
mov al, 'd'
mov [ds:edi], ax
mov edi, (80 * 0 + 4) * 2 + 0b8000h
mov ah, 0Ch
mov al, 'e'
mov [ds:edi], ax
mov edi, (80 * 0 + 5) * 2 + 0b8000h
mov ah, 0Ch
mov al, 'f'
mov [ds:edi], ax
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;*;;;;;;;;;;;
jmp $
---------------------------------------------------------------------------*---------------------------------------------------------------
Jan 20 '08 #1
2 1719
sorry to everyone, it works well.
i made some serious mistakes.
Jan 20 '08 #2
Yi********@gmail.com wrote:
sorry to everyone, it works well.
i made some serious mistakes.
Free standing, platform specific code is perhaps more topical for
alt.os.development or comp.arch and perhaps alt.lang.asm. This group is
primarily for Standard C which is usually inadequate for such purposes.

Jan 20 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: shoo | last post by:
Any one know how to do this? thank Write a simple text-formatting program that produces neatly printed output from input text containing embedded command lines that determine how to format the...
6
by: shoo | last post by:
Any one know how to do this? thank Write a simple text-formatting program that produces neatly printed output from input text containing embedded command lines that determine how to format the...
8
by: G Patel | last post by:
I wrote the following program to remove C89 type comments from stdin and send it to stdout (as per exercise in K&R2) and it works but I was hoping more experienced programmer would critique the...
4
by: sunniyeow | last post by:
Hi, My question is regarding password protecting 2 different folders inside a single virtual directory using forms authentication method. Easier if I illustrate things out... - <authentication...
7
by: Alan Silver | last post by:
Hello, Sorry this is a bit wordy, but it's a pretty simple question... I have a web site, http://domain/ which is a public site, part of which (http://domain/a/) is protected by forms...
10
by: Flavio | last post by:
Hi, I try to write here because maybe my problem is a common one. I have a rather complicated multithreaded program, which uses the POSIX pthread standard. A master routine calls a series of...
17
by: Mario | last post by:
Hello, I need a program what generates me a blue screen in Windows XP with .net! This should be simple, but how? Please help me. Mario
2
by: r_spaargaren | last post by:
Hello, for a school project i need to program the Motorola 68HC11 to use the HD44780 LCD controller, and this must be done in C lang plus maybe a bit of assembly. The 68HC11 uC is embedded in a...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.