Providing Services to
World Wide

Mail Us
khizarshahal3@gmail.com

Contact Us
+92 3472506073

Blog Post Details

Home / Free Services / Blog Posts / Blog Post Details

CS401P Assignment # 02 Spring 2026

June 24, 2026

Copy Paste this Code & Enjoy Your Life

Share, Like & Subscribe KST Learning Thank You

Code Examples

Assembly Language
[org 0x0100]

jmp start

OriginalString  db 'virtual university'
StringSize      equ $ - OriginalString

UppercaseString times StringSize db 0
ReversedString  times StringSize db 0

StringLength    dw 0
SpaceCount      dw 0

TitleMsg        db 'STRING PROCESSING UTILITY'
TitleLength     equ $ - TitleMsg

start:
    mov ax, cs
    mov ds, ax

    call ClearScreen

    mov ax, SpaceCount
    push ax

    mov ax, StringLength
    push ax

    mov ax, StringSize
    push ax

    mov ax, UppercaseString
    push ax

    mov ax, OriginalString
    push ax

    call ConvertToUpper

    mov ax, StringSize
    push ax

    mov ax, ReversedString
    push ax

    mov ax, UppercaseString
    push ax

    call ReverseString


    mov ax, 0Fh
    push ax

    mov ax, 25
    push ax

    mov ax, 2
    push ax

    mov ax, TitleLength
    push ax

    mov ax, TitleMsg
    push ax

    call PrintString

    mov ax, 07h
    push ax

    mov ax, 20
    push ax

    mov ax, 5
    push ax

    mov ax, StringSize
    push ax

    mov ax, OriginalString
    push ax

    call PrintString

    mov ax, 07h
    push ax

    mov ax, 20
    push ax

    mov ax, 7
    push ax

    mov ax, StringSize
    push ax

    mov ax, UppercaseString
    push ax

    call PrintString


    mov ax, 07h
    push ax

    mov ax, 20
    push ax

    mov ax, 9
    push ax

    mov ax, StringSize
    push ax

    mov ax, ReversedString
    push ax

    call PrintString

    mov ax, 4C00h
    int 21h

ClearScreen:
    push ax
    push cx
    push di
    push es

    mov ax, 0B800h
    mov es, ax

    xor di, di
    mov ax, 0720h          
    mov cx, 2000           

    cld
    rep stosw              

    pop es
    pop di
    pop cx
    pop ax
    ret

ConvertToUpper:
    push bp
    mov bp, sp
    sub sp, 2

    push ax
    push bx
    push cx
    push si
    push di
    push es

    mov ax, ds
    mov es, ax

    mov si, [bp+4]
    mov di, [bp+6]
    mov cx, [bp+8]

    mov word [bp-2], 0

    mov bx, [bp+10]
    mov ax, cx
    mov [bx], ax

    cld

ConvertLoop:
    lodsb

    cmp al, ' '
    jne CheckLowercase

    inc word [bp-2]
    jmp StoreCharacter

CheckLowercase:
    cmp al, 'a'
    jb StoreCharacter

    cmp al, 'z'
    ja StoreCharacter

    sub al, 20h

StoreCharacter:
    stosb

    loop ConvertLoop

    mov bx, [bp+12]
    mov ax, [bp-2]
    mov [bx], ax

    pop es
    pop di
    pop si
    pop cx
    pop bx
    pop ax

    mov sp, bp
    pop bp
    ret 10

ReverseString:
    push bp
    mov bp, sp
    sub sp, 2

    push ax
    push si
    push di
    push es

    mov ax, ds
    mov es, ax

    mov si, [bp+4]
    mov di, [bp+6]
    mov ax, [bp+8]

    mov [bp-2], ax

    add si, ax
    dec si

ReverseLoop:
    cmp word [bp-2], 0
    je ReverseDone

    std
    lodsb

    cld
    stosb

    dec word [bp-2]
    jmp ReverseLoop

ReverseDone:
    cld

    pop es
    pop di
    pop si
    pop ax

    mov sp, bp
    pop bp
    ret 6

PrintString:
    push bp
    mov bp, sp

    push ax
    push bx
    push cx
    push si
    push di
    push es

    mov ax, 0B800h
    mov es, ax

    mov ax, [bp+8]
    mov bx, 80
    mul bx

    add ax, [bp+10]
    shl ax, 1

    mov di, ax

    mov si, [bp+4]
    mov cx, [bp+6]
    mov ah, [bp+12]

    cld

PrintLoop:
    lodsb
    stosw
    loop PrintLoop

    pop es
    pop di
    pop si
    pop cx
    pop bx
    pop ax

    pop bp
    ret 10