TASM problems with output
So, I am a complete newcomer to TASM, so I'm probably making loads and loads of mistakes. This is one problem, however, I wish for some help with. I need to assemble a program that takes the input from the user and replaces all gaps with the character before it (So, if the input is a b c, it should print aabbc). The problem I have is that I am getting garbage data printed out instead of what I need. I honestly don't know what the problem is, so I am requesting help with this. Oh, and just in advance, I'm using DosBox on Windows 8. Here is the code: .MODEL SMALL ;defines memory model .STACK 100H ;reserves memory space .DATA insert equ 0ah outsert equ 9h ENDL equ '$' GAP equ ' ' ;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: ; initialization push ds ; iveda Word/Doubleword i steka sub cx, cx ; subtract push cx mov cx, ds ;ds = cx specifically moves the data segment mov ds, cx ;cx = ds same as above ;user input lea ax, 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 ;string testing 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 ax, Buff add ax, 2 ;from the 3'rd byte mov ah, outsert int 21h; ;finsihing up, closing ;returning to DOS FINISH: mov cx, 4c00h ;exit int 21h END START I apologize in advance if a similar question might have been answered already (I couldn't find anything from searching, though) and I thank you for answers.
How do you code subtraction in TASM
How to do inverse subtraction in TASM?
Display Negative numbers in TASM
getch() in TASM
why do we use 0dh,0ah after msg1 db in this statement :msg1 db 0dh, 0ah, “ENTER A CHOICE $”;
TASM problems with output
TASM Can't locate .asm file Error: **Fatal** Command line: Can't locate file: filename.asm
TASM giving no output after compile
I can't figure out how to delete a row in my tasm assembly homework
How to read and write A FAT in WinXP [duplicate]
Turbo Assembler [closed]
8086 programming using TASM: pc to pc communication