Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.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/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
Variables 如何更改程序集中变量的值_Variables_Assembly_Operating System_Nasm_Interrupt - Fatal编程技术网

Variables 如何更改程序集中变量的值

Variables 如何更改程序集中变量的值,variables,assembly,operating-system,nasm,interrupt,Variables,Assembly,Operating System,Nasm,Interrupt,我正在为我的MikeOS港口编写一些代码。它是用NASM x86 16位汇编编写的。我试图更改一个变量,使其具有不同的值。它编译时没有错误,但当我调用os_print_string时,它会打印一些wierd ASCII字符。代码如下: BITS 16 ORG 32768 %INCLUDE "mikedev.inc" start: mov si, test2 ; give si test 2 value mov [test1], si

我正在为我的MikeOS港口编写一些代码。它是用NASM x86 16位汇编编写的。我试图更改一个变量,使其具有不同的值。它编译时没有错误,但当我调用os_print_string时,它会打印一些wierd ASCII字符。代码如下:

    BITS 16
    ORG 32768
    %INCLUDE "mikedev.inc"



start:
    mov si, test2          ; give si test 2 value
    mov [test1], si        ; give test 1 si's value
    mov si, test1          ;now give test1's value to si
    call os_print_string   ; and print

test2 db "adsfasdfasdf", 0
test1 db "asdf", 0
我知道这个代码是多余的。我只需要一个关于如何改变变量值的解释。提前到达塔克斯


-Ryan

您正在做的是获取test2的地址,并将其存储在test1的前两个字节中,即第一个广告曾经所在的位置。您不能在运行时更改test1的地址。您可以做的是将内容(即所有字符)从test2复制到test1。请记住,test1没有足够的空间容纳test2中的所有角色。作为对Michael的回复:谢谢你的评论,但我想我可能还不够清楚。我为MikeOS制作的这个项目是一种脚本语言。我试图找出如何将一个变量的值分配给另一个变量,即字符串a=b;。在这种情况下,您可能不会像在当前代码中那样实现字符串。test1和test2更类似于C中的char*const,即不能更改为指向其他任何地方的指针。