tasm


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.

Related Links

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

Categories

HOME
shell
oracle12c
gridview
facebook-oauth
cheerio
codenvy
pda
twig
powerpoint
serialization
seo
edge
permissions
dojo
ado.net
pearson-correlation
spring-session
boto3
lanczos
flume
character
performancepoint
jquery-ui-sortable
dkim
plist
resultset
gruntfile
jersey-1.0
ksh
squashfs
qliksense
dynamically-generated
xunit
onload
pic32
stackexchange
outliers
paperjs
comparable
ntp
eviews
android-gridview
instantiation
hunspell
html-encode
pdw-file-browser
fiware-cygnus
node-mssql
c9.io
magento-1.9.3
subclipse
smoothstate.js
android-exoplayer
procfile
mesosphere
proget
datamaps
convex-optimization
lightning
zenhub
video-conferencing
tinkerpop
git-flow
ngmaterial
er-diagram
check-mk
pocketsphinx-android
rocks
atlas
stax
builtins
latin
xdoclet
cassia
lz77
fink
jparsec
design-principles
concept-insights
maybe
atan2
linklabel
r-package
rate-limiting
rpart
amiga
skspritenode
aspectj-maven-plugin
rrule
rapidsvn
teaspoon
strawberry-perl
rmysql
buffering
menubar
octal
font-awesome-4.0.0
video-codecs
android-sdk-2.3
redis-py
web-farm
luabind
gobject-introspection
pinch
user-tracking
jqote
rmdir
jqueryform
drupal-fivestar
zen
request-headers
build-environment
cardspace

Resources

Encrypt Message