Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
So I have 2 questions here, (Sorry for posting 2 questions in one Article)
1) Is there a BIOS routine that can receive a file from a URL like : www.domainname.tld/file.format
2)This one is for a creating a C Library out of assembly instructions like :
ASM
;===============Assembly Print Function====================
print_string:			; Routine: output string in SI to screen
	mov ah, 0Eh		; int 10h 'print char' function

.repeat:
	lodsb			; Get character from string
	cmp al, 0
	je .done		; If char is zero, end of string
	int 10h			; Otherwise, print it
	jmp .repeat

.done:
	ret

to this :
C++
#include <libc.h> //Name of a header file
int main(void)
{
  printf("Hello World") //This is the print_string function before shown
}


Any help would be appreciated,
~Sids123
Posted
Updated 24-Aug-13 0:42am
v4
Comments
Richard MacCutchan 24-Aug-13 9:20am    
1. I doubt it, the BIOS is extremely low level.
2. Does not really make sense, what exactly is your problem?

This looks very dated code (8080 assembler in DOS 3), where did you find it?
sid2x 25-Aug-13 4:42am    
It's basically a print-string function inside a floppy bootloader :)
Richard MacCutchan 25-Aug-13 6:43am    
Well if you know how to write a bootloader, then a function like this should be simplicity itself.

1 solution

1. Some BIOSes have some extensions but I don't know about any standard bios functions that do so high level stuff like connecting with TCP to a site and downloading file with HTTP protocol... In my opinion PCs should support user friendly network installs (like MACs) but we have to wait with that... I just want to turn on my new empty PC and I want to be able to select/buy an OS of my choice that gets installed with a few button presses with optional customizations (like partitioning).

2. Once I've created a partial printf implementation in assembly to output formatted text for debugging with my PRINTF assembly macro. It was just a partial implementation by supporting only a few formats with partial implementation of formatting parameters. Its a pain in the ass to implement such a function and the same is true for a lot of C library functions. If you are doing this for learning then go ahead with this but its much practical to write such a lib in C because its much easier to do so, much less buggy, easier to debug/fix/understand, portable,... Its usually better to use as minimal platform specific assembly as possible (take a look at the linux kernel) because writing C is much less painful and C is portable.

I see your point because I have my roots in assembly and once I was full of enthusiasm to rewrite the world in assembly but I've found out after a few years that writing everything in assembly is a bad idea for many reasons. Still its good to know assembly and its a nice way to kill some time. Asm knowledge comes very handy sometimes when debugging C/C++ code in windows.
 
Share this answer
 
Comments
sid2x 25-Aug-13 4:45am    
That's a heap of info. Thanks but I still have one doubt, How would I start writing a C library from these ASM functions?
pasztorpisti 25-Aug-13 6:28am    
By starting out with the basics. You want to write a libC in asm when you don't even know how to link asm and C??? Every compiler on every platform has its own rules and calling conventions about register usage and parameter passing. Use google to find out more about the relationship between asm and your compiler on your platform. A c library is nothing more than a library. It only has to contain a few exported functions required by the generated code of the compiler and the functions used by the written programs themselves. I would start out by writing the few necessary functions called by the generated code of the compiler. Which are these functions? You will find out when you are trying to link your program without the original c library...
pasztorpisti 25-Aug-13 11:01am    
As a first step find out how to compile a c program without the original c library then try to compile this program without the original std lib to find out the minimal function set required by the generated code of the compiler itself: "main() { return 0; }". In a more complex language (for example C++) there are lot of fancy builtin functions for example for exception handling, converting ints to floats, and so on... Some compiler generated function calls (like int to float conversion) are present in the code of course only if you write code that requires it...
sid2x 25-Aug-13 7:44am    
Thanks! If you don't mind Can you just tell me one more thing, Let's say I have an OS that boots in real mode, Is it possible to have TCP/IP and Internet support? Assuming that I have necessary knowledge?
pasztorpisti 25-Aug-13 7:54am    
Of course everything is possible but you have to write a network driver (for your particular network card) including the TCP/IP support and all other parts of the network stack. One reason for not writing an operating system: None of the hardware vendors will provide drivers for your OS for their network cards or any other kind of hardware. As a result noone will use your OS... (because your OS will run only on your machine with your hardware. :-)) The same problem holds for the applications: your OS will have zero applications compared to other OSes. If I wanted to work on an OS then I would do that with some kind of embedded OS that is specialized on some hardware and is simple. This way your competition is also a simple OS or OSes... This also requires a lot of experience. Its unlikely that you come up with a better OS than someone who works with these OSes for many years.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900