tasm 输出问题

tasm Trouble with output

我很难确定哪个寄存器保存了我需要输出的信息。我已经尝试使用 incs 和 decs 的 byte ptr si、bl、bx,但我完全无法弄清楚我需要做什么才能输出。目前它只是不输出任何东西。我需要输出的是输入,除了用它前面的字符替换所有的空白,所以 "a b c" 变成 "aabbc".

这是我无法理解的代码。

.MODEL SMALL ;defines memory model
.STACK 100H ;reserves memory space
.DATA
insert equ 0ah
outsert equ 9h
ENDL equ '$'
GAP equ ' '
EMPTY equ ' '
newline db 0ah, 0dh, '$'
;db 120h dup (?) ;reserve 120h bytes of space
Buff db 250
clen db ?
_chr db 250 dup (?) ;reserve 250 bytes of space for line
.CODE
START:
mov     dx, @data               ; perkelti data i registra ax
mov     ds, dx                  ; nustatyti ds rodyti i data segmenta

;user input
lea dx, Buff ;load address
mov ah, insert ;insert into ah
int 21h ;close

; putting length into cx
xor cx, cx
mov cl, clen
mov si, offset clen ;loads offset part

;if line is empty, end
cmp cx, 0 ;compare
;testing if end of the line
je FINISH

mov dx, offset newline ;from the 3'rd byte
mov ah, outsert
int 21h; ;finsihing up, closing

;pre-checking
PREP:
dec cx
inc si
cmp byte ptr [si], EMPTY
je PREP
jmp CHECK

CHECK:
dec cx ;decrement starting pointer by 1
inc si ;raise starting pointer by 1
cmp cx, 0 ;comparing if empty
je CONT ;jei paskutinis, tai baigiamas ciklas
cmp byte ptr [si], GAP ;2 operands compare
je CHANGE ;if gap found, then off to this cycle to change symbol
jmp CHECK
CHANGE:
mov bl, byte ptr [si-1]
mov [si], bl
jmp CHECK ;returning to cycle
CONT:
; '$' at end of buffer
; vi points at last symbol
inc si
mov bl, ENDL
mov [si], bl

;output onto screen
;lea dx, Buff
;add ax, 2 ;from the 3'rd byte
;mov ah, outsert
;int 21h; ;finsihing up, closing
xor ch, ch
mov cl, clen
mov si, offset _chr
ciklas:
lodsb
mov bx, 2
;al
dec bx
jz FINISH
loop ciklas


;returning to DOS
FINISH:
mov ax, 4c00h ;exit
int 21h

如果有必要,我会在截取的代码中添加,我将其删除是因为我认为找出输出问题并不重要。非常感谢您对我的耐心等待。

注释掉的代码应该可以正常工作,除了将 2 添加到 ax 而不是 dx:

;output onto screen
lea dx, Buff+2
mov ah, outsert
int 21h; ;finsihing up, closing

;returning to DOS
FINISH:
mov ax, 4c00h ;exit
int 21h