Last change
on this file since 173 was 172, checked in by aitotat@…, 13 years ago |
Changes to Assembly Library:
- Added 32/16bit and 64/16bit division functions.
|
File size:
1.3 KB
|
Rev | Line | |
---|
[172] | 1 | ; Project name : Assembly Library
|
---|
| 2 | ; Description : Functions for register operations.
|
---|
| 3 |
|
---|
| 4 |
|
---|
| 5 | ; Section containing code
|
---|
| 6 | SECTION .text
|
---|
| 7 |
|
---|
| 8 | ;--------------------------------------------------------------------
|
---|
| 9 | ; Math_DivQWatSSBPbyCX
|
---|
| 10 | ; Parameters:
|
---|
| 11 | ; [SS:BP]: 64-bit unsigned divident
|
---|
| 12 | ; CX: 16-bit unsigned divisor
|
---|
| 13 | ; Returns:
|
---|
| 14 | ; [SS:BP]: 64-bit unsigned quotient
|
---|
| 15 | ; DX: 16-bit unsigned remainder
|
---|
| 16 | ; Corrupts registers:
|
---|
| 17 | ; AX
|
---|
| 18 | ;--------------------------------------------------------------------
|
---|
| 19 | ALIGN JUMP_ALIGN
|
---|
| 20 | Math_DivQWatSSBPbyCX:
|
---|
| 21 | xor dx, dx
|
---|
| 22 | mov ax, [bp+6] ; Load highest divident WORD to DX:AX
|
---|
| 23 | div cx
|
---|
| 24 | mov [bp+6], ax ; Store quotient
|
---|
| 25 |
|
---|
| 26 | mov ax, [bp+4]
|
---|
| 27 | div cx
|
---|
| 28 | mov [bp+4], ax
|
---|
| 29 |
|
---|
| 30 | mov ax, [bp+2]
|
---|
| 31 | div cx
|
---|
| 32 | mov [bp+2], ax
|
---|
| 33 |
|
---|
| 34 | mov ax, [bp]
|
---|
| 35 | div cx
|
---|
| 36 | mov [bp], ax
|
---|
| 37 | ret
|
---|
| 38 |
|
---|
| 39 |
|
---|
| 40 | ;--------------------------------------------------------------------
|
---|
| 41 | ; Math_DivDXAXbyCX
|
---|
| 42 | ; Parameters:
|
---|
| 43 | ; DX:AX: 32-bit unsigned divident
|
---|
| 44 | ; CX: 16-bit unsigned divisor
|
---|
| 45 | ; Returns:
|
---|
| 46 | ; DX:AX: 32-bit unsigned quotient
|
---|
| 47 | ; BX: 16-bit unsigned remainder
|
---|
| 48 | ; Corrupts registers:
|
---|
| 49 | ; Nothing
|
---|
| 50 | ;--------------------------------------------------------------------
|
---|
| 51 | ALIGN JUMP_ALIGN
|
---|
| 52 | Math_DivDXAXbyCX:
|
---|
| 53 | mov bx, ax
|
---|
| 54 | mov ax, dx
|
---|
| 55 | xor dx, dx
|
---|
| 56 | div cx
|
---|
| 57 | xchg ax, bx
|
---|
| 58 | div cx
|
---|
| 59 | xchg dx, bx
|
---|
| 60 | ret
|
---|
Note:
See
TracBrowser
for help on using the repository browser.