how to fix the output for x86 turbo assembly language

青春壹個敷衍的年華 提交于 2019-12-02 08:59:28

Int 21h/0Ah expects a pointer to a structure, not a pointer to a string. The first byte of that structure must filled by you with the maximal length of the string. The second byte will be filled by the function with the real length of the inputted string. The string won't end with '$' as needed for int 21h/09h, but with 0Dh. So you need to change that character.

I corrected the issues only for inputName. The rest is up to you.

    ...
    mov inputName,21
    lea dx,inputName
    mov ah,0ah
    int 21h

    ; change 0Dh to '$'
    xor bh,bh
    mov bl, [inputName+1]             ; length of string
    mov byte [inputName+2+bx], '$'    ; store end-of-string-character 

    ...

    lea dx, outputName
    mov ah,09h
    int 21h

    lea dx, [inputName+2]             ; pointer to string
    mov ah,09h
    int 21h

    ...
Dirk Wolfgang Glomp

Note: The format of DOS input buffer+2 contains the actual characters read, including the final carriage return.

RBIL->inter61b.zip->INTERRUP.F
--------D-210A-------------------------------
INT 21 - DOS 1+ - BUFFERED INPUT
AH = 0Ah
DS:DX -> buffer (see #01344)
Return: buffer filled with user input
Notes:  ^C/^Break are checked, and INT 23 is called if either detected
reads from standard input, which may be redirected under DOS 2+
if the maximum buffer size (see #01344) is set to 00h, this call returns
  immediately without reading any input
SeeAlso: AH=0Ch,INT 2F/AX=4810h

Format of DOS input buffer:
Offset  Size    Description (Table 01344)
 00h    BYTE    maximum characters buffer can hold
 01h    BYTE    (call) number of chars from last input which may be recalled
    (ret) number of characters actually read, excluding CR
 02h  N BYTEs   actual characters read, including the final carriage return
--------K-210A00-----------------------------
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!