Professional Documents
Culture Documents
data
menumsg db 10,10,'Menu:',10
db 10,'5) Exit',10
spacechar db 20h
section .bss
cnt resb 01
optionbuff resb 02
dispbuff resb 03
srcstr resb 10
revstr resb 10
string resb 0
%macro dispmsg 2
mov eax,04
mov ebx,01
mov ecx,%1
mov edx,%2
int 80h
%endmacro
%macro accept 2
mov eax,03
mov ebx,00
mov ecx,%1
mov edx,%2
int 80h
%endmacro
%macro acceptstr 1
mov eax,03
mov ebx,00
mov ecx,%1
int 80h
%endmacro
section .text
global _start
_start:
menu:
dispmsg menumsg,menumsg_len
accept optionbuff,02
jne case2
call entstr_proc
jmp exit1
case2:
jne case3
call length_proc
jmp exit1
case3:
jne case4
call reverse_proc
jmp exit1
case4:
jne case5
call pal_proc
jmp exit1
case5:
je exit
dispmsg wrchmsg,wrchmsg_len
jmp menu
exit1:
dispmsg restmsg,restmsg_len
accept optionbuff,02
jne y1
jmp menu
y1:
jne exit
jmp menu
exit:
mov eax,01
mov ebx,00
int 80h
dispblk_proc:
mov ecx,cnt
rdisp:
push ecx
mov bl,[esi]
call disp8_proc
inc esi
dispmsg spacechar,1
pop ecx
loop rdisp
ret
entstr_proc:
dispmsg entmsg,entmsg_len
acceptstr srcstr
dec al
mov [cnt],al
ret
length_proc:
dispmsg lmsg,lmsg_len
mov bl,[cnt]
call disp8_proc
ret
reverse_proc:
mov ecx,00
mov esi,srcstr
mov edi,revstr
mov cl,[cnt]
add esi,ecx
sub esi,1
up2:
mov al,[esi]
mov [edi],al
inc edi
dec esi
loop up2
dispmsg revmsg,revmsg_len
dispmsg revstr,cnt
ret
pal_proc:
mov ecx,00
mov esi,srcstr
mov edi,revstr
mov cl,[cnt]
up3:
mov al,[esi]
mov bl,[edi]
cmp al,bl
jne exit2
inc esi
inc edi
loop up3
dispmsg palmsg,palmsg_len
jmp return
exit2:
dispmsg npalmsg,npalmsg_len
return:
ret
disp8_proc:
mov ecx,02
mov edi,dispbuff
dup1:
rol bl,4
mov al,bl
and al,0Fh
cmp al,09h
jbe dskip
add al,07h
dskip:
add al,30h
mov [edi],al
inc edi
loop dup1
dispmsg dispbuff,03
ret
OUTPUT:-
Menu:
5) Exit
Menu:
5) Exit
Menu:
5) Exit
Menu:
5) Exit
String is a Palindrome!
root@atharva-Inspiron-3542:/home/atharva#