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

Curs 8 Setul de Instructiuni 8086: Exemple

1. The document provides examples of 8086 instruction set basics. It includes examples of programs to calculate mathematical functions, compare values, generate random sequences, find greatest common divisors, and other operations. 2. Fifteen examples are given of programs implementing operations like comparisons, logic operations, loops, conditionals, and finding greatest common divisors. Pseudocode algorithms are also provided. 3. The examples demonstrate using 8086 assembly language instructions to perform common programming tasks through short code snippets and full programs.

Uploaded by

eugen lupu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Curs 8 Setul de Instructiuni 8086: Exemple

1. The document provides examples of 8086 instruction set basics. It includes examples of programs to calculate mathematical functions, compare values, generate random sequences, find greatest common divisors, and other operations. 2. Fifteen examples are given of programs implementing operations like comparisons, logic operations, loops, conditionals, and finding greatest common divisors. Pseudocode algorithms are also provided. 3. The examples demonstrate using 8086 assembly language instructions to perform common programming tasks through short code snippets and full programs.

Uploaded by

eugen lupu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Curs 8

Setul de instructiuni 8086


EXEMPLE

Moto: "Mi-e teama de ziua in care tehnologia va fi mai


importanta ca relatiile interumane.
In lume va exista o generatie de idioti. A. Einstein

Appreciating Art in a museum ... Admirand arta in museu

Setul de instructiuni de baza 8086 Exemple.


1. Scrieti secventa de program care implementeaza optimal
functia: y= (x2-5x)/2. Variabila x se citeste la un port de 8 biti cu
adresa 100h,
iar valoarea calculata se scoate la un port de 16 biti cu adresa
80h.
2. Indicati cel putin 3 moduri de a face ca BX=0.
3. Indicati 3 diferente intre instructiunile DEC AX si SUB AX,1.
4. Indicati 4 moduri de a face BX=BX+2 (din max. 2 instructiuni).
5. Scrieti secventa de program care contorizeaza in BL nr.
elementelor 55h din sirul SIR DB 100 DUP(?) (in 2 moduri).3

desecventa
instructiuni
de bazacare
8086/88.
EXEMPLE.
6.Setul
Scrieti
de program
face suma
primelor N <256
numere naturale in AX (in 2 moduri).
7. Scrieti o secventa de program care apeleaza de 50 de ori
subrutina Call_me
8. Scrieti secventa de program care umple o zona de 100 de
octeti cu caracterul $. Ce alta varianta ofera asamblorul?
9. In memorie se gasesc 2 siruri adiacente SIR1 si SIR2 de
lungime l1, l2 <256. Se cere secventa de program care
genereaza sirul intersectie INT DB (max l1,l2) DUP(?). Se cer 2
variante.

Setul de instructiuni
de baza 8086/88.
EXEMPLE.
10.Cautati
exemple de instructiuni
de 2-6 bytes
care sa aiba
efectul instructiunii NOP.
11. Dati exemplu de secvente de program care genereaza
secvente pseudoaleatoare.
12. Cum puteti face ca C=Z?
13. Scrieti o secventa de program care sa permita realizarea unor
bucle imbricate (2).

14. Scrieti o secventa de program care sa determine CMMDC a


doua numere aflate in AX si BX.
5

15.

and al, 0
or al, 1
or al, 80h
and al, 7Fh
stc
clc

; set Zero
; clear Zero
; set Sign
; clear Sign
; set Carry
; clear Carry

mov al, 7Fh


inc al

; set Overflow

or eax, 0

; clear Overflow

16. Implementati secventele de pseudocod in asambare. Valorile sunt


fara semn.
if( ebx <= ecx )
{
eax = 5;
edx = 6;
}
if (al > bl) AND (bl > cl)
X = 1;

Algoritmul lui EUCLID

Iterativ
function gcd(a, b)

function gcd(a, b)

if a = 0 return b

while b 0

while b 0

t := b

if a > b

b := a mod b
a := a b

a := t

else

return a
b := b a

return a

Recursiv
function gcd(a, b)

if b = 0 return a
else return gcd(b, a mod b)

Algoritmul lui EUCLID

C/C++
int gcd(int a, int b)
{
return ( b == 0 ? a : gcd(b, a % b) );
}

#include <stdio.h>
#include <stdlib.h>
//RECURSIV
int GCD(int a, int b)
{
return ( b == 0 ? a : GCD(b, a % b) );
}
/* ITERATIV
int GCD(int x, int y)
{
int wX = x;
int wY = y;
int tempX;
while ( wY > 0 )
{
tempX = wX;
wX = wY;
wY = tempX % wY;
}
return(wX);
}*/

int main()
{
int inputX;
int inputY;
int inputSuccess;
printf("Please enter x: ");
inputSuccess = scanf("%d", &inputX);
printf("Please enter y: ");
inputSuccess = scanf("%d", &inputY);
printf("GCD of %d and %d is %d\n", inputX, inputY, GCD(inputX,inputY));
exit(EXIT_SUCCESS);
}

Algoritmul lui EUCLID

10

You might also like