📄 quotient.asm
字号:
SECTION .data
dividend128 DD 0 ; bits 0-31
DD 0 ; bits 32-63
DD 0 ; bits 64-95
DD 0 ; bits 96-127
quotient128 DD 0 ; bits 0-31
DD 0 ; bits 32-63
DD 0 ; bits 64-95
DD 0 ; bits 96-127
SECTION .text
ALIGN 16
BITS 32
GLOBAL _Quotient
; Function prototype:
; UNSIGNED64 Quotient(UNSIGNED64 dividend64, UNSIGNED32 divisor32)
_Quotient: PUSH EBP
MOV EBP,ESP
SUB ESP,16 ; Allocate space for dividend128
SUB ESP,16 ; Allocate space for quotient128
%define divisor32 EBP+16 ; Use these identifiers to reference the
%define dividend64 EBP+8 ; function parameters, as in "[divisor32]".
%define dividend128 EBP-16 ; Use these identifiers to reference the
%define quotient128 EBP-32 ; extended dividend and 128-bit quotient
; We really only have a 64-bit dividend,
; so first extend it to a 128-bit version.
MOV EAX,[dividend64+0]
MOV [dividend128+0],EAX
MOV EAX,[dividend64+4]
MOV [dividend128+4],EAX
MOV DWORD [dividend128+8],0
MOV DWORD [dividend128+12],0
; Insert your code here for "quotient128 = dividend128 / divisor32"
; We only want to return bits 63-0 of the result...
MOV EAX,[quotient128+0]
MOV EDX,[quotient128+4]
; Restore stack pointer and old EBP and return...
MOV ESP,EBP
POP EBP
RET
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -