Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

.MODEL small .STACK 100h .DATA TimePrompt DB \'Is it after 12 noon (Y/N)?$\' Goo

ID: 3733821 • Letter: #

Question

.MODEL small

.STACK 100h

.DATA

TimePrompt DB 'Is it after 12 noon (Y/N)?$'

GoodMorningMessage DB 13,10,'Good morning, world!',

13,10,'$'

GoodAfternoonMessage DB 13,10,'Good afternoon, worl

d!',13,10,'$'

DefaultMessage DB 13,10,'Good day, world!',10,13,'$

'

.CODE

start:

mov ax, @data

mov ds, ax

mov dx, OFFSET TimePrompt

mov ah, 9

int 21h

mov ah, 1

int 21h

or al, 20h

cmp al, 'y'

je IsAfternoon

cmp al, 'n'

je IsMorning

mov dx, OFFSET DefaultMessage

IsAfternoon:

mov dx, OFFSET GoodAfternoonMessage

jmp DisplayGreeting

IsMorning:

mov dx, OFFSET GoodMorningMessage

DisplayGreeting:

mov ah, 9

int 21h

mov ah, 4ch

mov al, 0

int 21h

END start

1) Ask user to enter their name. What is your name? Eric

2) Use the name to replace world in the greeting message

Explanation / Answer

.MODEL small

.STACK 100h

.DATA

name db ?

msg DB 'Enter your name',13,10,'$'

TimePrompt DB 'Is it after 12 noon (Y/N)?$'

GoodMorningMessage DB 'Good morning, world!',13,10,'$'

GoodAfternoonMessage DB 13,10,'Goodafternoon,world!',13,10,'$'

DefaultMessage DB 13,10,'Good day, world!',10,13,'$'

.CODE

start:

mov ax, @data

mov ds, ax

mov dx, OFFSET TimePrompt

mov ah, 9

int 21h

mov ah, 1

int 21h

or al, 20h

cmp al, 'y'

je IsAfternoon

cmp al, 'n'

je IsMorning

mov dx, OFFSET DefaultMessage

IsAfternoon:

mov dx, OFFSET msg

mov ah, 9

int 21h

mov dx, OFFSET GoodAfternoonMessage

jmp DisplayGreeting

IsMorning:

mov dx, OFFSET msg

mov ah, 9

int 21h

mov dx, OFFSET GoodMorningMessage

DisplayGreeting:

mov ah, 9

int 21h

mov ah,0ah

mov dx,0Fh

mov dx,ah

int 21h

mov ah,9

int 21h

mov ah, 4ch

mov al, 0

int 21h ;mount c: /home/krsna/codinglife/MASM

END start