CS计算机代考程序代写 assembly AVR® Assembly Language Summary1 (J. Vasconcelos, 2008)

AVR® Assembly Language Summary1 (J. Vasconcelos, 2008)
Category
Instruction
Add
Subtract
Negate (2’s complement) Clear register
Set register
Increment register Decrement register
Test zero or negative Multiply
Set individual bits
Clear individual bits
Shift bits to the left
Shift bits to the right
And
Or
Xor (exclusive or)
Flip bits (1’s complement)
Compare two registers
Load immediate Copy register
Send data to I/O port Get data from I/O port
Load register from memory
Store register in memory
Save register in stack Load register from stack Skip if bit set
Skip if bit cleared
Skip if registers are equal Branch on equal
Branch on not equal
Branch on greater than (signed) Branch on lesser than (signed) Jump
Absolute jump Procedure call
Return from subroutine Reset watchdog timer No operation
Example
add R5, R6 sub R5, R6 neg R5
clr R5
ser R5
inc R5
dec R5
tst R5
mul R5, R6 sbr R16, 65 cbr R16, 65 lsl R5
lsr R5
and R5, R6 or R5, R6 eor R6, R5 com R5
cp R5, R6
ldi R16, 0xF0
mov R19, R20 out PortB, R16 in R17, PinB ldR5,X
ld R5, X+ stX,R5
st X+, R5 push R5
pop R5
sbrs R17, 6 sbrc R17,6 cpse R16,R17 breq LABEL brne LABEL brge LABEL brlt LABEL rjmp LABEL jmp LABEL rcall PROC ret
wdr nop
Meaning
R5=R5+R6 R5=R5–R6 R5=0–R5
R5=0
R5=$FF
R5=R5+1
R5=R5–1
If Rd <= 0, SREG[N,Z] = 1 R1,R0=R5xR6 Comments Arithmetic Bitwise Logical Data transfer Conditional branch Non- conditional jump Misc. R16[6] =1, R16[0] R16[6] =0, R16[0] R5=R5x2 R5=R5/2 R5=R5ANDR6 R5=R5ORR6 R5=R5XORR6 R5=$FF–R5 =1 =0 R5=1+(~R5) Result is 16-bit long R16= R16 OR $41 R16 = R16 AND ~R5 R5[7]=R5[6] ... R5[0]=0 R5[7]=0 ... R5[0]=R5[1] R5=~R5 Performs (R5-R6) to update SREGS X is 16-bit register R5 is a 8-bit register X is 16-bit register R5 is a 8-bit register SP=SP–1 SP=SP+1 Registers have to be compared right before the branch: cp regA, regB Jump relative to PC Jump to specific instruction location. Ret.Addr. saved in STACK Ret.Addr.retrieved STACK If R5=R6, SREG[Z] =1 else SREG[Z]=0 R16 = $F0 R19 = R20 I/O(PortB) = R16 R17 = I/O(PinB) R5 = mem[X] R5 = mem[X], X= X+1 mem[X] = R5 mem[X] = R5, X+1 STACK[top] = R5 R5 = STACK[top] Skip next instruction if R17[6] = 1 Skip next instruction if R17[6] = 0 Skip next instruction if R16=R17 if regA=RegB, goto LABEL if regA<>RegB, goto LABEL
if regA>RegB, goto LABEL
if regA