TITLE menu.asm include irvine32.inc clearEAX TEXTEQU <mov eax, 0> clearEBX TEXTE
ID: 3861485 • Letter: T
Question
TITLE menu.asm
include irvine32.inc
clearEAX TEXTEQU <mov eax, 0>
clearEBX TEXTEQU <mov ebx, 0>
clearECX TEXTEQU <mov ecx, 0>
clearEDX TEXTEQU <mov edx, 0>
clearESI TEXTEQU <mov esi, 0>
clearEDI TEXTEQU <mov edi, 0>
.data
prompt1 Byte 'MAIN MENU', 0ah, 0dh,
'---------', 0ah, 0dh,
'1. Enter a string', 0Ah, 0Dh,
'2. Convert the string to lower case', 0Ah, 0Dh,
'3. Remove all non-letter elements', 0Ah, 0Dh,
'4. Is the string a palindrome?', 0Ah, 0Dh,
'5. Print the string', 0Ah, 0Dh,
'6. Quit', 0Ah, 0Dh, 0h
oops Byte 'Invalid Entry. Please try again.', 0h
UserInput Byte 0h
theString Byte 50 dup(0h),0h
theStringlen Byte 0h
.code
main PROC
clearEAX
clearEBX
clearECX
clearEDX
clearESI
clearEDI
starthere:
Call clrscr
mov edx, OFFSET prompt1
Call WriteString
Call ReadDec
mov userinput, al
opt1: ;// option 1
cmp userinput, 1
jne opt2
mov edx, OFFSET theString
mov ecx, LENGTHOF theString
Call option1
mov theStringLen, al
jmp starthere
opt2:
cmp userinput, 2
jne opt3
mov edx, OFFSET theString ;//offset Of String To play With
movzx ecx, theStringLen ;//length Of String To play With
Call option2
jmp starthere
opt3: ;//remove all non-letter elements
cmp userinput, 3
jne opt4
mov edx, OFFSET theString ;//offset Of String To play With
movzx ecx, theStringLen ;//length Of String To play With
Call option3
jmp starthere
opt4: ;// Is it a palindrome
cmp userinput, 4
jne opt5
mov edx, OFFSET theString ;//offset Of String To play With
movzx ecx, theStringLen ;//length Of String To play With
Call option4
jmp starthere
opt5:
cmp userinput, 5
jne opt6
mov edx, OFFSET theString ;//offset Of String To play With
Call WriteString
jmp starthere
opt6:
cmp userinput, 6
je theEnd
mov edx, OFFSET oops
Call WriteString
Call waitmsg
jmp starthere
theEnd:
Exit
main ENDP
;//---------------------------------------
option1 PROC uses EDX ECX
;Desc: Prompts the user To enter a String.
; User entered string will be stored in
; the array passed in EDX
;Receives: edx -offset of the string
; ecx - max length of the string
;Returns: eax -number of chars entered by user
.data
opt1prompt Byte "Enter a string.", 0Ah, 0Dh, "----> ", 0h
.code
push edx
mov edx, offset opt1prompt
Call WriteString
pop edx
Call ReadString
ret
option1 ENDP
option2 PROC
ret
option2 ENDP
option3 PROC
ret
option3 ENDP
option4 PROC
ret
option4 ENDP
End main
This is menu based assembly language problem, Is there someone to help, option1 is done and need to work on the rest of the option?
Thanks in Advance
Explanation / Answer
section .text
global _start ;must be declared for using gcc
_start: ;tell linker entry point
mov edx, len ;message length
mov ecx, msg ;message to write
mov ebx, 1 ;file descriptor (stdout)
mov eax, 4 ;system call number (sys_write)
int 0x80 ;call kernel
mov edx,20
mov ecx,output
mov ebx,1
mov eax,3
int 0x80
mov eax,output
mov cl,20
back:
mov bl,[eax]
cmp bl,96
jg next
add bl,32
mov [eax],bl
next:
add eax,1
dec cl
jnz back
mov edx, eax ;message length
mov ecx, output ;message to write
mov ebx, 1 ;file descriptor (stdout)
mov eax, 4 ;system call number (sys_write)
int 0x80 ;call kernel
mov eax, 1 ;system call number (sys_exit)
int 0x80 ;call kernel
section .data
msg db 'Please Enter a string up to 20 Characters',0xa,0 ;our dear string
len equ $ - msg ;length of our dear string
section .bss
output : db 20
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.