TITLE Proj2
PAGE 56,90
; file: Proj2.asm
; date: 04/26/07
; ----------------------------------------
;
;
; This program will take a name entered by the user
; and display it backwards. It will also tell the
; user whether the word is a palindrome or not.
; ----------------------------------------
.MODEL SMALL
.STACK 100H
.DATA
CR EQU 0DH ; Carriage Return Code
LF EQU 0AH ; Line Feed Control Code
DOSEXIT EQU 4CH ; DOS exit code for 21h int
para_list LABEL BYTE
max_len db 20
act_len db ?
theword db 20 DUP(' ')
MSG1 DB 'Enter a word $'
ItIs DB 'The word is a Palindrome $'
ItIsNot DB 'The word is not a Palindrome $'
MSG2 DB 'The word backwards is $'
wordbw DB 12 DUP(20H),'$'
; --------- End of Data Segment ----------
.CODE
Main PROC
;------------------------------------------
; The routine performs basic
; "housekeeping" operations necessary in
; any Assembly Language Program running
; under DOS or Windows...
; 1 - Establish Addressability to the
; Data Segment of the program.
;------------------------------------------
HouseKeeping:
mov ax,@data ;get addr. of DSeg.
mov ds,ax ;set in DS Reg.
;------------------------------------------
; Routine "GetPut" will...
; 1 - Display prompt message.
; 2 - capture user provided ASCII
; letter (located in AL register).
; 3 - Convert the letter to it's decimal
; equivalent.
; 4 - Display the converted letter within
; an "echoing" message.
;------------------------------------------
Prompt:
lea dx,MSG1 ;addr. of 1st msg
mov ah,9h ;set for str. displ.
int 21H ;call DOS to displ.
mov ah, 06h
mov al,00h
int 10h
;DISPLAY MESSAGE ABOVE;
GetWord:
mov ah,0Ah ;set func. to Get String
lea DX,Para_list ;load address of para list
int 21H ;call DOS (val-AL)
mov theword,al ;move input to theword
;Clear Screen
mov ax,0600h
mov bh,07
mov cx,0000
mov dx,184fh
int 10h
;Clear Screen
ChangeWord:
CLD
MOV CX,20
LEA SI,theword
LEA DI,wordbw+11
L20:
LODSB
MOV [DI],AL
DEC DI
LOOP L20
;Clear Screen
mov ax,0600h
mov bh,07
mov cx,0000
mov dx,184fh
int 10h
;Clear Screen
lea dx, wordbw
mov ah,9
int 21h
;------------------------------------------
; The routine sets the exit code and
; calls DOS. This is the appropriate
; technique for terminating a non-
; resident program running under DOS.
;------------------------------------------
PgmExit:
mov ah,DOSEXIT ;set Exit code
int 21H ;and call DOS
Main EndP
End Main