⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 7-3.asm

📁 data array sdword 2 dup(?) str1 byte "Please input one 32-bit sign number :",0dh,0ah,0 str2 by
💻 ASM
字号:
TITLE 7-3
include allyssa32.inc
.data
   array sdword 2 dup(?) 
   string byte "The result is :",0 
   align 4
   jia1gao sdword 0
   jia1 sdword 0
.code
main proc
    mov eax,10
    mov esi,offset array
    mov [esi],eax
    mov dword ptr [esi+4],21
    mov edx,offset string 
    call writestring 
    call mul32
    mov edx,[esi+4]
    mov eax,[esi]
    mov jia1gao,edx
    mov jia1,eax
    mov esi,offset jia1gao
    mov ebx,4
    mov ecx,2
    call dumpmem
    
exit
main endp
mul32 proc
;-------------------
;receives :the offset address of array(store two 32-bit numbers)
;returns :[esi] store low 32-bit,[esi+4] store high 32bit 
;-------------------
     mov ecx,31
     mov eax,[esi]
     cdq
     mov ebx,[esi+4]
     mov dword ptr [esi],0
     mov dword ptr [esi+4],0
     ;call dumpregs
;--------------------
;change the sign of [esi] and [esi+4]
     add eax,0
     jns sign
     add ebx,0
     jns shift
     jmp neg1
sign:
     add ebx,0
     jns shift
     js neg1
neg1:
     neg eax
     neg edx
     sub edx,1h
     neg ebx
;--------------------
;shift and make the result
shift:
     cmp ecx,0
     je quit
     add ebx,0 
     jns next
     push ecx
     push eax
     push edx
cl1:
     shl eax,1
     rcl edx,1
     ;call dumpregs
loop cl1
     ;call dumpregs
     add [esi],eax
     adc [esi+4],edx
     pop edx
     pop eax
     pop ecx
next: 
     shl ebx,1
     dec ecx
     ;call dumpregs 
     jmp shift 
quit:
     add ebx,0
     jns bujia  
     add [esi],eax
     adc [esi+4],edx
bujia:
     ret
mul32 endp

end main

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -