Skip to content

KPlanisphere/Uppercase-to-Lowercase-Converter-in-Assembly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Uppercase to Lowercase Converter in Assembly

This repository contains an assembly language project that converts a user-input string from uppercase to lowercase. The program sets up the screen, takes input from the user, processes the string, and displays the original and modified strings.

Features

  • Screen Initialization: Clears the screen and sets up text attributes.
  • User Input: Reads a string from the user.
  • Case Conversion: Converts uppercase letters to lowercase.
  • String Display: Shows the original and modified strings on the screen.

Code Snippets

Screen Initialization

The program sets the screen background to black and text color to green, then positions the cursor.

; Clear screen
MOV AH, 06H   ; Scroll window up
MOV AL, 00H   ; Clear entire window
MOV BH, 00AH  ; Background black, text green
MOV CX, 00H   ; Starting position
MOV DH, 24    ; Ending row
MOV DL, 79    ; Ending column
INT 10H 

; Position cursor
MOV AH, 02H   ; Set cursor position
MOV BH, 0     ; Current page
MOV DH, 1     ; Row 1
MOV DL, 0     ; Column 0
INT 10H

User Input and Case Conversion

The program reads characters from the user, converts uppercase letters to lowercase, and stores the result.

; Read input string
LEA SI, MSG   ; Load address of MSG into SI

OTRO:
MOV AH, 1     ; Read character
INT 21H
CMP AL, 0DH   ; Check for Enter key
JE FIN        ; Jump to FIN if Enter is pressed

; Convert uppercase to lowercase
CMP AL, 20H   ; Check for space
JE SIGUIENTE
CMP AL, 5AH   ; Check if character is 'Z'
JG MINUSCULA
ADD AL, 20H   ; Convert to lowercase
JMP SIGUIENTE

MINUSCULA:
SUB AL, 20H   ; Convert to uppercase

SIGUIENTE:
MOV [SI], AL  ; Store character in MSG
INC SI

JMP OTRO

FIN:

Display Strings

The program displays the original and modified strings on the screen.

; Display "ORIGINAL"
LEA DX, MSG2
MOV AH, 9
INT 21H

; Position cursor
MOV AH, 02H
MOV BH, 0
MOV DH, 3
MOV DL, 0
INT 10H

; Display "MODIFICADO"
LEA DX, MSG3
MOV AH, 9
INT 21H

; Display modified string
LEA DX, MSG
MOV AH, 9
INT 21H

Usage

  1. Assemble and link the code using an assembler (e.g., TASM, MASM).
  2. Run the executable.
  3. Input a string when prompted.
  4. The program will display the original and modified strings on the screen.

Memory Variables

  • MSG: Stores the user-input string.
  • MSG2: String "ORIGINAL: ".
  • MSG3: String "MODIFICADO: ".