Difference between revisions of "Shift left"
From Unofficial QEdit Wiki Guide
Line 14: | Line 14: | ||
<span style='color:green'> let </span>R2, R1 <span style='color:orange'>//This will be used for 7bit value</span> | <span style='color:green'> let </span>R2, R1 <span style='color:orange'>//This will be used for 7bit value</span> | ||
<span style='color:green'> leti </span>R5, 00000002 <span style='color:orange'>//This will be used to store the shift amount</span> | <span style='color:green'> leti </span>R5, 00000002 <span style='color:orange'>//This will be used to store the shift amount</span> | ||
− | <span style='color:green'> andi </span>R2, 000001FC<span style='color:orange'>//Perform bitwise AND operation on R2 using 111111100 binary</span> | + | <span style='color:green'> andi </span>R2, 000001FC<span style='color:orange'>//Perform bitwise AND operation on R2 using 111111100 binary. R2 now equals 110010000</span> |
<span style='color:green'> shift_right </span>R2, R5 <span style='color:orange'>//Perform bitwise shift right on R2. Value changed from 400 (110010000) to 100 (1100100)</span> | <span style='color:green'> shift_right </span>R2, R5 <span style='color:orange'>//Perform bitwise shift right on R2. Value changed from 400 (110010000) to 100 (1100100)</span> | ||
<span style='color:green'> let </span>R3, R1 <span style='color:orange'>//This will be used to store the first flag</span> | <span style='color:green'> let </span>R3, R1 <span style='color:orange'>//This will be used to store the first flag</span> |
Revision as of 16:17, 4 May 2011
Contents
Syntax
Syntax: shift_left register1, register2
- register1 = Register to shift left
- register2 = Shift left by value of register2
Use
Used to execute a logical bitwise operation shift left. Use shift_right to shift right. In the example below we'll use R1 to store a 7Bit value 100 decimal (127 decimal value maximum) and 2 seperate flags.
Example
100: leti R1, 00000193 //Set R1 to 403 (110010011 in binary)
let R2, R1 //This will be used for 7bit value
leti R5, 00000002 //This will be used to store the shift amount
andi R2, 000001FC//Perform bitwise AND operation on R2 using 111111100 binary. R2 now equals 110010000
shift_right R2, R5 //Perform bitwise shift right on R2. Value changed from 400 (110010000) to 100 (1100100)
let R3, R1 //This will be used to store the first flag
let R4, R1 //This will be used to store the second flag
ret
Also see
List of OP Codes used in example.