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 6646811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:27:47+00:00 2026-05-26T00:27:47+00:00

So this program was for an assignment. The due date passed and I turned

  • 0

So this program was for an assignment. The due date passed and I turned in what I had and got a good grade, but this bug has been bothering me. It’s not technically an assignment anymore, but I’d still prefer if you didn’t write code for me, since I want to understand why this is happening, not necessarily to fix it.

So the program works fine (it’s essentially toUpper() in Assembly), but after I pass the program the terminating character (a period), the program calls ‘end’ successfully, but then never actually terminates. If I run it in a step-by-step debugger, the ‘end main’ is called, then the program jumsp to some prewritten code I don’t recognize, could be cleaning the stack, calling DOS, I’ve no idea. I’ve tried lots of different things (all without success), and I’m curious if anyone has an insight on what could be causing this.

Code below:

;---------------------------------------------------------------------
;    program:     Key
;    function:    Reads in specific characters from input and displays them.
;    owner:       ----------
;    date:        9/29/11
;    09/22/2011   Original Version
;----------------------
    .model small
    .8086
;----------------------
    .data              ; Start the data segment
;----------------------
    ; No variables

;----------------------
    .code              ; Start the code segment
;----------------------
main:                  ; Reading in values
    mov ah, 8h         ; Request input without echo
    int 21h            ; Read character into al

    cmp al, 20h        ; Is it a space?
    je  print          ; If so, print with no changes
    cmp al, 2Eh        ; Is it a period?
    je  print          ; If so, go to exit.
    cmp al, 41h        ; Is it below the floor of uppercase?
    jl  main           ; Then it's useless, throw it out and read in new.
    cmp al, 7Ah        ; Is it above lower ceiling?
    jg  main           ; Then it's useless, throw it out and read in new.
    cmp al, 5Ah        ; Is it smaller than upper ceiling?
    jle print          ; If it's equal or smaller, then it's an upper.
    cmp al, 61h        ; Is it above lower floor?
    jl  main           ; If it is lower, back to main.
                       ; If we're here it's a lowercase letter
    sub al, 20h        ; Subtract 20h to make lowercase

print:                 ; Print characters
    mov dl, al         ; Copy character to output register
    mov ah, 2h         ; Load character output subroutine
    int 21h            ; Print character
    cmp dl, 2Eh        ; Check if it was a period.
    jne main           ; If not a period, go to main.

    mov ah, 4Ch        ; Place Exit Code for DOS service
    int 21h            ; call DOS service
    end main           ; If it was a period, exit program.
;----------------------

The 2 lines before the end were suggested by a frind of mine who’s more experience with assembler than I am, and it makes the program terminate correctly on my DOS emulator, but the issue with ‘end’ still occurs in the debugger and my professor testing script.

Anyone have any idea what could be causing this?

  • 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-26T00:27:47+00:00Added an answer on May 26, 2026 at 12:27 am

    When you call DOS for exit, al contains the exit code (or error level). Try mov ax, 4c00h instead of mov ah, 4ch. This way the error code will be 0 (means everything’s ok). This makes it work because the return code is used somehow by the DOS statement IF ERRORLEVEL ... which screws everything up. 😉

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

Sidebar

Related Questions

This program I use has it's own variables to set when you run it,
This is for a homework assignment, so I don't want the exact code, but
Disclaimer: This is for a homework assignment, but the question is not regarding the
I get this error whenever i run the program Assignment makes pointer from Integer
My class assignment is to write a program that has the user input a
This was a 2 part assignment. first I had to figure out how to
I'm writing a program for a homework assignment. The program compiles and runs, but
I'm almost done with this program, but something's not right in main . Here
This assignment requires me to develop a MPI program for the parallel Odd-Even sort
This program is in response to the assignment: Create a method named Sum() that

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.