Saturday, January 19, 2013

Why is there a difference and what is it between assembly language in Linux and Windows?

Q. I am just wondering why the assembly languages for Windows and Linux are different since they are both based on the x86 architecture. And is there a basic assembly language that doesn't rely on an OS? And if so, what is it?
Ok, if they are the same, then why do the different OSs interact differently with it and is there a way to bypass the OS so that you can just program directly to the computer?

A. For a particular architecture (i.e. CPU type) the assembly language is the same. Realize that even modern intel CPUs have different instruction sets but in general most compilers stick to common instruction sets shared amoung all intel CPUs unless advanced instruction sets (aka extensions) are specifically enabled. MMX was one such extension.

Assembly really doesn't have much to do with device IO or drivers since assembly is *below* the operating system. In assembly, you write to or read from (poke/peek) memory locations which may be mapped to devices or be actual memory. If you are actually programming in assembly (not in a compiled language) then you'd just have to know what locations mean what. This "abstraction" is what the OS and compilers provide to higher level languages.

What you are confused about is binary executable format which *is* os dependent. Every executable binary contains information in it that helps the OS know how to run it and what it's called and so forth. Binaries contain the assembly instructions that needs to run but modern binaries are also often not self standing. The "assembly" code in a binary has to be "loaded" and run along with any other "shared" binary code fragments (i.e. shared libraries). This is where the portability breaks down. On the hardware abstraction side, there is also some runtime adjustments that the OS has to do in order to map the right locations into the assembly code. This is because hardware today are not in fixed predictable locations. The bios can move a device from one memory address to another at boot time or even at run time. This is basically what PnP is. It provides a way for the OS to modify how the bios positions hardware in memory to avoid conflicts. That is why if you are running an OS that is *not* PnP aware, you need to disable the feature in the bios so that the bios will initialize and fix those parameters for the hardware at boot time. Once the OS is done with relocation and device mapping, the "code" that is sent to the CPU is assembly and for all intents and purposes this code would be basically the same no matter what OS is used.

So what are some binary formats that are shared... well, ELF is one. Elf is used on various Unix and Unix-like OSs such as Linux and Solaris. Unfortunately binary compatibility is not a useful reality because it requires all the shared components to be compatible versions and format. In a sense, the WINE project in Linux is an attempt to emulate the Windows HAL (Hardware Abstraction Layer) in order to "load" a binary and do all of the necessary relocations for IO and shared components that windows does and then send it to the CPU. In a way, WINE is an attempt to create binary compatibility with windows "EXE" files.

How do unix and linux such as max os x run more efficantly then windows?
Q. I was using max os x today that someone brught in it was pretty cool but im not convinced its better then windows 7 for multitasking.

It feels more responsive but you cant multitask as easy.

A. There are many misconceptions about Unix, Linux and, Windows. If you look at the hardware level of any computer, Unix and Linux will run more efficiently than Windows will. Unix and Linux will install exactly the drivers in each computer it is installed on, you don't need third party drivers, but in some cases that is the only way some of it may need to run. Linux can multitask and I'm sure Unix will also. Unfortunately Windows dominates the world computer use in the average home and most users will find Unix and Linux a little odd and to some point limited, only because third party vendors and developers make more money developing for Windows. Linux is a programmers and hackers dream, because of all the software you can install and not cost you anything but your time. I work with all three operating systems and find Unix is the hardest one to deal with, in most cases.

If Windows is what you like, then Windows is what it should be as a choice. It takes some time and playing around with Linux, before you will actually like it. Most people don't spend enough time with it and really aren't sure how to install all the software and programs. Sorry I got carried away, and probably didn't answer your question.

Can you have multiple user accounts on Ubuntu Linux?
Q. I'm trying to persuade my parents to run Linux in addition to Windows Vista on our computer. My question is, can we have multiple user accounts on Linux? Like on Windows?

A. The answer to the question - absolutely
Linux is designed from the ground up as a multi-user system, rather than as an add on the way it works in Widows.
When you create additional users in Linux, that account is created with their own personal space, totally separate from other users. What they do in their space does not affect what another person sees when then use their space. It is a far superior system to what Windows does.

A couple of hints when doing your Linux dual boot system

1. While all major Linux distributions today can partition a Windows hard drive and add Linux to an existing system, there is always the odd case where Windows objects to sharing space with Linux. I have heard that Vista is particularly touchy about it.
So my recommendation is to add a second hard drive to your box. You do not need a big drive, you can get just about any drive sold in a store today and add it to your box.
Then install Linux on the second drive. This way, your Vista drive remains pristine, and Vista goes on happily ignorant that "another OS" exists.
Linux will install a boot loader utility that will allow you to choose the OS you want to boot into.

2. Be prepared to experiment, explore and try new things and ideas. Linux is very different from Windows. Things that are falling off a log easy in Windows can become very difficult in Linux if you keep approaching it "the Windows way"
I have changed distributions, and changed releases within distributions many, many times. I have loaded, unloaded, installed and un-installed apps and distros as I have tried to achieve my goals. Linux has never let me down. There has always been a way, but I am not going to say the way is always smooth or simple.
One thing is for sure, you learn a lot

All that said, I hope your parents let you proceed. As long as you do your work on the second hard drive, the Windows install will be unaffected and that should make them feel a lot better about the whole thing

Drop me a line if I can help

Welcome to Linux



Nec Projector Review

Plastic Shed Reviews

Ati Graphic Reviews

Nurse Uniforms Reviews

Cabochons Reviews

Inflatable Water Slides Reviews

Barcode Scanner Reviews

No comments:

Post a Comment