We're looking for your comments on how to best organize the wiki's content.

SHR

From 0x10c Wiki
Jump to: navigation, search

SHR (Shift Right) is one of the opcodes in the DCPU-16 specification. It represents a bitwise right shift.

Contents

[edit] Usage

 SHR arg1, arg2

SHR shifts arg1 arg2 bits to the right. The bits that were shifted out are stored in the EX register.

SHR is commonly used to quickly divide numbers by powers of two, since DIV and DVI cost three clock cycles versus SHR's cost of one cycle.

[edit] Signing awareness

SHR is only designed to work with unsigned numbers. For signed numbers, use ASR.

[edit] EX register usage

The bits shifted out are stored in the EX register.

[edit] Processing

In binary machine code, this Basic opcode's five-bit representation is: 0b0 1101 (0x0d)

The instruction has a takes one cycle to execute, plus any additional cycles necessary to evaluate the arguments.

[edit] References

Personal tools
Namespaces
Variants
Actions
Navigation
Community
Toolbox