最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 正文

用汇编实现浮点数相乘

来源:动视网 责编:小OO 时间:2025-10-01 09:52:58
文档

用汇编实现浮点数相乘

2:用任何一种汇编语言实现浮点相乘;答:注释:用IA-32汇编指令进行编写includeio32.inc.datamsg1byte'请输入第一个数字',13,10,0msg2byte'请输入第二个数字',13,10,0readbuf1byte256dup(0)readbuf2byte256dup(0)numbyte00h;记录负号个数.codestart:xorecx,ecxxorebx,ebxmoveax,offsetmsg1calldispmsgmoveax,offsetreadbuf1;
推荐度:
导读2:用任何一种汇编语言实现浮点相乘;答:注释:用IA-32汇编指令进行编写includeio32.inc.datamsg1byte'请输入第一个数字',13,10,0msg2byte'请输入第二个数字',13,10,0readbuf1byte256dup(0)readbuf2byte256dup(0)numbyte00h;记录负号个数.codestart:xorecx,ecxxorebx,ebxmoveax,offsetmsg1calldispmsgmoveax,offsetreadbuf1;
2:用任何一种汇编语言实现浮点相乘;

答:注释:用IA-32汇编指令进行编写

include io32.inc

    .data

    msg1     byte '请输入第一个数字',13,10,0

    msg2     byte '请输入第二个数字',13,10,0 

    readbuf1  byte 256 dup(0)

    readbuf2  byte 256 dup(0)

    num      byte  00h                 ;记录负号个数 

     .code

start:

    xor      ecx,ecx

    xor      ebx,ebx

    mov     eax,offset msg1

    call     dispmsg

    mov     eax,offset readbuf1     ;设置入口参数eax

    call     readmsg                 ;调用输入字符串子程序

    mov     edx,eax                 ;edx记录字符位数

    push     edx                     ;字符位数压入堆栈保护--------压入堆栈

    mov      esi,offset readbuf1     ;esi指向readbuf1

    cmp      byte ptr [esi],'-'

    jz        again3

again1:

    cmp      byte ptr [esi],'.'

    jnz       again2

    push      ecx                     ;堆栈 ecx

    inc       esi

    dec       edx

again2: 

    inc       ecx             ;read2循环 , 字符为数字时

    mov      al,[esi]

    sub       al,30h

    imul      ebx,10

    movzx    eax,al

    add       ebx,eax

    dec       edx

    inc       esi

    cmp      edx,00H

    jnz        again1

    jmp      done1

again3:                               ;read1   记录负号数num

    inc      esi

    inc      num

    dec      edx

    jmp      again1

done1:                              ;done   保护ebx,小数化成的整数,ecx小数位数-----------压入堆栈

    push     ebx

    pop      ebx                    

    pop      ecx

    pop      edx

    sub      edx,ecx

    dec      edx

    push     ebx

    push     edx

;------------------------------------------------------------------

    xor      ecx,ecx

    xor      ebx,ebx

    mov     eax,offset msg2

    call     dispmsg

    mov      eax,offset readbuf2     ;设置入口参数eax

    call       readmsg                 ;调用输入字符串子程序

    mov      edx,eax                 ;edx记录字符位数

    push     edx                     ;字符位数压入堆栈保护--------压入堆栈

    mov      esi,offset readbuf2    ;esi指向readbuf1

    cmp      byte ptr [esi],'-'

    jz        again6

again4:

    cmp      byte ptr [esi],'.'

    jnz       again5

    push      ecx                     ;堆栈 ecx

    inc       esi

    dec       edx

again5: 

    inc      ecx                  ;read2循环  字符为数字时

    mov     al,[esi]

    sub      al,30h

    imul     ebx,10

    movzx   eax,al

    add      ebx,eax

    dec      edx

    inc      esi

    cmp     edx,00H

    jnz      again4

    jmp     done2

again6:                               ;read1   记录负号数num

    inc      esi

    inc      num

    dec      edx

    jmp      again4

done2:    ;done  保护ebx,小数化成的整数,ecx小数位数压入堆栈

    push     ebx

    pop      ebx          ;ebx存入换算后的数据二整数            

    pop      ecx

    pop      edx                     

    sub      edx,ecx

    dec      edx                     ;edx存入数据二小数位数

    pop      ecx                     ;数据一的小数位数

    pop      eax                      ;数据一的整数

    

    add      ecx,edx

    imul     eax,ebx

    mov      ebx,1

done3:

    imul     ebx,10

    dec      ecx

    cmp     ecx,0

    jnz      done3

    mov     edx,0

    div      ebx

    call      dispuid

    mov     eax,'.'

    call      dispc

    mov     eax,edx

    call      dispuid

    exit 0

end start  

文档

用汇编实现浮点数相乘

2:用任何一种汇编语言实现浮点相乘;答:注释:用IA-32汇编指令进行编写includeio32.inc.datamsg1byte'请输入第一个数字',13,10,0msg2byte'请输入第二个数字',13,10,0readbuf1byte256dup(0)readbuf2byte256dup(0)numbyte00h;记录负号个数.codestart:xorecx,ecxxorebx,ebxmoveax,offsetmsg1calldispmsgmoveax,offsetreadbuf1;
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top