0% found this document useful (0 votes)
2 views

Computer_architecture_lab

The lab manual provides an introduction to Assembly language programming, including various types of registers and assemblers. It contains multiple programming assignments, such as printing 'Hello World', performing arithmetic operations, string concatenation, and reversing a string. Additionally, it includes detailed instructions on data transfer, arithmetic, bit manipulation, and flow control instructions in Assembly language.

Uploaded by

ritikraushanrau
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Computer_architecture_lab

The lab manual provides an introduction to Assembly language programming, including various types of registers and assemblers. It contains multiple programming assignments, such as printing 'Hello World', performing arithmetic operations, string concatenation, and reversing a string. Additionally, it includes detailed instructions on data transfer, arithmetic, bit manipulation, and flow control instructions in Assembly language.

Uploaded by

ritikraushanrau
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

LAB MANUAL

Lab Assignment

1. Introduction to Assembly language programming.


2. Introduction to various types of registers used in programming.
3. Introduction to various Assemblers used in assembling the Assembly language programs.
4. Write a program to print “Hello World” in Assembly Language.
5. Write a program in Assembly Language to show the sum of two numbers.
6. Write a program in Assembly Language to concatenation of two strings.
7. Write a program in Assembly Language to find the reverse of a string.

8. Write a program in Assembly Language to store five numbers in array and display it.

1 GoutamSanyal , Asstant Professor , CA/IT., YSM


LAB MANUAL

8086 Microprocessor and Assembly


LanguageProgramming

AH AL
BH BL
CH CL
DH DL

Registers

Category Bits Register Names


General 16 AX, BX, CX, DX
8 AH, AL, BH, BL, CH, CL, DH, DL
Pointer 16 SP (stack pointer), BP (base pointer)
Index 16 SI (source index), DI (destination index)
Segment 16 CS (code segment), DS (data segment)
SS (stack segment), ES (extra segment)
Instruction 16 IP (instruction pointer)
Flag 16 FR (flag register)

2 GoutamSanyal , Asstant Professor , CA/IT., YSM


LAB MANUAL

Data transfer instructions


Transfer information between registers and memory locations or I/O ports. MOV,
XCHG, LEA, PUSH, POP, PUSHF, POPF, IN, OUT.
Arithmetic instructions
Perform arithmetic operations on binary or binary-coded-decimal (BCD) numbers. ADD, SUB, INC,
DEC, ADC, SBB, NEG, CMP, MUL, IMUL, DIV, IDIV, CBW, CWD.
Bit manipulation instructions
Perform shift, rotate, and logical operations on memory locations and registers.SHL, SHR,
SAR, ROL, ROR, RCL, RCR, NOT, AND, OR, XOR, TEST.
Flow Control Instructions
Signed jumps
• JG/JNLE jump if greater than, or jump if not less than or equal
• JGE/JNL jump if greater than or equal, or jump if not less than
• JL/JNGE jump if less than, or jump if not greater than or equal
• JLE/JNG jump if less than or equal, or jump if not greater than
Unsigned jumps
• JA/JNBE jump if above, or jump if not below or equal
• JAE/JNB jump if above or equal, or jump if not below
• JB/JNAE jump if below, or jump if not above or equal
• JBE/JNA jump if below or equal, or jump if not above
□ Single-Flag jumps

• JE/JZ jump if equal, or jump if equal to zero


• JNE/JNZ jump if not equal, or jump if not equal to zero
• JC jump of carry
• JNC jump if no carry
• JO jump if overflow
• JNO jump if no overflow
Using C/C++ Editor
PROGRAM 1
// ASSSEMBLY LANGUAGE PROGRAM ARITHMATICAL OPERATION
#include<stdio.h>
#include<conio.h> int main()
{
clrscr();
asm MOV AX, 10 asm MOV
BX, 2 asm ADD AX ,BX
printf("%d',_AX); asm MOV

3 GoutamSanyal , Asstant Professor , CA/IT., YSM


LAB MANUAL

AX, 10 asm MOV BX, 2 asm


SUB AX ,BX
printf("%d',_AX); asm MOV
AX, 10 asm MOV BX, 2 asm
MUL BX printf("%d',_AX)
asm MOV AX, 10 asm MOV
BX, 2 asm DIV BX
printf("%d',_AX); getch();
return 0;
}

PROGRAM-2
// ASSSEMBLY LANGUAGE PROGRAM FOR LOGICAL OPERATION
#include<stdio.h>
#include<conio.h> int main()
{
clrscr();
asm MOV AX, 10 asm MOV
BX, 2 asm OR AX ,BX
printf("VALUE OF OR OF 10 , 2 IS %d\n",_AX); asm
MOV AX, 10
asm MOV BX, 2 asm AND
AX ,BX
printf"VALUE OF AND OF 10 , 2 IS %d\n",_AX); asm
MOV AX, 10
asm MOV BX, 2 asm XOR
AX ,BX
printf("VALUE OF XOR OF 10 , 2 IS %d\n",_AX);
getch(); return 0;
}

PROGRAM-3
//PROGRAM TO IMPLEMENT IF STATEMENT
// THE PROGRAM WILL NEGATE THE INTEGER IF IT IS NEGEATIVE
//THE ALGORITHM IS
//If AX < 0 Then

//Replace AX by -AX
#include<stdio.h>
#include<conio.h> int main()
{
int z; clrscr();
printf("Enter a number");
scanf("%d",&z);
//ENDIF
// if AX < 0
asm mov AX,z; // to move the value of z to ax
asm CMP AX, 0 // compare the value in ax with zero
asm JNL END_IF //jump to label END_IF if it is not less than zero
4 GoutamSanyal , Asstant Professor , CA/IT., YSM
LAB MANUAL

//then
asm NEG AX; // negate the value in ax END_IF:
printf("%d",_AX); return 0;
}

Using Emulator
Emulator Instalation

5 GoutamSanyal , Asstant Professor , CA/IT., YSM


LAB MANUAL

1. Program to print “Hello world”


.MODEL SMALL

.STACK

.DATA

6 GoutamSanyal , Asstant Professor , CA/IT., YSM


LAB MANUAL

STRING1 DB "HELLO WORLD $" ; declaring string

STRING2 DB 10,13, "GOOD MORNING $"


STRING3 DB 10 ,13,"HAVE GOOD DAY $" ; declaring string

.CODE

MAIN PROC ; main procedure

MOV AX, @DATA ; initialize the data segment


MOV DS, AX
LEA DX, STRING1 ; loading the effectiveaddress
MOV AH, 09H ; for string display
INT 21H
mov ah ,1
int 21h ; dos interrupt function
LEA DX, STRING2 ; loading the effective address
MOV AH, 09H ; for string display
INT 21H ; dos interrupt function
LEA DX, STRING3 ; loading the effectiveaddress
MOV AH, 09H ; for string display
INT 21H ; dos interrupt function
MOV AX, 4C00H ; end request
INT 21H
MAIN ENDP ; end procedure
END MAIN ; end program

7 GoutamSanyal , Asstant Professor , CA/IT., YSM


LAB MANUAL

Output

Emulate

Run

2. Program to find sum of two number


.model small
8 GoutamSanyal , Asstant Professor , CA/IT., YSM
LAB MANUAL

.data

MSG DB "ENTER TWO NUMBER",'$'

.stack 100H

.code

MAIN PROC

MOV AX ,@DATA
MOV DS,AX

LEA DX,MSG
MOV AH,9
INT 21H MOV
AH,1 INT 21H
MOV BL,AL
INT 21H MOV

CL,AL ADD
BL,CL SUB
BL,48 MOV
AH,2 MOV
DL,BL INT
21H

MOV AH,4CH

INT 21H
MAIN ENDP
END MAIN

9 GoutamSanyal , Asstant Professor , CA/IT., YSM


LAB MANUAL

3. Program to input numbers into an array and display


INCLUDE 'EMU8086.INC'
.MODEL SMALL

.STACK 100H

.DATA

NUMBER DB 10 DUB(?)
MAIN PROC
MOV AX ,@DATA
MOV DS,AX
XOR BX,BX
MOV CX,5
MOV AH,1
FOR:

INT 21H

MOV NUMBER[BX],AL
INC BX
LOOP FOR
XOR BX,BX
MOV CX,5
PRINTN
MOV AH,2

10 GoutamSanyal , Asstant Professor , CA/IT., YSM


LAB MANUAL

FOR2:

MOV DL,NUMBER[BX]
INT 21H
INC BX

LOOP FOR2
MOV AH, 4CH
INT 21H MAIN
ENDP

END MAIN

4. Program to reverse a string


; sting reverse

.MODEL SMALL

.STACK 100H

.DATA

TEXT1 DB 'HELLO WORLD'


TEXT2 DB 13 DUP(?) COUNT
DW 13

.CODE

BEGIN:

MOV AX ,@DATA
MOV DS ,AX

11 GoutamSanyal , Asstant Professor , CA/IT., YSM


MOV ES, AX

MOV CX,COUNT ; CX=13MOV SI ,0


MOV DI ,0 ADD
DI,COUNTDEC DI

AGAIN:

MOV AL ,TEXT1[SI] MOV


TEXT2[DI],ALINC SI

DEC DI LOOP AGAIN


MOV AH ,4CHINT 21H

END BEGIN

Compiler Explorer

You might also like