I've disassembled an old DOS program into assembly and I'm trying to figure out a function call. Here is the ASM:
seg000:373C ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
seg000:373C
seg000:373C
seg000:373C sub_373C proc far ; CODE XREF: sub_72C6+16BP
seg000:373C ; sub_72C6+18FP ...
seg000:373C push si ; Temp. store si on stack so we can restore it later
seg000:373D xchg ax, si
seg000:373E xchg ax, dx
seg000:373F test ax, ax
seg000:3741 jz short loc_3745
seg000:3743 mul bx ; Multiply b by a IIF a is non-zero
seg000:3745
seg000:3745 loc_3745: ; CODE XREF: sub_373C+5j
seg000:3745 jcxz short loc_374C
seg000:3747 xchg ax, cx
seg000:3748 mul si
seg000:374A add ax, cx
seg000:374C
seg000:374C loc_374C: ; CODE XREF: sub_373C:loc_3745j
seg000:374C xchg ax, si
seg000:374D mul bx
seg000:374F add dx, si
seg000:3751 pop si ; Restore old si
seg000:3752 retf
seg000:3752 sub_373C endp
Frankly it just seems to be jumbling the registers around to me. My best guess is that it's some kind of primitive pseudo-random number generator. Can anyone confirm this or if not, tell me what it's actually meant to do?
EDIT:
I've tried dry-running the code, and as far as I can tell, the following is the end result of the registers (can anyone confirm I've got this right and tell me what useful mathematical function it might be doing?):
ax: ( ax * bx )
bx: bx
cx: cx
dx: ax + ( (bx * dx) + (ax * cx) )
si
is just used as a temporary storage throughout the code, it is not part of the input and its value is never used inside the function.