Skip to main content
gamedev.net
🔒 Locked

Understanding assembler

Started by Ashaira 5 replies 2.2k views
Original Post
Ashaira
Ashaira
Well it seems i am lacking some very basic knowledge regarding c++ and a friend of mine told me i seem to not understand the hardware part of how programming and memory works and that understanding how the assembler works would help me cement and connect what i already know.
(consider that when i saw square(3++); i thought 4 would be sent as a parameter i tend to agree with him)

so does anyone know where i could learn about how assembler works? i dont want to learn to code in it just understand the principles of how it does things.
Hodgman
Hodgman
With that specific example ([font=courier new,courier,monospace]square(3++)[/font]), it's more of a C++ nuance than a "big picture"/hardware knowledge deficiency. In C++, "x++" means "x = x + 1", so "3++" means "3 = 4", which isn't valid code ;)

Back to your actual problem though, in a Computer Science or Software Engineering course, you'd likely take a class called something like "Computer Architecture", where you'll learn the basics of different hardware components, assembly languages, and low-level OS systems. Reading some text-books on "computer architecture" and/or "operating systems" may be useful to you.
NightCreature83
NightCreature83
If you want to learn assmebler have a look at this series of post on altdevblogaday: http://www.altdevblo...e-conditionals/ . Having said that assembler is an advanced topic for coding and most programmers know only the basiscs of assembler (thats including me), which means they can read it but not write it. The only time I actually look at assembler is when I get a crash bug that only happens in a release build of our game.

PS:
Its a good habit to write your for in the following manner:

for (int counter; <condition>; ++counter)
{
}

In this case it isn't really an optimisation just a habit so that when the ++operator is overloaded and does more work than you expect your not making an unessecary assignment. This is mostly the case when you have a custom assignment operater that makes a non-shallow copy.
brx
brx

PS:
Its a good habit to write your for in the following manner:

for (int counter; <condition>; ++counter)
{
}


It could be considered nitpicking (since it was not what you aimed at), but I have to say that I would not consider this for-declaration "good habit" as it is using the uninitialized variable counter... Just saying ;)
_MichaelSuess
_MichaelSuess

so does anyone know where i could learn about how assembler works? i dont want to learn to code in it just understand the principles of how it does things.


If you want to get a good understanding of assembly, and computer architecture, (how hardware plays nice with each other) I suggest that you download some of the microcontroller documents - I develop on the Microchip (http://www.microchip.com/) PIC lines, and they have a very simple to understand language as they are not CPUs, but MCUs and therefore don't have all the shift registers, and alike that can cause the novice to dropout from learning the language due to confusion. Read about how to connect peripheral devices (as that is everything not embedded in the CPU/MCU - including memory are really peripheral devices.) - I know that the Microchip's documentation on each chip is very well written and comprehensive - and best of all free. There are other MCU manufactures out there - I just like the PICs.
Michael Suess
MES Enterprises, LLC
http://mesenterprisesllc.com
NightCreature83
NightCreature83

It could be considered nitpicking (since it was not what you aimed at), but I have to say that I would not consider this for-declaration "good habit" as it is using the uninitialized variable counter... Just saying ;)


Yeah my bad I should have initialised counter, it was more the incrementer pattern I was on about :$.
alcedine
alcedine
Stanford University has put three of their courses on programming on youtube, open to watch. There's one on java, another or C++, and a third one that broadly talks some generics and paradigms, but in the first lectures, also pops the hood and looks around what actually happens when you use std::vector (for example). Depending on how much you already know, particularly about pointers and dynamic memory use, you'll want the second or the third one. This is where they begin.

[media]
[/media] [media]
[/media]

By the way, I know you asked about assembly, but from what I could gather about your intentions, I'd say you'll do better with one of these courses. Paradigms touches on assembly a bit, but you're probably more concerned with getting a feeling for the mechanics of C++.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.