简体   繁体   中英

Hello what does this code: $02 mean in assembly language

Hello I am having a problem to understand a code. it is the following:

ldi R17, $02
out PORTD, R17

I don't know what $02 means. Can you please help me? Thank you in advance

The LDI opcode is Load Immediate this places the number 2 into register R17. The following line then copies that value from R17 into the register PORTD (the actual address of that register is dependent on the exact Atmel chip that you are running is is defined in the header file). These two lines would be generated from a line of c code like PORTD=2;

The reason it takes two lines is because the port registers are higher in memory space and immediate values cannot be loaded directly into them. So, the the value is loaded into a register first, then copied to the desired final location.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM