![]() |
Tutorial CYFA - Creating Your First Assembler - Data Processing Instructions - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Assembly (https://sinister.ly/Forum-Assembly) +--- Thread: Tutorial CYFA - Creating Your First Assembler - Data Processing Instructions (/Thread-Tutorial-CYFA-Creating-Your-First-Assembler-Data-Processing-Instructions) |
CYFA - Creating Your First Assembler - Data Processing Instructions - phyrrus9 - 10-12-2017 Again, it seems like my last iteration of this series got some good attention (Instruction Set Design), 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. ![]() 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: Code: 0000 - AND Code: ADD, SUB, AND, EOR, ORR, ADC, SBC, MOV, MVN 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: Code: I=0: PPPP S NNNN DDDD 22222222222 Code: <operation>{cond}{S} Rd, Rn, Operand2 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 Code: TST, TEQ, CMP, CMM Code: AND.S r0, r1, r2 ; same as TST R1, R2 Code: TEQ r0, #0x0 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: Code: ADD r0, r1, #0x00 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 Master List Page 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! RE: CYFA - Creating Your First Assembler - Data Processing Instructions - Blink - 10-14-2017 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. RE: CYFA - Creating Your First Assembler - Data Processing Instructions - phyrrus9 - 10-14-2017 (10-14-2017, 05:40 AM)Ender Wrote: That was nice, short, and to the point. A bit harder than the last one, but still alright. 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? RE: CYFA - Creating Your First Assembler - Data Processing Instructions - Blink - 10-14-2017 (10-14-2017, 06:38 AM)phyrrus9 Wrote:(10-14-2017, 05:40 AM)Ender Wrote: That was nice, short, and to the point. A bit harder than the last one, but still alright. I think that the pace was just a little faster, so it felt harder. RE: CYFA - Creating Your First Assembler - Data Processing Instructions - phyrrus9 - 10-15-2017 (10-14-2017, 10:42 PM)Ender Wrote:(10-14-2017, 06:38 AM)phyrrus9 Wrote:(10-14-2017, 05:40 AM)Ender Wrote: That was nice, short, and to the point. A bit harder than the last one, but still alright. 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. |