×
Samples Blogs Make Payment About Us Reviews 4.9/5 Order Now

Input A Character And Display It In Upper And Lower Case, And The Ascii Code In Hex And Decimal In Pep9 Assembly Language Assignment Solution

July 02, 2024
Rehana Magnus
Rehana Magnus
🇨🇦 Canada
Assembly Language
Rehana Magnus, PhD in Computer Science from the esteemed Acadia Institute of Technology, Canada. With 6 years of experience, specializes in assembly language programming. Proficient in low-level coding, optimizing performance, and enhancing system functionality.
Key Topics
  • Instructions
  • Requirements and Specifications
Tip of the day
Familiarize yourself with OCaml's pattern matching; it simplifies handling recursive data structures like lists and trees, making your code concise and easier to debug.
News
In 2024, Girls Who Code introduced a Data Science + AI track in their free summer programs for high school students, fostering skills in cybersecurity and creative coding​

Instructions

Objective
Write a program that allows users to type a character and display it in upper and lower case, and the ascii code in hex and decimal in Pep9 assembly language.

Requirements and Specifications

Write the following program using Pep9 using Assembly Language
  1. First load the value FFFF in the A register.
  2. Save the value in A to memory and display the value using decimal out. ( This should display a -1 then an LF )
  3. Next, get a character from the user using character input. For simplicity, we will assume that the user types in a lower case alpha character.
  4. Display the following properties of the character: Original Character then LF Character as Uppercase then LF Decimal ASCII value of the Character then LF Decimal ASCII value of the Uppercase Letter then LF Hex value of the original lowercase letter then LF Other requirements for this program: Put the data section in low memory and Branch around it. Use the A register. DO NOT use the X register Print a LF after each output. This program should work for any lowercase letter submitted by the user. This program should work running it several times changing the input. That is, it should not work only the first time you run it. Run it a couple of times changing the input each time Deliverables: Turn in the following electronically: file with your assembly code with the pep extension: eg. prog1.pep Hints: When you save the assembly code, it saves a .pep file. You may need to load and store 1 and 2 byte values using Load/Store and LoadByte and StoreByte. Remember to put a stop instruction at the end of your program to complete the assembly language assignment. Remember that you are to work individually on your programs. You should not discuss your ideas and algorithms with other people. Sample input/output: Input: j Output: -1 j J 106 74 006A *Note that this program should work for any lowercase input. (Not just lower case j)
Screenshots of output
input character display in upper lower case ascii code in hex decimal in Pep9 using assembly language
input character display in upper lower case ascii code in hex decimal in Pep9 using assembly language 1
Source Code
               BR start ; branch to start of program
number: .WORD 0 ; place to save number
lletter: .BYTE 0 ; place to save lower case letter
uletter: .BYTE 0 ; place to save upper case letter
start: LDWA 0xFFFF,i ; Load the value FFFF in the A register.
                STWA number,d ; save the number in A in memory
                DECO number,d ; display the value using decimal out
                LDBA 0xA,i ; load LF char
                STBA charOut,d ; display LF to change line
                LDBA charIn,d ; Read a character
                STBA lletter,d ; save character in memory
                SUBA 32,i ; convert letter to uppercase by subtracting 32
                STBA uletter,d ; save character in memory
                LDBA lletter,d ; load original character from memory
                STBA charOut,d ; display original char
                LDBA 0xA,i ; load LF char
                STBA charOut,d ; display LF to change line
                LDBA uletter,d ; load uppercase character from memory
                STBA charOut,d ; display uppercase char
                LDBA 0xA,i ; load LF char
                STBA charOut,d ; display LF to change line
                ANDA 0,i ; clear A to zero
                LDBA lletter,d ; load lowercase character from memory
                STWA number,d ; save the value as a 2 byte number
                DECO number,d ; display lowercase ASCII value
                LDBA 0xA,i ; load LF char
                STBA charOut,d ; display LF to change line
                LDBA uletter,d ; load uppercase character from memory
                STWA number,d ; save the value as a 2 byte number
                DECO number,d ; display uppercase ASCII value
                LDBA 0xA,i ; load LF char
                STBA charOut,d ; display LF to change line
                LDBA lletter,d ; load lowercase character from memory
                STWA number,d ; save the value as a 2 byte number
                HEXO number,d ; display lowercase char hex value
                LDBA 0xA,i ; load LF char
                STBA charOut,d ; display LF to change line
                STOP ; End the program
                .END

Related Samples

Explore our Assembly Language Assignment Samples for precise solutions to low-level programming challenges. Covering concepts such as registers, memory management, and bitwise operations, these examples offer clear explanations and practical implementations. Perfect for students aiming to master assembly language programming and excel in their coursework with structured, educational content.