![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Hobbyist Programmer
Join Date: Apr 2006
Posts: 155
Rep Power: 3
![]() |
Hi everybody!
I want to learn Assembly, but it seems to be hard to find something about it. I have programmed C, C++ and Python, but i have heard that Assembly is kinda good for understanding different stuff. So.. Can someone tell me about Assembly and/or Assembler? What programs there can be used for it? Some basic, for an example a "Hello World"-program? How I start? Is it a good thing to learn Assembly? I have allready looked around on the net, but i din't find something. (http://www.programmingforums.org/for...ead.php?t=5405) Hope someone can help! (Sorry my english..) |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Microprocessor operations are driven by the application of hardware gating and clocking signals which apply binary logic levels to various devices. Some of these devices are memory elements outside the cpu, some are memory elements inside the cpu (registers), some perform binary logic and arithmetic operations. There are others. These signals are controlled by binary signal states that have as their source (primarily) the "instructions" provided by those who are programming the device. The physical arrangement of the wiring of the bits will determine what causes two things to be added in one processor, versus what states will cause the same operation in another processor. These are the "machine instructions." Assembly language is, essentially, a set of mnemonics that represent these codes. There is very little abstraction other than being able to say, "LD A, 7", versus "0x3E 0x07". This situation can be mitigated somewhat by macro assemblers and so-called "high-level" assemblers. Despite exceptions and caveats, one is essentially dealing with the nuts and bolts.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Professional Programmer
![]() Join Date: Sep 2005
Posts: 419
Rep Power: 4
![]() |
>Can someone tell me about Assembly and/or Assembler?
Assembly is a language based on mnemonic names for machine instructions. It's as low as you can get without using a hex editor to manually write opcodes. An assembler is a program that translates the mnemonic names and other directives into machine code. >What programs there can be used for it? It depends on what you're doing. Some assemblers can output executable programs directly, so all you would need is the assembler and a debugger. A somewhat more flexible approach uses assemblers that output object files, in which case you need the assembler, a debugger, and a linker. OllyDbg is a good debugger, and I usually use the linker that comes with GCC. >Some basic, for an example a "Hello World"-program? Here's one in FASM that assembles right to an executable: format PE console
entry start
include 'C:\fasmw\include\win32a.inc'
;======================================
section '.data' data readable writeable
;======================================
hello db 'Hello, world!',10,0
;=======================================
section '.code' code readable executable
;=======================================
start:
cinvoke printf,hello
invoke ExitProcess,0
;=====================================
section '.import' import data readable
;=====================================
library kernel,'kernel32.dll',\
msvcrt,'msvcrt.dll'
import kernel,\
ExitProcess,'ExitProcess'
import msvcrt,\
printf,'printf';============== [section .data] ;============== hello db 'Hello, world!',10,0 ;============== [section .text] ;============== global _main extern _printf _main: push hello call _printf add esp,4 mov eax,0 ret #include <stdio.h>
int main ( void )
{
printf ( "Hello, world!\n" );
return 0;
}format MS COFF include 'C:\fasmw\include\win32a.inc' ;=================== section '.data' data ;=================== hello db 'Hello, world!',10,0 ;=================== section '.code' code ;=================== public _main extrn _printf _main: cinvoke _printf,hello mov eax,0 ret Get an assembler, find a reference, and start writing programs. Just like any language. Of the assemblers out there, the most popular are MASM, NASM, and FASM. FASM is a good combination of flexibility and simplicity, but NASM is easier to learn in my opinion. MASM has too many inconsistencies to be a good first assembler, but it's powerful. You might also look into HLA, if you want to ease into assembly rather than jump right in. >Is it a good thing to learn Assembly? Yes.
__________________
Even if the voices aren't real, they have some pretty good ideas. |
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Apr 2006
Posts: 155
Rep Power: 3
![]() |
Thanks both of you.
But i don't really understand it. Can someone please give me a step-to-step-Guide? Linker-program: Which one? Assembler-program: Which one? Debugger-program: Which one? -- MASM is..? Shall i download it? NASM is..? Shall i download it? FASM is..? Shall i download it? HLA is..? Shall i download it? ... And if you have some links, I'll be pleased I'm sorry, but i just really want to learn it! Last edited by v0id; May 3rd, 2006 at 7:35 AM. Reason: I forgotten something |
|
|
|
|
|
#5 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
This is a personal viewpoint. Check Narue's avatar to see if there's agreement. If you don't know what constitutes a typical, basic 'computer', memory, the cpu with its registers, alu, and such, you need to go there first. No need to worry initially about such things as MMUs, cache, and the like. Just the basic operational elements and how they interact.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#6 |
|
Professional Programmer
![]() Join Date: Sep 2005
Posts: 419
Rep Power: 4
![]() |
>But i don't really understand it.
You're not expected to understand everything immediately. >Can someone please give me a step-to-step-Guide? I'm working on one, but it's not ready yet. >Linker-program: Which one? >Assembler-program: Which one? >Debugger-program: Which one? That's like asking someone which layout style to use. It's 100% personal preference if you're not forced to use something. If you don't have a preference, try them all and develop one. >... And if you have some links, I'll be pleased www.google.com
__________________
Even if the voices aren't real, they have some pretty good ideas. |
|
|
|
|
|
#7 |
|
Hobbyist Programmer
Join Date: Apr 2006
Posts: 155
Rep Power: 3
![]() |
DaWei >
I don't actually know how a computer works with CPU, Memory and all that stuff. I actually thought that i could learn something about it, throught Assembly. But I was wrong? Shall i read about CPU, Memory etc. before i'm going to learn Assembly? Narue > >> I'm working on one, but it's not ready yet. It will be nice! *I din't know ASM was so damn hard! But someday, I will learn it!* Last edited by v0id; May 3rd, 2006 at 8:22 AM. Reason: Typed wrong |
|
|
|
|
|
#8 |
|
Professional Programmer
![]() Join Date: Sep 2005
Posts: 419
Rep Power: 4
![]() |
>I actually thought that i could learn something about it, throught Assembly.
You can. >Shall i read about CPU, Memory etc. before i'm going to learn Assembly? If you start with 32-bit flat mode, there's not much to it. The tricky stuff is under a segmented architecture. Modern x86 assembly doesn't require intimiate knowledge of the hardware to get started. >I din't know ASM was so damn hard! Assembly is actually easier to learn than any high level language I can think of. You just need to shift your thinking, and that's where most people stumble.
__________________
Even if the voices aren't real, they have some pretty good ideas. |
|
|
|
|
|
#9 |
|
Hobbyist Programmer
Join Date: Apr 2006
Posts: 155
Rep Power: 3
![]() |
It's maybe not hard to learn the language, but it's hard to getting started with all the debuggers, linkers etc.
A hurry question: Is Assembly just for extensions to C and other lanuage, or can it make Applications by itself? And can it make bigger applications or just some small stuff, like calulate? (I'm sorry that i ask so much (I don't normally do), but I just can't find anything of ASM) |
|
|
|
|
|
#10 | |
|
Caffeinated Neural Net
![]() Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,033
Rep Power: 5
![]() |
Quote:
Anyways, to get back to your question, assembly is often used in conjunction with other languages. Many things are easier to express in a high-level language like C++, but certain things are easier to do in assembly, or can be made more efficient. Thus, you might see a game written almost entirely in C++, with some very speed-critical portions written in assembly. However, as the hardware gets faster and compilers get smarter, assembly is used less these days than in previous years. That said, if the hardware is capable of something, then it is certainly possible to write a program in assembly language to do it.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|