3708 views|4 replies

1

Posts

0

Resources
The OP

Help: A 8086 program, looking for expert guidance [Copy link]

A 8086 program performs multiplication of two 32-bit numbers. I am confused because I have just started learning it. The program is as follows: data segment mulnum dw 0000,0fffh,0000,offfh,4dup(?) data ends stack segment para stack 'stack' db 100dup(?) stack ends code segment assume cs:code,ds:data,ss:stack,es:data start porc far begin push ds mov ax ,0 push ax mov ax,data mov ds,ax mov es,ax lea bx,mulnum mulu32: mov ax,[bx] mov si,[bx+4] mov di,[bx+6] mul si mov [bx+8],ax mov [bx+0ah],dx mov ax,[bx+2] mul si add ax,[bx+0ah] adc dx,0 mov [bx+0ah],ax mov [bx+0ch],dx mov ax,[bx] mul di add ax,[bx+0ah] adc dx,[bx+0ch] mov [bx+0ah],ax mov [bx+0ch],dx pushf mov ax,[bx+2] mul di popf adc ax,[bx+0ch] adc dx,0 mov [bx+0ch],ax mov [bx+0eh],dx ret start endp code ends end begin Why do we need to introduce this dx and assign a new address? And does it have a value when it is transferred to ax? mov [bx+0ah],dx mov ax,[bx+2] If it is convenient for you, could you please help me add comments to the above program? Thanks in advance! ! ! ! ! ! ! ! !
This post is from MCU

Latest reply

8086. I haven't touched it for a long time. I'll take a seat. I'll read the manual first and then reply to you. First of all, this is the 8086 accumulative multiplication operation. So for a multiplication A*B, it means adding A for B times in a loop. There is a problem here. Address. First of all, the memory is located. For example, a 16-bit multiplier. An address space is 16 bits 0xFFFF. At this time, if a carry is generated when adding two numbers, where should the carry be placed? Of course, it should be placed in the next address space. The role of this ADC DX,0; is to automatically offset the ADD instruction with carry addition. A carry is generated after addition. The role of ADC is to introduce a carry. That is to say, DX+0+CF, so that when there is a carry, the automatic offset is increased by one. This way, each carry can be saved to the offset address. You can try it. Remove the sentence ADC DX,0;. You can only get a 16-bit number in the end. But 16 bits multiplied by 16 bits should produce a 32-bit number. [ This post was last edited by leang521 on 2009-12-17 10:40 ]  Details Published on 2009-12-17 10:14

159

Posts

0

Resources
2
Why do I need to learn 8086 assembly? Where do you plan to develop in the future?
This post is from MCU
Personal signature*我的EMAIL:     sunke9@qq.com  
*我的博客http://blog.ednchina.com/sunke9/
*我网店:https://sunke9.taobao.com/
承接:电子、自动控制产品设计开发;单片机、ARM编程。

1721

Posts

0

Resources
3
Haha, I don’t understand 8086 assembly anymore. What’s the point of learning it now?
This post is from MCU
Personal signature南京璞晓电子   www.cpx0.com需要
msn:njlianjian@hotmail.com

6352

Posts

4454

Resources
4
Haha, this has stumped many people. We don't know much about assembly. What's more, yours is computer assembly language, not 51 assembly language, so we can't help you.
This post is from MCU

2120

Posts

0

Resources
5
8086. I haven't touched it for a long time. I'll take a seat. I'll read the manual first and then reply to you. First of all, this is the 8086 accumulative multiplication operation. So for a multiplication A*B, it means adding A for B times in a loop. There is a problem here. Address. First of all, the memory is located. For example, a 16-bit multiplier. An address space is 16 bits 0xFFFF. At this time, if a carry is generated when adding two numbers, where should the carry be placed? Of course, it should be placed in the next address space. The role of this ADC DX,0; is to automatically offset the ADD instruction with carry addition. A carry is generated after addition. The role of ADC is to introduce a carry. That is to say, DX+0+CF, so that when there is a carry, the automatic offset is increased by one. This way, each carry can be saved to the offset address. You can try it. Remove the sentence ADC DX,0;. You can only get a 16-bit number in the end. But 16 bits multiplied by 16 bits should produce a 32-bit number. [ This post was last edited by leang521 on 2009-12-17 10:40 ]
This post is from MCU

Guess Your Favourite
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>

    EEWorld
    subscription
    account

    EEWorld
    service
    account

    Automotive
    development
    circle

    Robot
    development
    community

    Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
    快速回复 返回顶部 Return list