Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6624523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:39:50+00:00 2026-05-25T21:39:50+00:00

I have an assignment that is described like so: – Reads printable characters (20h-7Fh)

  • 0

I have an assignment that is described like so:

- Reads printable characters (20h-7Fh) from the keyboard without echoing
- Uppercase letters are printed to display
- Lowercase letters are converted to uppercase and then printed to display
- Blank spaces and periods are printed to display; everything else is trashed
- Program ends when period is printed

My program so far is this:

    .model      small
    .8086


    .data


    .code

start:
        mov     ax,@data
        mov     ds,ax

read:
        mov     ah,8
        int     21h
        cmp     al,61
        jl      write
        cmp     al,7fh
        jg      read
        sub     al,20h
        jmp     write

write:      cmp     al,20h
        jl      read
        mov     dl,al
        mov     ah,2
        int     21h
        cmp     dl,2eh
        jne     read

exit:
        mov     ax,4c00h
        int     21h
        end     start

My program succesfully converts lowercase letters and prints the corresponding uppercase letter, but I am having trouble trashing everything else. What is the best way to only allow blank spaces, periods, and letters through to the display?

Looking at the ASCII chart,

21h - 2Dh can be trashed
2Fh - 40h can be trashed
5bh - 60h can be trashed
7bh - 7fh can be trashed

Can anyone help me come up with the best logic for comparing the input to these values and then trashing those that fall between the range above? We are graded on efficiency, with 0-20 instructions written awarded full credit. I am already at 20 instructions here and I haven’t included compares to find the trash values.

EDIT
Here is what I have narrowed my code down to:

    .model      small
    .8086


    .data


    .code


read:
        mov     ah,8
        int     21h
        cmp     al,' '
        je      write
        cmp     al,'.'
        je      write
        cmp     al,'a'
        jl      read
        cmp     al,'Z'
        jg      convert

convert:    
        cmp     al,'a'
        jl      read
        sub     al,20h

write:      
        mov     dl,al
        mov     ah,2
        int     21h
        cmp     dl,'.'
        jne     read

exit:
        mov     ax, 4c00h
        int     21h
        end     read

Currently at 21 instructions! Is there any redundancy in my code that can be removed to get it down to 20?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:39:50+00:00Added an answer on May 25, 2026 at 9:39 pm

    You might modify your logic to do something like:

    • if space or period, jump to write
    • fold lowercase to uppercase
    • if not uppercase letter, jump back to read

    Note that the “fold lowercase to uppercase” doesn’t need to check to see whether the input was a letter first. Just and xx where xx is an appropriate value should do it (I’ll let you work out the value). This step will also modify characters other than letters, but since the next step is to check for a letter it doesn’t matter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an assignment that asks me to retrieve delimited text from form values.
I have an assignment that converts dates from one calendar system to another. The
Because anything from C++ and beyond have nice constructs that handles a stack like
I have an assignment that wants me to write an ternary search algorithm and
I have an assignment that simulates a dice game. As part of the program,
I have quite a large XSL document for an assignment that does a number
My assignment requires that I have an ER diagram that shows the dependencies between
For a school assignment I have to create a C++ program that will create
For an assignment in college, we have to make a script in Perl that
I have an assignment that requires us to implement a doubly linked list class.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.