Q1. Convert Upper to Capitalize.

Write an Assembly Code to Changing Uppercase to Lower Case Expect the First Character of each Word of the String Statement1 ‘FACULTY of COMPUTER & ARTIFCIAL INTELLIGENCE’, using Simplified segment Directive & Conventional Segment Directive.

Where: ASCII Code “Space Bar” = 00100000 (Decimal 32) = 20H ASCII Code ‘a’ = 01100001B (Decimal 97) = 61H, ASCII Code ‘z’ = 01111000B (decimal 122) = 78H, ASCII Code ‘A’ = 01000001B (65 Decimal) = 41H, ASCII Code ‘Z’ = 01100000B (Decimal 96) = 60H,

Conventional

PAGE 60, 132
TITLE: Assembly program to Convert Alphabetic Character

; -----------------------------------------------------------------------
S1 SEGMENT PARA STACK 'Stack'
    DW 32 DUP (0)
S1 ENDS
; -----------------------------------------------------------------------

D1 SEGMENT PARA 'Data'
    Statment1 DB 'FACULTY of COMPUTER & ARTIFICIAL INTELLIGENCE', '$'
    ; Statement1 is 45 Characters
D1 ENDS
; -----------------------------------------------------------------------

C1 SEGMENT PARA 'Code'
    P1 PROC FAR
        ASSUME SS:S1, DS:D1, CS:C1 ; Adjust the Address of each Segments

        MOV AX, D1                ; Load Memory Data Address in AX
        MOV DS, AX                ; Move AX to Data Address Register DS
        LEA BX, Statement1        ; LOAD EFFECTIVE ADDRESS of Second Character
        MOV CX, 44                ; 44 IS NO. OF CHARACTER IN UPSTR

    LAB1:
        MOV AL, [BX]              ; MOVE CHARACTER from Statement1 to AL
        CMP AL, 20H               ; Space Bar ASCII Code
        JE LAB22
        CMP AL, 41H               ; COMPARE CHAR WITH ASCII 41H
        JB LAB2                   ; JUMP TO LABEL LAB2 IF CH < 41H
        CMP AL, 5AH               ; COMPARE CHAR WITH ASCII 5AH
        JA LAB2                   ; JUMP TO LABEL LAB2 IF CH > 5AH
        XOR AL, 00100000B
        MOV [BX], AL

    LAB22:
        INC BX                    ; Escape Space Bare
        INC BX                    ; Escape First Character of word
				DEC CX
				DEC CX
        JMP LAB1                  ; Continue with Other Character

    LAB2:
        INC BX                    ; SET TO NEXT CHARACTER OF Statement1
        DEC CX
        JNZ LAB1                  ; LOOP TO LABEL LAB1 if CX not = Zero

        MOV AX, 4C00H              ; CODE OF END Processing
        INT 21H                    ; INTERRUPT PROCESSING

    P1 ENDP                        ; END PROCEDURE
C1 ENDS                            ; END SEGMENT CODE
END

Simplified

PAGE 60, 132
TITLE: Assembly program to Convert Alphabetic Character

; -----------------------------------------------------------------------------------
.MODEL SMALL ; Program Size <= 64 KB
.STACK 64
; -----------------------------------------------------------------------------------

.DATA
    Statment1 DB 'FACULTY of COMPUTER & ARTIFICIAL INTELLIGENCE', '$'
    ; Statement1 is 45 Characters

; -----------------------------------------------------------------------------------

.CODE
    M1 PROC FAR ; PROC M1
        MOV AX, @data    ; Load Memory Data Address in AX
        MOV DS, AX       ; Move AX to Data Address Register DS
        LEA BX, Statement1 ; LOAD EFFECTIVE ADDRESS of Second Character
        MOV CX, 44       ; 44 IS NO. OF CHARACTER IN UPSTR

    LAB1:
        MOV AL, [BX]     ; MOVE CHARACTER from Statement1 to AL
        CMP AL, 20H      ; Space Bar Code
        JE LAB22
        CMP AL, 41H      ; COMPARE CHAR WITH ASCII 41H
        JB LAB2          ; JUMP TO LABEL LAB2 IF CH < 41H
        CMP AL, 5AH      ; COMPARE CHAR WITH ASCII 5AH
        JA LAB2          ; JUMP TO LABEL LAB2 IF CH > 5AH
        XOR AL, 00100000B
        MOV [BX], AL

    LAB22:
        INC BX           ; Escape Space Bare
        INC BX           ; Escape First Character of word
				DEC CX
				DEC CX
        JMP LAB1         ; Continue with Other Character

    LAB2:
        INC BX           ; SET TO NEXT CHARACTER OF Statement1
        DEC CX
        JNZ LAB1         ; LOOP TO LABEL LAB1 if CX not = Zero

        MOV AX, 4C00H    ; CODE OF END Processing
        INT 21H          ; INTERRUPT PROCESSING

    ENDP M1 ; END PROC M1

END

Q2. Convert Upper to Lower.

Write an Assembly Code to Changing Uppercase to Lower Case of the String Statement1 ‘FACULTY OF COMPUTER & AI’, using Simplified segment Directive & Conventional Segment Directive.

Where: ASCII Code “Space Bar” = 00100000 (Decimal 32) = 20H ASCII Code ‘a’ = 01100001B (Decimal 97) = 61H, ASCII Code ‘z’ = 01111000B (decimal 122) = 78H, ASCII Code ‘A’ = 01000001B (65 Decimal) = 41H, ASCII Code ‘Z’ = 01100000B (Decimal 96) = 60H,

Conventional

Page 60,132
Title Program to change from upper case to lower case
;-----------------------------------------------------------------------
S1 SEGMENT PARA STACK 'Stack'
    DW 32 DUP (0)
S1 ENDS
;--------------------------------------
D1 SEGMENT PARA 'Data'
    UPSTR DB 'FACULTY OF COMPUTER & AI','$'
D1 ENDS
;--------------------------------------
C1 SEGMENT PARA 'Code'
    MAIN PROC FAR
        ASSUME SS:S1, DS:D1, CS:C1
        MOV AX, D1
        MOV DS, AX
        LEA BX, UPSTR
        MOV CX, 24
    LOOP1:
        MOV AL, [BX]
        CMP AL, 'A'
        JB LOOP2
        CMP AL, 'Z'
        JA LOOP2
        ADD AL, 32 ; Convert to lowercase
        MOV [BX], AL
    LOOP2:
        INC BX
        DEC CX
        JNZ LOOP1
        ; Output the string loaded in DX
        LEA DX, UPSTR
        MOV AH, 09H
        INT 21H
        ; Interrupt to exit
        MOV AH, 4CH
        INT 21H
    END MAIN
C1 ENDS
END

Simplified

Page 60,132
Title Program to change from upper case to lower case
;----------------------------------------------------
.MODEL SMALL
.STACK 64
; -----------------------------------------------------------------------------------
.DATA
    UPSTR DB 'FACULTY OF COMPUTER & AI','$'
; -----------------------------------------------------------------------------------
.CODE
    MAIN PROC FAR
        MOV AX, @data
        MOV DS, AX
        LEA BX, UPSTR
        MOV CX, 24
    LOOP1:
        MOV AL, [BX]
        CMP AL, 'A'
        JB LOOP2
        CMP AL, 'Z'
        JA LOOP2
        ADD AL, 32 ; Convert to lowercase
        MOV [BX], AL
    LOOP2:
        INC BX
        DEC CX
        JNZ LOOP1
        ; Output the string loaded in DX
        LEA DX, UPSTR
        MOV AH, 09H
        INT 21H
        ; Interrupt to exit
        MOV AH, 4CH
        INT 21H
    END MAIN
END

Q3. get Sum & Avg. from 1 to N