Monday, 15 June 2015

assembly language, strange loop -



assembly language, strange loop -

i'm struggling understand code does

ldi r20, 80 loop: asr r20 brsh loop nop

what code doing , how many clock cycles code take execute?

this seems atmel avr assembly code. in loop continues until carry bit of status register set, shifts hexadecimal 80 arithmetically right 1 position r20 takes successive values of 80, c0, e0, f0, f8, fc, fe, ff. until now, low bit has been 0, , value has been shifted carry bit of status register. on next shift, low bit of ff shifted, 1. causes loop exit.

see http://www.atmel.com/webdoc/avrassembler/avrassembler.wb_asr.html on asr instruction.

the net effect cause little delay.

assembly

No comments:

Post a Comment