Xilinx UG129 manual No Operation NOP, 18Loading a Register with Itself Acts as a NOP Instruction

Models: UG129

1 124
Download 124 pages 29.5 Kb
Page 31
Image 31

Processing Data

R

;Divide Routine (8-bit / 8-bit = 8-bit result, remainder)

;==================================================

;Shift and subtract algorithm

;

 

 

 

 

 

 

 

 

div_8by8:

 

 

 

 

NAMEREG s0, dividend

;

preserved

NAMEREG s1, divisor

;

preserved

NAMEREG s2, quotient

;

preserved

NAMEREG s3, remainder

;

modified

NAMEREG s4, bit_mask

;

used to test bits in dividend,

 

 

 

 

 

 

;

one-hot encoded, modified

;

 

 

 

 

 

 

 

 

LOAD remainder, 00

;

clear remainder

LOAD bit_mask, 80

;

start with most-significant bit (msb)

div_loop:

 

 

 

 

TEST dividend, bit_mask

;

test bit, set CARRY if bit is '1'

SLA remainder

 

;

shift CARRY into lsb of remainder

SL0 quotient

 

;

shift quotient left (multiply by 2)

;

 

 

 

 

 

 

 

 

COMPARE remainder, divisor ;

is remainder > divisor?

JUMP C, no_sub

 

; if divisor is greater, continue to next bit

SUB remainder, divisor

;

if remainder > divisor, then subtract

ADD quotient, 01

;

add one to quotient

no_sub:

 

 

 

 

SR0 bit_mask

 

;

shift to examine next bit position

JUMP NZ, div_loop

;

if bit_mask=0, then all bits examined

 

 

 

 

 

 

;

otherwise, examine next bit

RETURN

 

 

 

 

 

 

 

 

 

 

 

Figure 3-17:8-bit Divided by 8-bit Routine

 

 

 

 

 

 

 

 

 

 

 

 

If reading this document in Adobe Acrobat,

 

 

 

 

T

 

 

 

 

 

 

 

use the Select Text tool to select code snippets,

 

 

 

 

 

 

 

 

 

 

 

 

then copy and paste the text into your text editor.

 

 

 

 

 

 

 

 

 

 

No Operation (NOP)

The PicoBlaze instruction set does not have a specific NOP instruction. Typically, a NOP instruction is completely benign, does not affect register contents or flags, and performs no operation other than requiring an instruction cycle to execute. A NOP instruction is therefore sometimes useful to balance code trees for more predictable execution timing.

There are a few possible implementations of an equivalent NOP operation, as shown in Figure 3-18and Figure 3-19. Loading a register with itself does not affect the register value or the status flags.

nop:

LOAD sX, sX

Figure 3-18:Loading a Register with Itself Acts as a NOP Instruction

PicoBlaze 8-bit Embedded Microcontroller

www.xilinx.com

31

UG129 (v1.1.2) June 24, 2008

Page 31
Image 31
Xilinx UG129 manual No Operation NOP, 18Loading a Register with Itself Acts as a NOP Instruction