Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 499 Vote(s) - 3.54 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CYFA - Creating Your First Assembler - Data Processing Instructions

#1
Again, it seems like my last iteration of this series got some good attention (

[To see links please register here]

), so I'm going to try to hammer this one out today. I've come up with a plan I'm going to use for planning these. Once the latest part of the series gets 5 replies, I will start working on the next one. Hopefully we can keep this one alive and active until it's done.

Alright, as discussed in the last one, we will be discussing data processing instructions. These are the most common of the model we talked about (see graphic below), but this iteration will go quickly.
[Image: instr.gif]

Data processing instructions are used to manipulate data. That means doing basic math, moving data around in the CPU, and some boolean logic. We'll be focusing on just a few of the possible operational codes within this tutorial, but here is a list of all of them for your reference:

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.

For this tutorial series, we will probably just use the following:

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


Ok, so let's ignore the condition field for right now, we'll learn about those later. The instruction actually starts at bit 25. There are also 2 forms of this, bit 25 is called the Immediate bit, and it tells the CPU what to do with the Operand2 parameter:

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.

These instructions follow this format:

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.

Note: the rotate value isn't entered by the user. For the above example, the rotate would be 0xF, and the value would be 0x10. We need to calculate that at the time of assembly.



Ok, so let's talk about some of these bits:
The S bit
The S bit, aka the set condition codes bit, will be something new to you if you're an intel assembly programmer. In Intel, every instruction you execute effects the flags register, in ARM it's the other way around, the only instructions that set it by default are

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.

However, you can have them set on any data processing instruction. For example, the TST instruction is simply a shorthand for this:

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.

This format saves you some time. In a previous thread, we talked about a loop, which used a test, but we can rewrite that so that it doesn't execute the test all the time like this:

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.

This lets us write extremely dense code, and remember that each instruction takes up EXACTLY one clock cycle. This code will take a minimum of 4 cycles to execute, but each iteration of the loop will only take 3, rather than 7 like our intel example, or 4 like the original ARM.

The I bit
This looks like a binary 1 in the diagram, but it is not. This bit is actually relatively simple, it tells the CPU if the instruction has 3 registers, or 2 registers and a constant value (known at assemble time). This is probably the most useful bit in the entire instruction set. With intel instructions, any operation always overwrites one of the operands, which sucks if you're chaining math operations. With ARM, you get to pick where it goes (as long as I=0), which means that you can also do a MOV in the same cycle. MOV can actually be replaced by ADD instructions like so:

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.

NOTE: the least significant bit of the operational code also tells the CPU what to do with Operand2. If this bit is set (TST all the way to MVN), that part of the instruction is ignored. Those instructions can only take 2 parameters.
If the I flag is set, then 8 significant bits are copied in, and rotated by 3 bits. This means you only get a 12-bit immediate value, so you can't load integer 256 with 1 instruction!



Ok, well this one went by quicker than I thought, but I think I covered it pretty well. Let me know what you guys think. I'll be updating the

[To see links please register here]

with this thread. I've also added the titles of the next segments. The faster this thread starts a discussion is the faster those will get written.

PLEASE REPLY TO THIS THREAD, DISCUSSION IS KEY!
Reply

#2
That was nice, short, and to the point. A bit harder than the last one, but still alright.

I'm looking forward to the next post in the series.
Reply

#3
Quote:(10-14-2017, 05:40 AM)Ender Wrote:

[To see links please register here]

That was nice, short, and to the point. A bit harder than the last one, but still alright.

I'm looking forward to the next post in the series.

There's some hard concepts in this. Sadly I've got to teach this in a very restricted setting. What bits were harder in your opinion?
Reply

#4
Quote:(10-14-2017, 06:38 AM)phyrrus9 Wrote:

[To see links please register here]

Quote: (10-14-2017, 05:40 AM)Ender Wrote:

[To see links please register here]

That was nice, short, and to the point. A bit harder than the last one, but still alright.

I'm looking forward to the next post in the series.

There's some hard concepts in this. Sadly I've got to teach this in a very restricted setting. What bits were harder in your opinion?

I think that the pace was just a little faster, so it felt harder.
Reply

#5
Quote:(10-14-2017, 10:42 PM)Ender Wrote:

[To see links please register here]

Quote: (10-14-2017, 06:38 AM)phyrrus9 Wrote:

[To see links please register here]

Quote: (10-14-2017, 05:40 AM)Ender Wrote:

[To see links please register here]

That was nice, short, and to the point. A bit harder than the last one, but still alright.

I'm looking forward to the next post in the series.

There's some hard concepts in this. Sadly I've got to teach this in a very restricted setting. What bits were harder in your opinion?

I think that the pace was just a little faster, so it felt harder.

Fair enough. The next ones will be a little slower, this one had a lot of info to cover because of the opcodes. In the others we won't have that and we can focus more at the electron level.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through