Assembly 8086 program that calculates c = ((22-7)/5)*113
hi i really have no idea how this is working
dat开发者_运维知识库a 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
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
Here are some useful tips:
mov dst, src
copies the src into the destoperand *dst*, src
performs the operand on the src and the dest and copies the result into the dest. For instance,sub ax, 7
calculatesax - 7
and puts the result inax
.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.
Simple:
mov word[c],((22-7)/5)*113
精彩评论