Can somebody tell me what am I doing wrong? I'm trying to open a text file, which is in the same directory as my .asm file. The text file contains one short sentence as a message and can contain up to 200 characters. The program should read the message from the .txt-file and then use the sentence read for further work. The problem is that it just exits without doing anything. I'm compiling with TASM. Here' s the code:
JUMPS
masm
model small
.data
handle dw 0
filename db 'the_message.txt',0
point_fname dd filename
string db 200 dup (" ")
point_buffer dd string
errorMes db 0ah,0dh,'Not allowed any more!','$'
mes db 0ah,0dh,'Type 1 to crypt, type 2 to decrypt!','$'
mes1 db 0ah,0dh,'Crypted one time ','$'
mes2 db 0ah,0dh,'Crypted two times ','$'
mes3 db 0ah,0dh,'Decrypted','$'
count db 0
.stack 256
.code
main:
;open
mov ax,@data
mov ds,ax
mov al,0
lds dx,point_fname
mov ah,3dh
int 21h
jc exit
mov [handle],ax
;read
mov bx,[handle]
mov cx,200
lds dx,point_buffer
mov ah,3fh
int 21h
jc exit
mov bp,ax
nop
;close
mov ah,3eh
int 21h
jc exit
nop
;Now crypt and decrypt
jmp ask
crypt1:
;test
cmp count,0
jg crypt2
xor ax,ax
mov cx,bp
mov si,0
go1:
add string[si],1
inc si
loop go1
inc count
;print on the screen
mov cx,bp
mov si,0
mov ah,09h
lea dx,mes1
int 21h
jmp show
crypt2:
;test
cmp count,1
jg notAllowed
xor ax,ax
mov cx,bp
mov si,0
go2:
add string[si],2
inc si
loop go2
inc count
;print on the screen
mov cx,bp
mov si,0
mov ah,09h
lea dx,mes2
int 21h
jmp show
decrypt2:
;test
cmp count,2
jl decrypt1
xor ax,ax
mov cx,bp
mov si,0
goDecr2:
sub string[si],2
inc si
loop goDecr2
dec count
;print on the screen
mov cx,bp
mov si,0
mov ah,09h
lea dx,mes3
int 21h
jmp show
decrypt1:
;test
cmp count,1
jl notAllowed
xor ax,ax
mov cx,bp
mov si,0
goDecr1:
sub string[si],1
inc si
loop goDecr1
dec count
;print on the screen
mov cx,bp
mov si,0
mov ah,09h
lea dx,mes3
int 21h
;jmp show
show:
mov ah,02h
mov dl,string[si]
int 21h
inc si
loop show
ask:
mov ah,09h
lea dx,mes
int 21h
mov ah, 01h
int 21h
cmp al, 31h
je crypt1
jmp decrypt2
notAllowed:
mov ah,09h
lea dx,errorMes
int 21h
;jmp exit
exit:
mov ax,4c00h
int 21h
end main