Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

CLP 02.2 Course Title: Microprocessors & Microcontrollers Lab

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

CLP 02.

2
Course Title: Microprocessors &
Microcontrollers Lab
Course Code: CSE 304

Submitted by:
Name: SHAKILISLAM
ID: 191902016
Batch & Section: 191
Department of CSE
Green University of Bangladesh

Submitted to:
Md. Sultanul Islam Ovi
Lecturer
Department of CSE
Green University of Bangladesh

Date of Submission: 00-00-0000

1
Class Work
TASK 01

Problem

Solution
ORG 100h

.DATA
PROMPT_1 DB 'Enter Integer Numbers: ', '$'
PROMPT_2 DB 0Dh, 0Ah, 'NUMBER IS ODD Digits: ', '$'
PROMPT_3 DB 0Dh, 0Ah, 'NUMBER IS EVEN Digits: ', '$'
ARRAY DB 10 DUP(0)

.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX

MOV AH, 9
LEA DX, PROMPT_1
INT 21H

MOV CX, 1 ; because we will input 6 integers


LEA SI, ARRAY

INPUTS:
MOV AH, 1
INT 21h

MOV [SI], AL ; Load the inputs in array one by one


INC SI

MOV AH, 2
MOV DX, ' '
INT 21h
LOOP INPUTS

CALL Odd_Numbers
CALL Even_Numbers

MAIN ENDP

Odd_Numbers PROC

MOV AH, 9
LEA DX, PROMPT_2

2
INT 21H

MOV CX, 1
LEA SI, ARRAY

Loop_1:
XOR AX, AX
MOV AL, [SI]
SUB AL, 48

MOV BL, 2 ; compare the integer with all elements


of the one by one
DIV BL

CMP AH, 1
JE Print1
JL noPrint1

Print1:
MOV AH, 2
MOV DX, [SI]
INT 21h

MOV DX, ' '


INT 21h

noPrint1:
INC SI
LOOP Loop_1

Odd_Numbers ENDP

Even_Numbers PROC

MOV AH, 9
LEA DX, PROMPT_3
INT 21H

MOV CX, 6
LEA SI, ARRAY

Loop_2:
XOR AX, AX
MOV AL, [SI]
SUB AL, 48

MOV BL, 2 ; compare the integer with all elements


of the one by one
DIV BL

3
CMP AH, 0
JE Print2
JG noPrint2

Print2:
MOV AH, 2
MOV DX, [SI]
INT 21h

MOV DX, ' '


INT 21h

noPrint2:
INC SI
LOOP Loop_2

Even_Numbers ENDP

END MAIN
RET

Screenshot

TASK 2.

.MODEL SMALL
.STACK 100H

.DATA

4
PROMPT DB 'The 256 ASCII Characters are : $'

.CODE
MAIN PROC
MOV AX, @DATA ; initialize DS
MOV DS, AX

LEA DX, PROMPT ; load and print PROMPT


MOV AH, 9
INT 21H

MOV CX, 256 ; initialize CX

MOV AH, 2 ; set output function


MOV DL, 0 ; initialize DL with first ASCII character

@LOOP: ; loop label


INT 21H ; print ASCII character

INC DL ; increment DL to next ASCII character


DEC CX ; decrement CX
JNZ @LOOP ; jump to label @LOOP if CX is 0

MOV AH, 4CH ; return control to DOS


INT 21H
MAIN ENDP
END MAIN

SCREENSHOT:

5
4.

PROMPT is a variable name.

DB Mean "db" (data byte) to allocate some space, and fill it with a string.

Output: The output of the assembler program is the object deck, a machine language
translation of the source program

0Dh, 0Ah, '$'

oah is for line feed (moves to next output line) & odh is for carriage return. $ : It’s the
‘$’, which in most languages is just a dollar sign. But for whatever crazy reason, CP/M
used ‘$’ as a string terminator for messages printed with that API.

You might also like