Windows Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsWindows Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 30th, 2012, 02:48 PM
jmsparkland1 jmsparkland1 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2012
Posts: 2 jmsparkland1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 32 sec
Reputation Power: 0
Assembler question

I know that this very well may be a stupid question, and I know that it isn't Windows specific, but how does an operating system at its most primitive level, understand assembler? Does it have a compiler or something stored somewhere? If anyone knows a place where I can learn about this, it would be very appreciated.

Reply With Quote
  #2  
Old March 30th, 2012, 05:39 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Jun 2003
Posts: 14,257 Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 19 h 1 m 26 sec
Reputation Power: 4445
Computers understand only binary bits. Numbering systems like hexidecimal and octal, assembly language and higher-level compilers are only around to make binary bits more readable and understandable by humans.

An assembler like MASM does the same thing a compiler does, it creates a collection of binary bits from some human-friendly language.

You could start by finding the instruction set for a simple CPU like an old 8008 or Z80 or 6502 chip to get a feel for how the computer actually does things. Newer processors still do the same things and work basically the same way older processors did, just a whole lot faster and with more built-in math and other functions today.

I had to manually key in a 6-instruction bootstrap program on my first home computer. At that time there was no concept of a BIOS, just a chunk of bare metal waiting for some binary bits to tell it what to do.
__________________
======
Doug G
======
It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi

Reply With Quote
  #3  
Old March 30th, 2012, 06:10 PM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Lost in code
Dev Shed God 7th Plane (8000 - 8499 posts)
 
Join Date: Dec 2004
Posts: 8,063 E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 1 Day 6 h 49 m 31 sec
Reputation Power: 7104
An operating system isn't responsible for actually executing the code, so it doesn't need to understand assembly. As Doug mentioned, assembly isn't actually the most primitive level. An assembler takes assembly and converts it from human-readable code into a series of instructions. Each instructions is some number of bits long (determined by the architecture). Many assembly instructions map into a single machine instruction, but some assembly instructions will be mapped into multiple machine instructions by the assembler. The machine instructions themselves are virtually unreadable to humans because they are nothing more than a series of bits (most commonly represented as numbers).

So the assembler itself exists at the same level as any other program on your computer.

The processor hardware is responsible for actually executing those machine instructions. It reads them directly and performs the actions they say to take. The logic for executing the instructions is physically built into the processor hardware. The processor hardware cannot understand assembly.

You may want to look up information on RISC. It's great for learning the basic concepts.
__________________
PHP FAQ
How to program a basic, secure login system using PHP
Connect with me on LinkedIn


Quote:
Originally Posted by Spad
Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

Reply With Quote
  #4  
Old March 30th, 2012, 08:29 PM
jmsparkland1 jmsparkland1 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2012
Posts: 2 jmsparkland1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 32 sec
Reputation Power: 0
Thank you, this clears some things up. But -- how is an instruction set defined to a processor? For example if something like the code "10000000" is fed to a processor, which means "NULL," how does it know that this order of digits does this thing? What is a flag, or a register? I know this a lot, but any hep would be greatly appreciated.

Reply With Quote
  #5  
Old March 30th, 2012, 10:08 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Jun 2003
Posts: 14,257 Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 19 h 1 m 26 sec
Reputation Power: 4445
Quote:
Originally Posted by jmsparkland1
Thank you, this clears some things up. But -- how is an instruction set defined to a processor? For example if something like the code "10000000" is fed to a processor, which means "NULL," how does it know that this order of digits does this thing? What is a flag, or a register? I know this a lot, but any hep would be greatly appreciated.
The manufacturer of the processor determines the actual instruction set. For pretty much as long as there have been digital computers the "CPU" has consisted of a few "registers" that hold "words" of data, and some kind of sequencer that acts on the data in registers.

The first few computers I worked on only added. They had a register, an adder register and an accumulator register that collected the results from the adder. Instructions are executed sequentially from memory (memory, memory addressing and such are for another discussion). The cpu is given a starting address of a program. The contents of the first memory address are loaded into the opcode register where the processor hardware decodes the instruction and acts accordingly. The processor then automatically sequences to the next memory address and repeats the cycle, unless the opcode caused a "jump" to move the program execution to a different spot in memory.

Typical machine instructions do things like fetch a word from memory and put it in a cpu register, add the contents of two registers, conditionally jump if a register contens meet some test like being zero, postitve, negative, etc.

This cycle of executing insstructions continues until the cpu reaches a stop instruction or exhausts the memory.

Modern PC's have a built-in start address that points the processor to the BIOS, which is just a program stored in non-volitale memory.

Reply With Quote
  #6  
Old March 30th, 2012, 10:17 PM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Lost in code
Dev Shed God 7th Plane (8000 - 8499 posts)
 
Join Date: Dec 2004
Posts: 8,063 E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 1 Day 6 h 49 m 31 sec
Reputation Power: 7104
The instruction set is defined only by the physical electronic properties of the processor's circuity. Its definition, as far as the processor is concerned, is literally only the order in which the gates and components in the processor are physically wired to one another.

Of course, since a human cannot look at a schematic with a billion transistors on it and make any sense of it, documentation for humans is written in a high level human language like English.

As a drastically simplified example, if I have a 32 bit instruction it means the processor starts by applying 32 separate voltages to different input "pins". Those pins are connected to different chains of logic gates, which could eventually connect to 32 output "pins". The "instruction set" is documentation of what the values of those output pins will be given any set of input pin values.

"NULL" is a high level language construct; in general a processor would have no concept of it, they deal only with numbers.

A flag is normally a boolean (one bit) value.

A register is a small piece (32 or 64 bits commonly) of memory on the processor that can be accessed directly by most instructions. Most mathematical operations use the values from two registers as their operands.


Wikipedia actually has a really good reference for how to encode instructions for the MIPS RISC architecture.
http://en.wikipedia.org/wiki/MIPS_architecture
That will give you an indication of why this is pretty much never done by hand anymore except as a learning exercise.

Each instruction is a 32 bit number (for MIPS). This consists of some bits to specify the format of instruction (which defines its arguments), some bits to specify the type of the instruction (which defines what it does) and then some variable number of arguments (depending on the format).

As an example, in an I-format instruction the first 6 bits specify the format and type of instruction. If these bits have the value 001001, then the processor performs an addiu instruction. The next 5 bits specify the number of the destination register (0-31). The results of the addition will be saved to that register's memory. The next 5 bits specify the number of a source register (0-31); this will be used as one of the operands in the addition. The remaining 16 bits are treated as an unsigned integer and added to the value taken from the source register. The result is then stored back to the destination register. When that is complete, the instruction is fully executed.

So, if I give the number 606,076,930 to the processor as an instruction input, it will add 0+2 and store the result in register #1 (register #0 always has a value of 0, which is where the 0 comes from).

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsWindows Help > Assembler question

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap