Author Topic: Some questions about nasm  (Read 15533 times)

Offline Estrobeda

  • Jr. Member
  • *
  • Posts: 3
Some questions about nasm
« on: April 07, 2013, 03:15:02 PM »
I like to learn nasm becouse i have been interested in making a os as a hobby prodject.
The problem is that i cant nasm i can write helloworld in linux and write a input like name and then output it it is as much as i know.
So i want to learn nasm but i cant find anything anywere to teach me and the things i do find is either to hard to understand or dont cover all the basics etc.
My 1th question is if there are any tips were to find a good tutorial with not to much text becouse to much text becomes boring and hard to not forget the first thing you learned. I want if there are any a tutorial with not to much text but also covers how to use, code etc nasm.
My 2th question is the kernal i want to create a os from scratch only becouse i want to se if i can do it. the question is does nasm need a kernal like unix, dos etc to run or can you create a kernal with nasm that does not need an alredy existing kernal?

And my 3th question is only curiosity, is there a ducumentry or something that says how assembly languages is made? if it is pure 1-0s or hexcode or somthing. (not important just curiosity)

Offline TightCoderEx

  • Full Member
  • **
  • Posts: 103
Re: Some questions about nasm
« Reply #1 on: April 07, 2013, 04:17:19 PM »
NASM at it's core takes about 1/2 hr to learn.  Attached is a version of boot loader specific to my needs. It uses only 6 keywords specific to NASM.  BITS, EQU, ALIGN, TIMES, DB and INCLUDE. Then nasm -O3 Boot.S -oboot.bin and presto, you have a binary that can be copied to boot sector.

The learning you need to do first is understanding IA32 architecture and it's underlying instruction set. Never assume the examples you'll find work correctly and without understanding the hardware your dealing with you'll be ill equipped to spot errors and you'll become very frustrated.

The best way to do this, is to find small examples and the code examples section in this forum is a good place to start.  Then trace through the programs using GDB and watch what happens to registers and/or data after each instruction.

I've been programming both professionally and as a hobbyist since 1978. This chain boot loader I've concocted, took over 200 hrs to design.  Each of the 40 - 50 some odd versions didn't take very long, but then I'd look it over and decide, no I don't like this, or something won't work on a particular computer and so on.  OS development is new to me and I too look at many examples, but at the end of the day, it's my concept and I understand inside out, why it works and the reason I used that particular design paradigm.

OS development only requires a platform such as OSX, Linux or Windows and an appropriate tool chain.  As an example, in Ubuntu I use a terminal, gedit, nasm, dd, kvm (qemu) and another computer that I can test my code on, not using an emulator. Afterwards, whatever you design may or may not be dependant on an existing operating system or file system for that matter.

Lastly, NASM is an assembler unlike C, C++ and so on that are languages.  The assembler just takes each mnemonic and create the appropriate bit pattern for that instruction.
« Last Edit: April 07, 2013, 06:55:22 PM by TightCoderEx »

Offline Estrobeda

  • Jr. Member
  • *
  • Posts: 3
Re: Some questions about nasm
« Reply #2 on: April 07, 2013, 04:44:34 PM »
Thanks for your help and reply, now i have something to do for a while i think =)

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Some questions about nasm
« Reply #3 on: April 07, 2013, 06:08:00 PM »
"unable to open include file 'Intel.Inc'"...

Hi, Estrobeda, welcome to the Forum. Yes, this will give you something to do for a while. Quite a while...

For documentation, the Nasm Manual itself should cover usage of Nasm, but it won't tell you what to do with it. Too much to read the whole thing, but look at the sections covering the output formats you're interested in ("-f elf" and "-f bin" probably...).

I like Dr. Paul Carter's tutorial - http://www.drpaulcarter.com/pcasm - but it's for 32-bit code, and won't help much with a bootloader/OS.

There's a huge amount of information at http://www.osdev.org - you might want to work through the "baby steps" tutorial before tackling TightCoderEx's bootloader, which is quite advanced.

Alfonso (avcabellero?) has written a very nice tutorial covering both 16- and 32-bit coding... but I haven't got the URL at hand. I'll look it up and get back to ya.

More later,
Frank


Offline TightCoderEx

  • Full Member
  • **
  • Posts: 103
Re: Some questions about nasm
« Reply #4 on: April 07, 2013, 06:56:16 PM »
"unable to open include file 'Intel.Inc'"...

Opps. I've included it in original post.

Offline Estrobeda

  • Jr. Member
  • *
  • Posts: 3
Re: Some questions about nasm
« Reply #5 on: April 12, 2013, 06:07:33 PM »
Thanks for the replies =D i like to have stuff to do and i havent jet gone through the first reply tips and suggestions.

Offline Rob Neff

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 429
  • Country: us
Re: Some questions about nasm
« Reply #6 on: April 13, 2013, 12:54:45 AM »
Alfonso (avcabellero?) has written a very nice tutorial covering both 16- and 32-bit coding... but I haven't got the URL at hand. I'll look it up and get back to ya.

Here ya go: http://abreojosensamblador.net