CSE 505 Lab 7

CSE 505 Lab 7

Practise #1 (Section 6.5)
Write a code to take a string input and print the first and last capital letters in the string in alphabatical order

//code 
TITLE First and last capitals
.MODEL SMALL ; DIRECTIVE
.STACK 100H
.DATA ;
CR EQU 0DH ;
LF EQU 0AH ;
;A DW 2 ; DATA SEGMENT
;B DW 5 ;
;SUM DW ? ;
msg db 'Type a line of text',cr,lf,'$'
msg_nocap db cr,lf,'There is no capital$'
cap_msg db cr,lf, 'First Capital = '
first db ']' 
 db ' Last Capital = '
last db '@$'

.CODE ;
MAIN PROC ;MAIN PROCEDURE ; CODE SEGMENT
 MOV AX,@DATA ;
 MOV DS, AX ;

mov ah, 9
 lea dx, msg
 int 21h
 



 MOV AH, 1
 INT 21h
while: 
 cmp al, cr
 je end_while
 
;STaring of if statement
;if
 cmp al,'A'
 jnge end_if 
 cmp al, 'Z'
 jnle end_if
;then 
 cmp al, first
 jnl check_last
 mov first, al 
 
check_last: 
 cmp al, last
 jng end_if
 mov last,al


end_if:


 int 21h
 jmp while
end_while:

mov ah, 9 
 
 cmp first,']'
 jne cap
 
 lea dx, msg_nocap
 jmp display 
 
cap: 
 lea dx, cap_msg

display:
 
 int 21h


;Exit code 
 MOV AH, 4CH 
 INT 21H
 MAIN ENDP
END MAIN

 

Problem #1
Write a code to take a string input and print the first and last capital letters in the string as appeared in the string

Example
input:
Hello this is a test A
output:
First capital = H Last capital = A

Problem #2

Dispay the extended ascii characters from 80h to FFh with only 10 ascii characters per line with a space between each characters.

 

Hometask and assignement

Marut chapter 6 practice problem 9,10,11

Submit Assignment 4[Lab 6 and 7] through this link

Leave a Reply

Your email address will not be published. Required fields are marked *