Question: Write a program using procedures to display good morning, good day and good evening message depending on the time entered by the user. If user

Write a program using procedures to display "good morning", "good day" and "good evening" message depending on the time entered by the user. If user enters: hour of the day 10 or less, it should display "Good Morning" hour of the day 20 or less, it should display "Good Day" hour of the day more than 20, it should display "Good Evening" The input number entered by the user should be in hours only. Do not enter minutes. Input should be 24 hrs. format and should not be more than 23. Please write the source code in the space given below and attach the .ASM emulator file. You can copy/paste the code from the emulator. Sample Run 1: Please enter time in 24 hr format: 16 Good Day! Sample Run 2: Please enter time in 24 hr format: 9 Good Morning!

Sol74:

Here is the program in NASM Assembly Language:

section .data

prompt db "Please enter time in 24 hr format: "

msg_morning db "Good Morning!"

msg_day db "Good Day!"

msg_evening db "Good Evening!"

section .bss

hour resb 1

section .text

global _start

_start:

; Prompt user for input

mov eax, 4

mov ebx, 1

mov ecx, prompt

mov edx, 29

int 0x80

; Read user input

mov eax, 3

mov ebx, 0

mov ecx, hour

mov edx, 1

int 0x80

; Convert input to integer

mov eax, [hour]

sub eax, 48

; Call appropriate message based on input

cmp eax, 10

jle display_morning

cmp eax, 20

jle display_day

jmp display_evening

display_morning:

mov eax, 4

mov ebx, 1

mov ecx, msg_morning

mov edx, 13

int 0x80

jmp exit_program

display_day:

mov eax, 4

mov ebx, 1

mov ecx, msg_day

mov edx, 9

int 0x80

jmp exit_program

display_evening:

mov eax, 4

mov ebx, 1

mov ecx, msg_evening

mov edx, 13

int 0x80

exit_program:

; Exit program

mov eax, 1

xor ebx, ebx

int 0x80

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!