This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

汇编延时函数

;延时时间函数,每次延时22800个周期,对应50us//实际周期22836
;调用格式为Delay(x), x为需要的延迟,单位为50us

.asg B15, SP
.def _Delay

_Delay:

STW .D2 B1, *SP--(0x8) ;寄存器保护
STW .D2 B2, *+SP(0x4) ;寄存器保护
MV .L2 A4, B1 ;A4存放第一个参数

LOOP_DELAY:

[B1] SUB .L2 B1, 1, B1
MVK .S2 0x1C8, B2
LOOP1:
SUB .L2 B2, 1, B2
NOP 3
NOP 5
NOP 5
NOP 5
NOP 5
NOP 5
NOP 5
NOP 5
NOP 5
[B2] B .S2 LOOP1
NOP 4
[B1] B .S2 LOOP_DELAY
NOP 4

LDW .D2 *+SP(0x4), B2
LDW .D2 *++SP(0x8), B1

LOOP2: B .S2 B3
NOP 3

以上代码是我在别的工程里面复制过来的一个延时函数;但是我在实际运行过程中用仿真器调试发现LOOP1只循环了一次又调到LOOP_DELAY里面去了,直到B1的值为0以后才会把LOOP1整个循环完成,请问下各位,要怎么改才能使这个程序先把LOOP1循环完再跳出去B1减一,再循环LOOP1直至B1减到0。我用的是C6748芯片