.model small
.stack 100h
.data
tang db 'enter word: ',0
diana db 13,10,'the reverse is ',0
inside db 80 dup (0)
words dw ?
.code
sugod:
mov ax,@data
mov ds,ax
mov words,0
mov ax,offset tang
call put_str
dec words
mov ax,offset inside
call get_str
add words,ax
mov ax,offset diana
call put_str
rope:
mov bx,words
mov al,byte ptr [bx]
cmp al,0
je finish
call putc
dec words
jmp rope
putc:
mov dl,al
mov ah,2h
int 21h
ret
getc:
mov ah,1h
int 21h
ret
get_str:
push ax
push bx
push cx
push dx
mov bx,ax
call getc
mov byte ptr[bx],al
get_loop:
cmp al,13
je get_fin
inc bx
inc words
call getc
mov byte ptr[bx],al
jmp get_loop
get_fin:
mov byte ptr[bx],0
pop dx
pop cx
pop bx
pop ax
ret
put_str:
push ax
push bx
push cx
push dx
mov bx,ax
mov al,byte ptr [bx]
put_loop:
cmp al,0
je put_fin
call putc
inc bx
mov al,byte ptr[bx]
jmp put_loop
put_fin:
pop dx
pop cx
pop bx
pop ax
ret
finish:
mov ax,4c00h
int 21h
nextline:
mov al,13
call putc
mov al,10
call putc
ret
end sugod
No comments:
Post a Comment