code:lrem - ikarishinjieva/unixV6-code-analyze-chs GitHub Wiki

Source

  • 用于返回函数两参数相除的余数
  • 共2个参数:n,b
  • n:被除数,b:除数
  • 返回n/b的余数

1399 /* -------------------------*/

1400 .globl _lrem

  • 进入函数前状态如图:

1401 _lrem:

1402     clr r0

1403     mov 2(sp),r1

1404     div 4(sp),r0

1405     mov r1,r0

  • 清除R0寄存器的值
  • 将2(SP)的值传给R1
  • 用4(SP)的值除以由R0,R1组成的32位长的数,并将余数传递给R1
  • 将R1赋值给R0,使余数作为函数的返回值返回

1406     rts pc

1407

Ref

Caller

⚠️ **GitHub.com Fallback** ⚠️