计算 c = ((22-7)/5)*113 的汇编 8086 程序

发布于 2024-10-24 13:37:49 字数 325 浏览 1 评论 0原文

嗨,我真的不知道这是如何工作的,

data segment
 db 22
 db 7
 db 5
 db 113
data ends
code segment
 assume cs:code,ds:data
start:mov si,500H
 mov di,1500H
 mov ah,0
 mov al,22
 cbw
 sub ax,7
 mov cx,5
 idiv cx
 mov bx,113
 imul bx
 mov dl,ax
 mov [di],al
 code ends
end start

我真的不知道这个程序发生了什么,所以任何帮助将不胜感激

hi i really have no idea how this is working

data segment
 db 22
 db 7
 db 5
 db 113
data ends
code segment
 assume cs:code,ds:data
start:mov si,500H
 mov di,1500H
 mov ah,0
 mov al,22
 cbw
 sub ax,7
 mov cx,5
 idiv cx
 mov bx,113
 imul bx
 mov dl,ax
 mov [di],al
 code ends
end start

i really don't know what's going on in this program so any help would be appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

孤城病女 2024-10-31 13:37:49

一般来说,代码看起来不正确。但无论如何,让我们回顾一下主要部分:

数据段 - 声明将用于计算的 3 个字节的数据(但不幸的是根本没有使用)。 db - 是字节声明(与 dw - d eclare w ord 相比,...)
代码段 - 声明程序代码

完全从那里开始执行计算,您只需要执行以下操作:

mov AX, 22; place number 22 to processor register AX
sub AX, 7; now we have subtract 7 from AX and place it back to AX
mov CX, 5; 5 is placed to CX register
xor DX, DX; per comment of @GJ
idiv cx ; divide AX / CX
mov bx,113; BX now contains 113
imul bx; at last mul result of AX on BX and place back to AX

In general code not looks correct. But anyway let's review main parts:

data segment - declares 3 bytes of data that would be used for calc (but unfortunately doesn't used at all). db - is declaration of byte (compare with dw - d eclare w ord, ...)
code segment - declares that program code starts there

totally for perform calculation you need only following:

mov AX, 22; place number 22 to processor register AX
sub AX, 7; now we have subtract 7 from AX and place it back to AX
mov CX, 5; 5 is placed to CX register
xor DX, DX; per comment of @GJ
idiv cx ; divide AX / CX
mov bx,113; BX now contains 113
imul bx; at last mul result of AX on BX and place back to AX
貪欢 2024-10-31 13:37:49

以下是一些有用的提示:

  • mov dst, src 将 src 复制到 dest
  • 操作数 *dst *, src 对 src 和 dest 执行操作数,并将结果复制到 dest。例如,sub ax, 7 计算 ax - 7 并将结果放入 ax 中。
  • idiv src 将 src 乘以 ax,并将结果放入 ax。 imul 对乘法执行相同的操作。

这应该足以让您开始。

Here are some useful tips:

  • mov dst, src copies the src into the dest
  • operand *dst*, src performs the operand on the src and the dest and copies the result into the dest. For instance, sub ax, 7 calculates ax - 7 and puts the result in ax.
  • idiv src multiplies the src by ax, and puts the result in ax. imul does the same with multiplication.

This should be enough to get you started.

小帐篷 2024-10-31 13:37:49

简单的:

mov word[c],((22-7)/5)*113

Simple:

mov word[c],((22-7)/5)*113
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文