News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Newbie alert - print to console without Win API call

Started by mikichi, December 27, 2016, 05:35:40 AM

Previous topic - Next topic

mikichi

Hello everyone,
My name is Michael 24 y/o programmer from israel, I have experience with various languages such JS, C#, PHP, Haxe(my favorite :)) and more...
About week ago I decided to learn asm because I think it'll give me a better performance perspective and understanding my code.
I have windows 10 x64, Intel i5 CPU and I'm using MASM(ml) for writing my asm.
So i dig all over the internet to understand how to create a "hello world" program, but! because my main interest is learn how things working I want do this without any Macro or Win API calls, but till now without success.
It's possible to do that? (print to console without Win API?)
I just think that Win API calls is abstract for the real code, so it is not different from doing printf in C, so I'm feeling that by using Win API I'm misses the point of "touch the metal"...
Thanks,
Michael
P.S: Sorry for my english.
P.S1: if you have any recommendation I would love to hear.
P.S2: I have access to all Microsoft products, so if they have something interesting in asm area, please let me know.

rrr314159

Hello Michael,

First, Macro is very different from API. When you use a Macro, from instance from masm32's library, you're invoking low-level MASM source code. Don't know how familiar you are with it, it's a bit like a procedure call. So you can go read that source code and dig down as deep as you want. IOW macro's don't stop you from "touching the metal".

Second, basically, you can't print without using an API call in modern windows. Long ago, you could, but no longer. You could use a DOS 16-bit emulator and old-fashioned interrupts but that insulates you from the "metal" (we usually refer to it as the "silicon", BTW) even more. The only way to do it would be to get around Windows somehow, with techniques similar to sophisticated hacking. But you have to be extremely expert in MASM, and Windows itself, before you can hope to do that.

The right way to go is as follows. Use the standard Windows API calls, such as printf, to print. It's approximately impossible to get started without being able to print out results. A beginner has no business trying to "roll your own" printing routine. You'll find there are an awful lot of low-level (touching the metal) things to learn. Probably take a year or so. At that time you might know enough to dig down to the intimate details of printf, if you still want to.

Good luck ... !
I am NaN ;)

mikichi

Thank you very much for your answer!
Do you have a recommended comprehensive tutorial for MASM?

BTW: Why we still using this "old"(but gold!) forums system? If the users are interesting, I can help with that(by install Discourse)

hutch--

Hi Michael,

Neither 32 or 64 bit MASM comes with a runtime library but they both have a powerful but quirky pre-processor so between the Windows API functions and macros written with the preprocessor language, you can get enough up and running to then start writing assembler algorithms for speed. On the top right hand corner there is a link to the MASM32 SDK which puts a lot of capacity in your hands so that you can get code to work without having to write your own runtime library first.

> Why we still using this "old"(but gold!) forums system?

Simple, if it ain't broke, don't fix it. Forums work well and have been reliable for years.

rrr314159

Quote from: mikichi on December 27, 2016, 06:17:57 AMDo you have a recommended comprehensive tutorial for MASM?

I don't think you can do any better than this forum's masm32 tutorials and examples. Especially considering you're already very familiar with programming - because masm32 is not for the faint of heart. Download the masm32 package, read the help and tutorials a bit, and as soon as you can, dive into the examples. Get each one working, play with them, and ask questions. Read extensively on the forum, almost every topic is covered somewhere. Instead of using the native search function I usually just google, and this forum is often at the top of the hits. Of course other useful sources also come up. This approach requires initiative on your part, but you'll learn 10X faster (literally) than by taking a course or following a book. If you need your hand to be held, it won't work ... but in that case, you really shouldn't be learning MASM anyway.

For the time being, don't bother with 64-bit. Not that it's any harder than 32, but there's much less help and resources available. About 98% of what you learn for 32-bit is directly applicable to 64, when you get to it.
I am NaN ;)