CSE 506

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

CSE 506 Lab 6

Practise #1 (Example 6.4)
If AX contains a negative number, put -1 In BX; if AX contains 0, put O In BX; if AX contains a positive number, put 1 In BX.·

mov ax,0FFFBh
 CMP AX,0
 JL NEGATIVE
 JE ZERO
 JG POSITIVE
 NEGATIVE:
 MOV BX,-1
 JMP END_CASE
 ZERO:
 MOV BX,0
 JMP END_CASEPOSITIVE:
 MOV BX,1
 JMP END_CASE
 END_CASE:
 MOV AX,4CH
 INT 21h
 MAIN ENDP
 END MAIN

Practise #2 (example 6.5)
If AL contains I or 3, display “o”; if AL contains 2 or 4, Display “e”.

CMP AL,1
 JE ODD
 CMP AL,3
 JE ODD
 CMP AL,2
 JE EVEN
 CMP AL,4
 JE EVEN
 ODD:
 MOV DL,'o'
 JMP DISPLAY
 EVEN:
 MOV DL,'e'
 JMP DISPLAY:
 DISPLAY:
 MOV AH,2
 INT 21h

Practise #3 (example 6.6)
Read a character and if it is uppercase display it

 MOV AH,1
 INT 21H
 CMP AL,'A'
 JNGE NOT
 CMP AL,'Z'
 JNLE NOT
 MOV DL,AL
 MOV AH,2
 INT 21h
 NOT:

 

Practise #4 (example 6.7)
Read a character. If it’s “y” or “Y”, display it; otherwise, terminate the program.

MOV AH,1
 INT 21H
 CMP AL,'y'
 JE THEN
 CMP AL,'Y'
 JE THEN
 JMP ELSE
 THEN:
 MOV AH,2
 MOV DL,AL
 INT 21H
 JMP EXIT
 ELSE:
 JMP EXIT
 EXIT:

 

Practise #5 (Example 6.9)
Write some code to count the number of characters In a input line.

MOV DX,0
 MOV AH,l
 INT 21H
 WHILE:
 CMP ·AL, OOH ;CR?
 JE END_WHILE ;yes, exit
 INC DX ;not CR, increment count
 INT 21H ;read a character
 JMP WHILE ;loop back;
 END_WHILE:

 

Problem #1
Write a program to display a “?”, read two capital letters, and dis-play them on the next line In alphabetical order.

Practise #6 (Example 6.10)
Write some code to read characters until a blank is read.

MOV AH,l
 repeat:
 INT 21H
 CMP AL,' '
 JNE REPEAT

Hometask
Marut section 6.5

 

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

CSE 506 Lab 5

Practise #1 (Eg 6.1)

Write a code to find the greater signed number of the numbers stored in AX and BX

ABC:
mov ah, 1
int 21h
mov bl, al

int 21h
mov bh, al

cmp bl, bh
jG point1
jl point2

point1:
mov ah, 2
mov dl, '>'
int 21h
jmp ABC

point2:
mov ah, 2
mov dl, '<'
int 21h

jmp ABC

Practise #2
Print 80 star using condition

mov cx, 80
point1:
mov ah, 2
mov dl, '*'
int 21h
dec cx
jnz point1

Problem #1
Print 10*10 box with star (*) without using string and using conditions

Practise #3 (eg 6.2)
Replace a number with absolute number

mov ax,0FFFBh

cmp ax, 0
jnl point1
neg ax

point1:

Practise #4 (eg 6.3)
Suppose AL and BL contain extended ASCII characters. Display the one that comes first in the character sequence.

MOV AH,2
CMP AL,BL
JNBE NOT_AL
MOV DL,AL
JMP DISPLAY
NOT_AL:
MOV DL,BL
JMP DISPLAY
DISPLAY:
INT 21h

 

CSE 506 Lab 4

Problem #1
Write· a program to read one of the hex digits A-F, and display it on the next line in decimal.
Sample execution:

ENTER A HEX DIGIT: C 
IN DECIMAL IT IS 12

Problem #2
Write a program to display a 10 x 10 solid box of asterisks.
Hint: declare a string in the data segment that specifies the box, and display it with INT 2lh, function 9h.

 

Problem #3
Write a program to (a) display”?”, (b) read three initials,(c) display them in the middle of an 11 x 11 box of asterisks

Submit the lab codes using this link

CSE 506 Lab 3

Problem #1

Write an assembly code that will take a lowercase character input and convert it to uppercase

The code is as follows

TITLE Lower_letter_to_upper
.MODEL SMALL
.STACK 100H
.DATA
 CR EQU 0DH
 LF EQU 0AH
 MSG1 DB 'Enter the letter in lower case : $'
 MSG2 DB 0DH,0AH,'In upper case is: '
 CHAR DB ?,'$'
.CODE
MAIN PROC
 MOV AX,@DATA 
 MOV DS,AX
 
 
 LEA DX,MSG1
 MOV AH, 9
 INT 21h
 
 MOV AH,1
 INT 21h
 SUB AL,20H
 MOV CHAR,AL
 
 LEA DX,MSG2
 MOV AH,9
 INT 21h
 
 MOV AH,4CH
 INT 21H

MAIN ENDP
 END MAIN

The main segment operating the code is

 MOV AH,1
 INT 21h
 SUB AL,20H
 MOV dl,AL
 mov ah, 2
 int 21h

Problem #2

Write a program to (a) display a “?”, (b) read two decimal digits whose sum is less than 10, (c) display them and their sum on the next line, with an appropriate message.

Sample execution: 
?27 
THE SUM OF 2 AND 7 IS 9

Problem #3
Write a program to (a) prompt the user, (b) read first, middle, and last initials of a person’s name, and (c) display them duwn the left margin.
Sample execution:

ENTER THREE INITIALS: JFK 
J 
F
K

 

Submit Assignment 2 through this link

CSE 506 LAB 2

Assembly Code to print a string

.MODEL SMALL 
.STACK 100H
.DATA ;
CR EQU 0DH ;
LF EQU 0AH ;

MSG db CR, LF, 'Hello: $'

.CODE ;
MAIN PROC ;MAIN PROCEDURE ; CODE SEGMENT
 MOV AX,@DATA ;
 MOV DS, AX ;
 
LEA DX, MSG ;Print hello
mov ah,9
int 21h

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

END MAIN

Problem #1

Write an assembly code to print 2 different string that will be stored in 2 different variable.

Problem #2

Write an assembly code to take 3 input and print them right away.

Problem #3

Write an assembly code to take 4 inputs and print them after taking all the inputs.

example

a b c d <-- 4 inputs taken
abcd   <-- Prints

Practice #1

Practice Marut code example 4.2  for next class.