Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly 代码在bell triangle(汇编语言emu8086)中给出了错误的输出_Assembly_Emulation_X86 16 - Fatal编程技术网

Assembly 代码在bell triangle(汇编语言emu8086)中给出了错误的输出

Assembly 代码在bell triangle(汇编语言emu8086)中给出了错误的输出,assembly,emulation,x86-16,Assembly,Emulation,X86 16,我想用汇编语言emu8086制作贝尔三角形 我在这方面有问题 mov ch,a[DI-(1+d)] d=1;可变增量 我试着移除(1+d)并将其放置为2,使其像这样 mov ch,a[DI-2] 1 1 2 2 3 5 5 7 10 15 它给出了我想要的结果,但我想使用变量(d),因为它每次都会改变 这就是问题所在 J2: cmp DI,bx JE J1 mov al, a[DI] mov ch,a[DI-(1+d)] //in this line// add al,ch in

我想用汇编语言emu8086制作贝尔三角形

我在这方面有问题

mov ch,a[DI-(1+d)] 
d=1;可变增量 我试着移除(1+d)并将其放置为2,使其像这样

mov ch,a[DI-2]
1
1 2
2 3 5 
5 7 10 15 
它给出了我想要的结果,但我想使用变量(d),因为它每次都会改变

这就是问题所在

J2:
cmp DI,bx
JE J1
mov al, a[DI] 
mov ch,a[DI-(1+d)] //in this line//
add al,ch
inc di
mov a[DI],al
print ' '
call print_num 
mov dl,c 
mov b,dx
jmp J2
这就是输出

1
1 2
2 2 2
2 2 2 2
但应该是这样的

mov ch,a[DI-2]
1
1 2
2 3 5 
5 7 10 15 

我认为问题在于括号

处理器寄存器中只能有不同的地址组件

mov ch,a[DI-(1+d)]
假设d是一个单词大小的变量,我建议您编写以下代码:

push bx  ;Save because you use it elsewhere!
mov bx,d
neg bx
mov ch,a[DI-1+BX]
pop bx

什么是
d
声明为“d”,它是循环中增加1的变量