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
Assembly 汇编:字符串输入(字号)和重新打印_Assembly_X86_Dos_16 Bit - Fatal编程技术网

Assembly 汇编:字符串输入(字号)和重新打印

Assembly 汇编:字符串输入(字号)和重新打印,assembly,x86,dos,16-bit,Assembly,X86,Dos,16 Bit,我不知道出了什么问题。我想输入字号大小的字符串,在字符串的输入值上加一个整数,然后重新打印结果。我不太清楚算术运算,因为这是我第一次在一个程序中使用许多运算,它们是16位的 clr macro mov ax, 03h int 10h endm cseg segment para 'code' assume cs:cseg; ds:cseg; ss:cseg; es:cseg org 100h start: jmp begin amount_s label w

我不知道出了什么问题。我想输入字号大小的字符串,在字符串的输入值上加一个整数,然后重新打印结果。我不太清楚算术运算,因为这是我第一次在一个程序中使用许多运算,它们是16位的

clr macro  
mov ax, 03h  
int 10h  
endm  

cseg segment para 'code'  
assume cs:cseg; ds:cseg; ss:cseg; es:cseg  
org 100h  

start: jmp begin  

amount_s label word  
amount_max dw 3  
amount_length dw ?  
amount_field dw 3 dup (?)  

x1 dw 0  
x2 dw 0  

sum1 dw 0
sum2 dw 0

bal dw 10

begin:  clr

mov ah, 0Ah     ;input string
lea dx, amount_s
mov cx, amount_length
lea si, amount_field
int 21h

mov ax, [si]        ;copy si to ax
sub ax, 30h     ;converts value of ax to integer
mov bx, 10      ;copy 10 to bx      
mul bx          ;multiply it ax by bx
mov x1, ax      ; copy ax to x1
inc si          ;move si pointer by 1

mov ax, [si]        ;copy si to ax
sub ax, 30h     ;converts value of ax to integer
mov x2, ax      ; copy ax to x2

add ax, x1      ;add ax which is x2 by x1
add ax, bal     ; add ax by bal which is 10
mov sum1, ax        ;copy the result to sum1

mov dx, 0       ; copy 0 to dx  
mov bx, 10      ; copy 10 to bx
div bx          ;divides ax by bx
mov sum1, ax        ; copy quotient to sum1
mov sum2, dx        ; copy remainder to sum2

add sum1, 30h       ;convert for printing
add sum2, 30h       ;convert for printing

mov ah, 02h     ;prints sum1
mov dx, sum1
int 21h

mov ah, 02h     ;prints sum2
mov dx, sum2
int 21h

int 20h
cseg ends
end start

如何调试和检查参考文档,看看哪里出了问题,如何解决

有一件事我可以直截了当地说,int 21h的函数0ah使用的结构包含字节字段,而不是单词字段

但您将它们声明为单词(
dw
),而不是字节(
db
):

而且,您不应该像使用以下内容那样以文字形式访问它们:

mov ax, [si]
而是读取字节:

mov al, [si]
如果要将字节值转换为字值,只需在字寄存器的顶部字节中插入一个0,如下所示:

mov ah, 0

其余的看起来合理,但我还没有运行代码。你应该这样做。在调试器中,如果它工作不正常。

Oh。我不知道我使用的代码只是字节。谢谢你的更正。我回家后再试试。
mov ah, 0