i need a help to understand Assembly code......anyone who could help me dude..........?

sort by: active | newest | oldest
lemonie7 years ago
Which assembly code?

+1, though the techniques are all fairly similar. And hard.
Oh yes, I looked at Z80, but decided I wasn't that interested: my sum total assembly experience.

Get your head round another language, and Assembly starts to make more sense, but you have to think more literally.

Assembler is a very specialised tool, for hand optimising routines that need to run VERY efficiently. In most applications, you'd write the bulk of your code in a high level language, but routines that tie things up, or are executed a lot of times can (should ???)  be hand optimised.

There are almost as many flavours of assembler as there are processor families, and there are family resemblances too. Motorola code looks different to Intel looks different to ARM, but Atmel AVR looks a bit like Intel, because there are family resemblances.

Its interesting that sometimes you can write a really  short piece of  code and it takes longer to execute than a long example !

Here for example is a piece in Basic

For X:=0 to 10

In assembler than would be something like
MOV B,#0     ; Start by making B = 0
MOV X,#10   ;Make X = 10
Loop:   MOV A,X  ; The A register is the "scratchpad" in assembler.
ADD A,B       : Add the A and B together
XCH B          ; Put the result back in the B register
DJNE X,loop ; If X isn't zero, knock one of it and jump back to loop:

....which looks longer, but will probably execute in a fraction of the time of the BASIC example. In my particular flavour of assembler there, this would take 50 clock cycles to execute. There are some changes in there that I can see immediately whcih would knock it down to 35  or less.

Assembly almost always looks similar to this. An instruction Mnemonic like "MOV" for MOVE or "DJNE" for "Decrement, Jump if Not Equal", is followed by one or more arguments, you'll see here that there are some instructions that take one argument (XCH) and some that take 2 (MOV)

You'll also see the indentation. This is critical, because assemblers are VERY fussy about layout  - the first 6 columns here are reserved for LABELS. A label is used to mark a block of code in a human readable way.

Here MOV is an instruction to MOVe something,  the contents of a REGISTER ( a memory location inside the processor) or a literal number, from one place to another.

XCH swaps the accumulator (A) with a register.

ADD adds the accumulator and something else - like a register.

DJNE is a nice little thing. Take the first argument X here, take one off it, if the result isn't zero go back to where the second argument sends you.


I really like this sort of super-mechanical-logical thing, and I see the BASIC interpreter hiding behind the coal-shed... But it's not something I've got enough need to learn.
I get the move, register, stack, flag etc, but have never developed enough that it forms into something I can see a a whole doing "PRINT "Hi".
Two "assemble" questions in one day...

Snowy over there?

Snow ? 
Oh yea, about 6" so far - noone in work apart from me and Liz.

This video kind of shows the difference between BASIC and Assembler....

That's pretty cool, oh yes. But I think it out of place, there's a sequential / parallel thing going on there which doesn't fit my picture of how processors are controlled by software. That is referencing CPU/GPU, which is a chip-architecture thing, but on speed-wise I get it totally.


Heavy-snow, got let out at 4, who knows tomorrow.
Yes, but who cares ? AIn't it COOL ! The Speed was the thing.
Yeah, it's definatly not for the beginner.  The heaviest, thickest book I had in college was my 68K Assembly book.  If you're not already very competent in at least one compuer language I wouldn't even begin to approach assembly.

While the techniques are all pretty similar it is pretty important to know what processor you're assembling for.  For a while I was working on both 68K and 8088 processors and they were completely different to work with.  As I remember 68K was big-endian and 8088 was little-endian, and register handling was entirely different.

(Obviously my information is quite dated, both of those processors originated in the 80's)
nfarrow7 years ago
I think you would have a easier time with software that you reverse engineer the code.

nfarrow nfarrow7 years ago

FYI:  You can use Reverse Engineering software on compiled java AKA “Class file” and re-compile it back to java. To view a more manageable code AKA “non machine code”

There is no way to be Neo!

frollard7 years ago
Machine code is the ones and zeros that computer cores run to execute commands and do...everything.  It is the lowest level of coding possible, and near impossible for humans to comprehend (per todays complexity).

Assembly is machine code assembled into a more human readable format - but still very low level and very 'physical' regarding how instructions are formatted.

By comparison - other programming languages, C, VB, Pascal, Basic, etc - are higher level and require compiling into machine code by a compiler.

Specific code - you have to tell us!