Difference between revisions of "SARC"

From Intellivision Wiki
Jump to: navigation, search
 
m (Protected "SARC" ([edit=autoconfirmed] (indefinite) [move=autoconfirmed] (indefinite)))
 
(3 intermediate revisions by 3 users not shown)
Line 9: Line 9:
 
<tr><td>Output Flags</td><td>[[Sign Flag]], [[Zero Flag]], [[Overflow Flag]], [[Carry Flag]]</td></tr>
 
<tr><td>Output Flags</td><td>[[Sign Flag]], [[Zero Flag]], [[Overflow Flag]], [[Carry Flag]]</td></tr>
 
</table><br/>
 
</table><br/>
The Shift Arithmetic Right Through Carry (SARC) instruction shifts the bits in the specified register either one (1) or two (2) bits to the right, stores the result back to the specified register, and sets or clears the [[Sign Flag]] and [[Zero Flag]] according to the new value in the register.  The rightmost one or two bits are discarded.  Unlike the [[Shift Logical Right]] instruction, however, the SLR instruction does not set the leftmost one or two bits to zero.  Instead the value of bit 15 (the sign bit) stays the same value as the value of bit 15 before the shift occurred.  For a double shift, bit 15 is also copied to bit 14.  The number of clock cycles used depends on the number of shifts specified.  One shift will use 6 clock cycles and two shifts will use 8 clock cycles. The opcode format is as follows.<br/>
+
The Shift Arithmetic Right Through Carry (SARC) instruction shifts the bits in the specified register either one (1) or two (2) bits to the right, stores the result back to the specified register, and sets or clears the [[Sign Flag]] and [[Zero Flag]] according to the new value in the register.  For either a single or double shift, the [[Carry Flag]] is set to the value of bit 0 before the shift occurred.  For a double shift, the [[Overflow Flag]] is also set to the value of bit 1 before the shift occurred.  Unlike the [[SLR|Shift Logical Right]] instruction, however, the SARC instruction does not set the leftmost one or two bits to zero.  Instead the value of bit 15 (the sign bit) stays the same value as the value of bit 15 before the shift occurred.  For a double shift, bit 15 is also copied to bit 14.  The number of clock cycles used depends on the number of shifts specified.  One shift will use 6 clock cycles and two shifts will use 8 clock cycles.<BR/><BR/>
 +
 
 +
[[Image:Sarc_diagram.png]]
 +
 
 +
 
 +
The opcode format is as follows.<br/><br/>
  
 
     0000:0000:0111:1srr<br/>
 
     0000:0000:0111:1srr<br/>

Latest revision as of 09:11, 4 December 2010

Instruction NameShift Arithmetic Right Through Carry
MnemonicSARC
CP1610 Clock Cycles6 or 8
InterruptibleNo
Opcode Range$0078-$007F
Input FlagsNone
Output FlagsSign Flag, Zero Flag, Overflow Flag, Carry Flag

The Shift Arithmetic Right Through Carry (SARC) instruction shifts the bits in the specified register either one (1) or two (2) bits to the right, stores the result back to the specified register, and sets or clears the Sign Flag and Zero Flag according to the new value in the register. For either a single or double shift, the Carry Flag is set to the value of bit 0 before the shift occurred. For a double shift, the Overflow Flag is also set to the value of bit 1 before the shift occurred. Unlike the Shift Logical Right instruction, however, the SARC instruction does not set the leftmost one or two bits to zero. Instead the value of bit 15 (the sign bit) stays the same value as the value of bit 15 before the shift occurred. For a double shift, bit 15 is also copied to bit 14. The number of clock cycles used depends on the number of shifts specified. One shift will use 6 clock cycles and two shifts will use 8 clock cycles.

Sarc diagram.png


The opcode format is as follows.

   0000:0000:0111:1srr
where: s indicates the number of places to shift such that: s == 0 indicates to shift once s == 1 indicates to shift twice
rr indicates the target register such that: rrr == 000 indicates register R0 rrr == 001 indicates register R1 rrr == 010 indicates register R2 rrr == 011 indicates register R3