Skip to content

Instantly share code, notes, and snippets.

@antonijn
Created May 4, 2014 15:17
Show Gist options
  • Select an option

  • Save antonijn/e2550be6e9b20437b89d to your computer and use it in GitHub Desktop.

Select an option

Save antonijn/e2550be6e9b20437b89d to your computer and use it in GitHub Desktop.
_mul32
/*
* Multiplies two 32-bit numbers on 8086.
*/
long _stdcall _mul32(int highr, int lowr, int highl, int lowl)
{
asm {
; a = lowl * lowr
mov ax, [bp + 6] ; lowl
mul word [bp + 10] ; lowr
mov bx, ax ; lowa in bx
mov cx, dx ; higha in cx
; a +=
; (lowl * highr) << 16
mov ax, [bp + 6]
mul word [bp + 4]
add cx, dx
; a +=
; (highl * lowr) << 16
mov ax, [bp + 8]
mul word [bp + 6]
add cx, dx
mov ax, bx
mov dx, cx
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment