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/regex/17.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 int 21h ah 02h不';因为某种原因我不能工作_Assembly_Dos_X86 16_Keyboard Input - Fatal编程技术网

Assembly int 21h ah 02h不';因为某种原因我不能工作

Assembly int 21h ah 02h不';因为某种原因我不能工作,assembly,dos,x86-16,keyboard-input,Assembly,Dos,X86 16,Keyboard Input,我的任务是从终端(又名atoi)读取一个数字,然后将其写回终端(又名itoa) 要读取字符串,我使用int21h,ah0ah。当我在调试器中检查它时,它看起来很好。然后我的atoi和itoa看起来也不错,除了在itoa中我使用int21h,ah02h来显示一个字符,但由于某种原因它没有显示。所以我回到开头,注意到在int21h,ah0ah(读取字符串)之后立即写入int21h,ah02h(打印字符)不会产生任何结果 ; STACK SEGMENT STSEG SEGMENT PARA STACK

我的任务是从终端(又名atoi)读取一个数字,然后将其写回终端(又名itoa)

要读取字符串,我使用
int21h,ah0ah
。当我在调试器中检查它时,它看起来很好。然后我的atoi和itoa看起来也不错,除了在itoa中我使用
int21h,ah02h
来显示一个字符,但由于某种原因它没有显示。所以我回到开头,注意到在
int21h,ah0ah
(读取字符串)之后立即写入
int21h,ah02h
(打印字符)不会产生任何结果

; STACK SEGMENT
STSEG SEGMENT PARA STACK "STACK"
    DB 64 DUP (0)
STSEG ENDS

; DATA SEGMENT
DSEG SEGMENT PARA PUBLIC "DATA"
    startStr db "Enter a number : $"
    inputError db "Number has incorrect chars.", 10, "$"
    buffError db "Number is too big", 10, "$"
    bufferSize DB 16        ; 15 chars + RETURN
    inputLength DB 0        ; number of read chars
    buffer DB 16 DUP('?')   ; actual buffer
DSEG ENDS

; CODE SEGMENT

CSEG SEGMENT PARA PUBLIC "CODE"

    MAIN PROC FAR
        ASSUME cs: CSEG, ds: DSEG, ss:STSEG
        mov ax, DSEG
        mov ds, ax
        ;lea dx, startStr
        ;call WRITING
        ;call READING

        xor ax, ax
        xor dx, dx
        mov ah, 2
        mov dl, 56
        int 21h

;test display char before reading string - works fine


        xor dx, dx
        xor ax, ax
        lea dx, bufferSize
        mov ah, 10
        int 21h

; reading string - works fine

        xor ax, ax
        xor dx, dx
        mov ah, 2
        mov dl, 56
        int 21h

; trying to display char again - nothing

        ; call ATOI
        ; add ax, 15
        ; call ITOA
        ret
    MAIN ENDP
CSEG ENDS
END MAIN


“8”是我在开头显示的字符123'是我输入的字符串,然后按回车键。

一旦DOS缓冲输入函数0Ah收到回车键, 根据DOS仿真器的工作方式,光标将移动到当前行的开头还是下一行

由于在程序退出之前只剩下输出第二个“8”,DOS提示可能会覆盖第二个“8”。看

尝试推迟终止程序。只需等待钥匙。
还可以打印与第一个角色不同的内容

    mov dl, "*"
    mov ah, 02h  ; DOS.PrintChar
    int 21h
    mov ah, 00h  ; BIOS.GetKey
    int 16h

    ret
    MAIN ENDP
CSEG ENDS
END MAIN

它确实起作用,但它正在覆盖已打印的内容。使用不同的字符,您将看到。将第二个
mov-dl,56
更改为
mov-dl,57
,然后您将看到正在打印
9
。这是用于终止输入的回车的副作用。我尝试将其更改为57-没有任何更改。我已尝试将其更改为10(必须是\n)-没有结果。还有别的事吗?在这里工作。你换了第二个吗?@Jester yeap。正如我所说,我尝试了不同的值,但在我的机器上没有任何变化