汇编语言编程 编程序,实现y=10*x 谢谢

kuaidi.ping-jia.net  作者:佚名   更新日期:2024-08-31
汇编语言:编写程序,实现求Y=10 * X,X在0~255之间

datas segment x db ? y dw ?datas endscodes segmentassume cs:codes, ds:datasstart: mov ax, datas mov ds, ax ;inut codes here mov bl, 10 mov x, 0R0: mov ah,1 int 21h cmp al, 0dh jz R1 sub al, 30h xchg al, x mul bl add x, al jmp R0R1: mov al, x mov bl, 10 mul bl mov y, ax; output codes here mov cx, 0 mov bx, 10 mov ax, yO0: xor dx, dx div bx xor dx, 0e30h push dx inc cx cmp ax, 0 jnz O0O1: pop ax int 10h loop O1 mov ah,4ch int 21hcodes endsend start

dseg segment
x db 4
y db ?
dseg ends
cseg segment
assume cs:cseg,ds:dseg
begin: mov ax,dseg
mov ds,ax

mov al,x ;取出x的值放al
and al,al ;判断x是什么数
jz zero ;为零,转zero
jns plus ;为正,转plus
mov bl,-10 ;为负数,顺序执行,把-10放在bl中
jmp save ;转移到save
zero: mov bl,0 ;x为零时,置bl为0
jmp save
plus: mov bl,10 ;正数时,置bl为10
save: mov y,bl ;保存结果
mov ah,4ch ;程序结束
int 21
cseg ends
end begin

没有编写输出,要用debug看结果。

data segment
org 1000h
x db 12
y db ?
data ends
code segment
assume cs:code,ds:data
start:mov ax,data
mov ds,ax
mov ax,ds:[1000h]
mov dx,10
mul dx
code ends
end start
结果存放在dx,ax,中分别是0000h,0078h,分别是高字节位的和低字节位的,7*16+8=120 验证正确

什么意思,完全不明白,实现y=10*x也太抽象了吧,其他要求没有了?
乘法直接不是用乘法的指令就能完成了么