//函数:计算除以90
// 输入放在r3:r2中,输出放在r2
;90 * 182 = 16380 ~ 16384 = 2^14
FUNC_DIVIDE:
push r0
push r1
push r5
push r16
// 输入放在r3:r2中,输出放在r2
;90 * 182 = 16380 ~ 16384 = 2^14
FUNC_DIVIDE:
push r0
push r1
push r5
push r16
ldi r16,182
mul r2,r16 //低字节乘以182
mov r5,r1 //把结果的高字节存到r5,低字节放弃,即相当于右移了8位
mul r2,r16 //低字节乘以182
mov r5,r1 //把结果的高字节存到r5,低字节放弃,即相当于右移了8位
mul r3,r16 //高字节乘以182
add r0,r5
clr r5
adc r1,r5
add r0,r5
clr r5
adc r1,r5
//再右移6位,共右移14位
swap r0
lsr r0
lsr r0
ldi r16,0b00000011
and r0,r16
swap r0
lsr r0
lsr r0
ldi r16,0b00000011
and r0,r16
lsl r1
lsl r1
or r1,r0
lsl r1
or r1,r0
//保存结果
mov r2,r1
mov r2,r1
pop r16
pop r5
pop r1
pop r0
pop r5
pop r1
pop r0
ret