Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/71.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 用8086汇编语言从用户输入实例化指定大小的数组?_Assembly_X86_X86 16 - Fatal编程技术网

Assembly 用8086汇编语言从用户输入实例化指定大小的数组?

Assembly 用8086汇编语言从用户输入实例化指定大小的数组?,assembly,x86,x86-16,Assembly,X86,X86 16,我是汇编新手,对于一个项目,我必须提示程序的用户输入所需数组的大小,然后实例化该数组 array db ? DUP(?) ;Declare array of uninitialized size 现在,我可以创建一个固定长度的数组,例如: array db 10 DUP(?) 但是,我不知道如何接受用户输入并创建指定大小的数组。 我通常会在DosBox上得到一个错误,要求我的数组有一个正计数 .code ;Mark start of cod

我是汇编新手,对于一个项目,我必须提示程序的用户输入所需数组的大小,然后实例化该数组

array db ? DUP(?)   ;Declare array of uninitialized size
现在,我可以创建一个固定长度的数组,例如:

array db 10 DUP(?)  
但是,我不知道如何接受用户输入并创建指定大小的数组。 我通常会在DosBox上得到一个错误,要求我的数组有一个正计数

.code                       ;Mark start of code segment
startCode:  
extrn readsint : proc, writesint : proc     ;Make visible the external routines

mov ax, @data   ;move data segment address into the AX register
mov ds, ax  ;Load data segment address into the segment register

lea dx, stuNameNum  ;Loads effective address of string into dx
mov ah, 09h     ;Print string interrupt
int 21h

lea dx, userPrompt1 ;Print string asking user for array size
mov ah, 09h
int 21h

call readsint       ;read user size input
mov arrSize, ax     ;Store user input

他们有办法做到这一点吗?

您可以调用操作系统服务来动态分配内存。
arrSize
是如何定义的?您没有试图在
dup(?)
表达式中使用它来表示静态存储的大小,是吗?如果是这样,那当然是个错误。静态内容必须是链接时间常量,而不是运行时变量。