我有以下代码:
unsigned short wrLine;
unsigned short prev = ((wrLine - 1) % 16);
wrLine = (wrLine + 1) % 16;
这会生成以下反汇编:
unsigned short prev = ((wrLine - 1) % LINES_IN_FIFO);
0041456A movw r3, #25282
0041456E movt r3, #8192
00414572 ldrh r3, [r3]
00414574 uxth r3, r3
00414576 add.w r2, r3, #4294967295
0041457A mov.w r3, #15
0041457E movt r3, #32768
00414582 ands r3, r2
00414584 cmp r3, #0
00414586 bge #10
00414588 add.w r3, r3, #4294967295
0041458C orn r3, r3, #15
00414590 add.w r3, r3, #1
00414594 strh r3, [r7, #4]
wrLine = (wrLine + 1) % LINES_IN_FIFO;
0041463E movw r3, #25282
00414642 movt r3, #8192
00414646 ldrh r3, [r3]
00414648 uxth r3, r3
0041464A add.w r2, r3, #1
0041464E mov.w r3, #15
00414652 movt r3, #32768
00414656 ands r3, r2
00414658 cmp r3, #0
0041465A bge #10
0041465C add.w r3, r3, #4294967295
00414660 orn r3, r3, #15
00414664 add.w r3, r3, #1
00414668 uxth r2, r3
0041466A movw r3, #25282
0041466E movt r3, #8192
有趣的是,如果 wrLine 为零,则 prev 最终将等于 0xFFFF,而当 wrLine 为 15 时,它将最终等于 0x0000。知道为什么只有其中一个有效吗?
谢谢,德文