Reputation: 3
I am currently trying figure out one instructions given each clock cycle using an ARM processor. I have been introduced to these concepts twice now and have yet to find anyone who teaches it properly. Currently I am trying to figure out the instructions:
1). LSR R0, R1, #2; 2). cmp R5, R6;
and I need to determine the machine code and then schedule the above instructions on the one bus machine.
Any help is appreciated!
Upvotes: 0
Views: 254
Reputation: 75
The ARM Architecture Reference Manual specifies the machine code for instructions. Page A7-68 describes the format for an LSR instruction with an immediate input.
//I can't post an image because of low reputation
Bit - 15 14 13 12 11 | 10 6 | 5 3 | 2 0
Val - 0 0 0 0 1 | immed_5 | Rm | Rd
Syntax
LSR <Rd>, <Rm>, #<immed_5>
where:
<Rd> Is the destination register for the operation.
<Rm> Is the register containing the value to be shifted.
<immed_5> Specifies the shift amount, in the range 1 to 32.
Shifts by 1 to 31 are encoded directly in immed_5.
A shift by 32 is encoded as immed_5 == 0.
With your instruction, immed_5 = 00010, Rm = 001, and Rd = 000
So the binary instruction is: 00001 00010 001 000
or in hex: 0x0111
.
To goal of scheduling an instruction on a one bus machine is to specify which registers are putting data on the bus, which registers are reading data from the bus, and in what order this should occur. An important thing to remember is that only one value should be put on the bus at a time.
Here is an example scheduling using your first instruction. This uses X as an ALU input register, and Y as an ALU output register. This also assumes ALUsll will left shift the value on the bus by the value stored in X.
LSR R0,R1,#2
Get the instruction into the Instruction Register
Perform instruction specific operations
Advance the PC for the next instruction
You can use these same methods to determine the machine code translation and one-bus scheduling of any other ARM instruction.
Upvotes: 1