Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 29th, 2005, 12:21 PM   #1
teencoder
Hobbyist Programmer
 
teencoder's Avatar
 
Join Date: Jul 2005
Posts: 158
Rep Power: 0 teencoder is an unknown quantity at this point
Exclamation Should I learn assembler?

I mean with X64 prohibiting inline assembler is it worth it I mean isn't the only modern use of assembler to pump extra speed.
I'm currently learning a ton of C++ and stumbled upon inline assembler on the web researched and googled. And discoverd an X64 issue with inline assembler witch is turning me down. Will X86 assembly be similiar enough to X64 to make X86 assembler knowledge worth while.
__________________
Geeks may not be cool now but in the long run they prosper.
teencoder is offline   Reply With Quote
Old Jul 29th, 2005, 1:36 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Learning assembly language will give you a better idea of how the device works under the hood. It will not automatically give you the ability to wreak the utmost from the machine in terms of perfomance, as it would have in years gone by. The nature of the beast has changed with the advent of hyperthreading, dual-core, co-processing, and instruction and data cache. It takes a lot of study far beyond the mere learning of opcodes to master those things.

The machine code emitted by compilers is usually less efficient in terms of footprint and register usage than a hand coder could achieve, but the story goes far beyond that. Even compiler writers who have studied the best ways in which to achieve optimal use of the machine can be stymied by the differences between models. The correct approach to pipelining, for instance, will be dictated by the number and size of the cache segments, and that may well vary from model to model.

I realize that the younger generation considers a knowledge of assembler to be "cool". For the older generation, it was often the only game in town. I doubt that any of you can actually appreciate the fact that it was once economical for me to spend three weeks figuring out how to save SEVEN BYTES!!! :eek: That translates to a pain in the south end for a coder walking north. There is a market for the highly competent assembly coder, but it's a relatively tiny niche. If you aim for it, you better be among the best.
__________________
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
DaWei is offline   Reply With Quote
Old Aug 3rd, 2005, 11:03 PM   #3
iignotus
Professional Programmer
 
iignotus's Avatar
 
Join Date: Apr 2005
Location: Nowhere Special
Posts: 466
Rep Power: 4 iignotus is on a distinguished road
Send a message via AIM to iignotus
You spelled 'Geeks' wrong n00b. Welcome.
__________________
% rc4 hexkey < input > output
#define S ,t=s[i],s[i]=s[j],s[j]=t /* rc4 hexkey <file */
unsigned char k[256],s[256],i,j,t;main(c,v,e)char**v;{++v;while(++i)s[ 
i]=i;for(c=0;*(*v)++;k[c++]=e)sscanf((*v)++-1,"%2x",&e);while(j+=s[i]
+k[i%c]S,++i);for(j=0;c=~getchar();putchar(~c^s[t+=s[i]]))j+=s[++i]S;}
iignotus is offline   Reply With Quote
Old Aug 4th, 2005, 9:24 PM   #4
teencoder
Hobbyist Programmer
 
teencoder's Avatar
 
Join Date: Jul 2005
Posts: 158
Rep Power: 0 teencoder is an unknown quantity at this point
I'll look in to it. I know it will be hard accessing the processer directly. Plus to me that seven bytes makes since back then capacities were greatly smaller than that of a high density floppy. Back then lean and mean was the game now it's cool bloatware quite a shame. Can you possibly show what the hello world program would look like. Thanks.
P.S. Popularity is the last thing on my mind. I just like pushing myself to my mental limits.
__________________
Geeks may not be cool now but in the long run they prosper.

Last edited by teencoder; Aug 4th, 2005 at 9:41 PM.
teencoder is offline   Reply With Quote
Old Aug 4th, 2005, 9:32 PM   #5
OpenLoop
Expert Programmer
 
OpenLoop's Avatar
 
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4 OpenLoop is on a distinguished road
Quote:
Originally Posted by teencoder
Back then lean and mean was the game, now it's cool bloatware quite a shame.
Hey, that rhymes. Forget programming, go to poetry. Maybe you'll become a rap star and make more than all the programmers on earth combined.
Back to your question, I think DaWei answered it pretty well. I liked assembly days, pretty fun stuff to be programming hardware and voltages if you ask me.
OpenLoop is offline   Reply With Quote
Old Aug 4th, 2005, 9:56 PM   #6
Gink
Newbie
 
Join Date: Apr 2005
Posts: 12
Rep Power: 0 Gink is on a distinguished road
Quote:
Originally Posted by teencoder
I'll look in to it. I know it will be hard accessing the processer directly. Plus to me that seven bytes makes since back then capacities were greatly smaller than that of a high density floppy. Back then lean and mean was the game now it's cool bloatware quite a shame. Can you possibly show what the hello world program would look like. Thanks.
P.S. Popularity is the last thing on my mind. I just like pushing myself to my mental limits.
[BITS 16]

SEGMENT cstart

..start:

mov ax,data
mov ds,ax

mov ax,stack
mov ss,ax

mov sp,stacktop

mov ax,0x0900
mov DX,HelloMsg
int 0x21

mov ax,0x4C00
int 0x21


SEGMENT stack stack
resb 64
stacktop:

SEGMENT data
HelloMsg db "Hello World!",0xD,0xA,'$'

Last edited by Gink; Aug 4th, 2005 at 10:23 PM.
Gink is offline   Reply With Quote
Old Aug 4th, 2005, 11:02 PM   #7
teencoder
Hobbyist Programmer
 
teencoder's Avatar
 
Join Date: Jul 2005
Posts: 158
Rep Power: 0 teencoder is an unknown quantity at this point
Okay I have alot of research to do I see alot of Hex addresses. I knew this wasn't going to be easy. Then again nothing worth having comes easy.
__________________
Geeks may not be cool now but in the long run they prosper.
teencoder is offline   Reply With Quote
Old Aug 5th, 2005, 7:59 AM   #8
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Note that the assembly program shown presumes that you have real mode capabilities and MSDOS functions behind a software interrupt table (or an emulation thereof) that matches up with a particular BIOS. I/O is highly machine dependent no matter how you write it and OS dependent if you're trying to take advantage of existing I/O functions.

All machine values are binary. Hexadecimal allows one to express that in physically shorter numbers that provide the ability to mentally visualize the state of each bit in the pattern.

Assembly language has nothing directly to do with programming "hardware" and "voltages". Registers and memory are hardware, but they remain hardware even when you're stuffing them with the emissions of a high level language. Your program neither knows nor cares whether the processor is running at 3.3 volts, 5 volts, or lebenty-leben volts.

The simple, essential microprocessor is not hard to understand. It has at its heart an ALU (arithmetic/logic unit) with two inputs and one output. The number of bits ganged together as "one input" varies. The ALU can do a few things such as add, and, and invert. Which it does depends upon the control signals applied to it. These are provided by the "opcode" part of your instruction. The values to be operated on are provided by the "operand" part of the instruction. These may be immediate (value right in the instruction), direct, or indirect. The opcode also specifies what to do with the result.

Instructions are no different than data. They're just used differently. One indicates that they are instructions by pointing at them with the machine's instruction pointer. When the machine reads an instruction, it knows by its content how many following bytes are used as a part of THAT instruction, and consequently, where the NEXT instruction begins. Designers dink around with this organization and come up with organizational methods and approaches that determine whether or not the particular device is CISC, RISC, or whatever.
__________________
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
DaWei is offline   Reply With Quote
Old Aug 6th, 2005, 11:05 PM   #9
teencoder
Hobbyist Programmer
 
teencoder's Avatar
 
Join Date: Jul 2005
Posts: 158
Rep Power: 0 teencoder is an unknown quantity at this point
Okay so if I learned assembler I would ultimatly understand software from the ground up? And if I write in mainstream 32-bit X86 code will my code run on AMDs and Intels that use X86 alike? Any good tutorials you can recommend? If I make a big mistake will I fry my computer?
__________________
Geeks may not be cool now but in the long run they prosper.
teencoder is offline   Reply With Quote
Old Aug 7th, 2005, 9:39 AM   #10
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Quote:
Okay so if I learned assembler I would ultimatly understand software from the ground up?
No. No more than learning to use a pencil or a typewriter or a word processor will make you a Hemingway. You will have learned to use a tool. In doing so you will have learned something about current microprocessor architecture. You will also no doubt learn why a good, high-level language is a Valuable Thang.
__________________
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
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:26 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC