The MASM Forum

General => The Campus => Topic started by: xdc on June 01, 2012, 05:14:42 PM

Title: assembly without libraries
Post by: xdc on June 01, 2012, 05:14:42 PM
the reason I switched from High level languages to assembly was because
I wanted to learn without using libraries. I want to learn how to make
my own printf, scanf functions etc

I was using the c++ std lib, and tried graphics programming, etc It didn't feel right, it seems like
too much is going on in the background that I still don't know, and that's what i want to learn!

I've looked around for this for c/c++, but I've only get negative
responses, or 'talk of reinventing the wheel', etc

I have AoA, the non-HLA version, it might be the ms-dos version, but i hear
people say skip 16 and go to 32bit, etc

Is there a book that is to my liking of programming?
Do I have to go through using these libraries till I can make my own?
Title: Re: assembly without libraries
Post by: jj2007 on June 01, 2012, 05:43:56 PM
There is no "with" vs "without". There is only "more" vs "less libraries".
For example, you could write your own version of print, but somewhere inside you will inevitably have to revert to WriteFile or WriteConsole - and these are functions of one big fat library called "Windoze"...

If you have installed Masm32, open \Masm32\examples\exampl07\slickhuh\slickhuh.asm and spend some time trying to understand it (and I am afraid even that one uses Windows...). Then come back and tell us if you really want to live without libraries and high level elements.
Title: Re: assembly without libraries
Post by: anta40 on June 01, 2012, 06:14:33 PM
Do I have to go through using these libraries till I can make my own?

like JJ said, as long as your app run on OS (Windows, Linux, etc), eventually you'll end up using their native API.
C's printf, for example, may be implemented using WriteFile of WriteConsole on Windows.

AFAIK the only way to code in assembly without using those libraries is... to write your own OS. Then you can write your own printf, scanf, graphics engine, etc.
Title: Re: assembly without libraries
Post by: xdc on June 01, 2012, 06:37:33 PM
There is no "with" vs "without". There is only "more" vs "less libraries".
For example, you could write your own version of print, but somewhere inside you will inevitably have to revert to WriteFile or WriteConsole - and these are functions of one big fat library called "Windoze"...

If you have installed Masm32, open \Masm32\examples\exampl07\slickhuh\slickhuh.asm and spend some time trying to understand it (and I am afraid even that one uses Windows...). Then come back and tell us if you really want to live without libraries and high level elements.

are there any books/tutorials for this kind of thing? I'm still using libraries but if that's as low as it gets without having to create your own OS that
sounds great to me.

Do I have to go through using these libraries till I can make my own?

like JJ said, as long as your app run on OS (Windows, Linux, etc), eventually you'll end up using their native API.
C's printf, for example, may be implemented using WriteFile of WriteConsole on Windows.

AFAIK the only way to code in assembly without using those libraries is... to write your own OS. Then you can write your own printf, scanf, graphics engine, etc.

thanks, ill also start looking into OS development
Title: Re: assembly without libraries
Post by: Vortex on June 02, 2012, 03:50:32 AM
Hi xdc,

Try to study the Masm32 examples as much as possible. They will give you an idea.
Title: Re: assembly without libraries
Post by: raymond on June 02, 2012, 10:34:53 AM
Hi xdc,

You can effectively program without the use of libraries as long as you don't interact with the external "hardware". Unless you run strictly in DOS mode, a modern OS will not let you directly access external hardware (such as the monitor screen).

However, there are numerous ways to put a pixel on the screen (using OS functions), but some are a lot faster than others; and that becomes important when the quantity and rate increase significantly. That is where assembly can excel.
Title: Re: assembly without libraries
Post by: Adamanteus on June 02, 2012, 05:24:13 PM
I've looked around for this for c/c++, but I've only get negative
responses, or 'talk of reinventing the wheel', etc
The "wheel" consist of some algos, that is till now commercial secretes, becouse it's not easy to rewrite them.
So if you'd like to "learn how to make my own printf" you could make you own - that's all you can do.
Normal way in you case - first choose developer environment (including OS), then collect for it all algos that you see in sources or lib-files, make from it own library (for not loosing code) - building part from sources, other save with docs that to access it easy. Meanwhile you'll be understanding how's it works, replace some of functions by you own - more excellent, and so on  ::)
Title: Re: assembly without libraries
Post by: dedndave on June 02, 2012, 09:47:13 PM
what hasn't been mentioned...

most of the libraries you see in the masm32 package are import libraries
they allow you to link a program to the operating system functions

a good example might be the ExitProcess function
it's hard to write a valid win32 application without using that one   :P
the actual code is in kernel32.dll, which is in your Windows\System32 folder - part of the OS
the import library kernel32.lib gives the linker a way to resolve this external reference
kernel32.inc defines the prototype so the assembler knows the parameter format