SlideShare ist ein Scribd-Unternehmen logo
1 von 6
Proiect II
Proiect Arhitectura Sistemelor de Calcul
- Dec. 2018 -
UNIVERSITATEA TITU MAIORESCU
Facultatea de INFORMATICĂ
Tema de proiect
Sa se realizeze un program in assembler care
calculeaza suma a trei variabile, apoi suma a
doua variabile, aduna cele doua sume si afiseaza
rezultatul
Cod ASM - 1
; Suma in dubla precizie a variabilelor de tip cuvant dublu a,b,c.
; Rezultatul este plasat in variabile s.
; N E A G O E C R I S T I A N
; 78 69 65 85 76 69 67 82 73 83 84 73 65 78
;------------------------------------------------------------------------------------------------------------------------------------------------
.model small ;Marimea maxima data,stack si cod este de 64 biti
.stack 100h ;Program executatbil cu mai multe segmente , rezerva 100h pentru stack .
.data ;Directive pentru procesor - prepara asamblorul pentru codul nostu
nstr db 6 dup(' ') ;Sir format din spatii, spatiul rezerva in memorie este de 6x
idv dw 10 ;Divizorul = 10
a dw 8 ;Variabila N - 78 : ultima cifra 8
b dw 9 ;Variabila E - 69 : ultima cifra 9
c dw 7 ;Variabila A - 67 : ultima cifra 7
x dw ? ;Variabila x=a+b+c
d dw 67 ;Variabila C - 67 : corespondentul in ASCII 67
e dw 82 ;Variabila R - 82 : corespondentul in ASCII 82
y dw ? ;Variabila y=d+e
s dw ? ;Variabila s=x+y
.code ;Directive pentru procesor - prepara asamblorul pentru codul nostru
.startup ;Directive pentru procesor - prepara asamblorul pentru codul nostru
;Ds - initializare registru data storage , dgroup - nume segment
mov ax, dgroup
mov ds, ax ;ax registru care preia valoarile .
Cod ASM - 2
; x = a+b+c
mov ax, a ;In dx:ax transfera valoarea lui a
add ax, b ;Aduna la ax cuvantul mai putin semnificativ al lui b
add ax, c ;Aduna la ax cuvantul mai putin semnificativ al lui c
mov x, ax ;In x transfera rezultatul a+b+c
; y = d+e
;In dx:ax transfera valoarea lui d
mov ax, d
add ax, e ;Aduna la ax cuvantul mai putin semnificativ al lui e
mov y, ax ;In y transfera rezultatul d+e
; s = x+y
mov ax, x
add ax, y
mov s , ax ;In s transfera rezultatul x+y
mov si,5 ;Terminatorul de sir ,indice 5
mov nstr[si], '$' ;Marcheaza finalizarea sirului,
dec si ;Decrementare Si , scoate 1 din sir
;La impartire numarul se gaseste in dx:ax
mov ax, s ;Muta valarea lui s in ax
mov dx,0
Cod ASM - 3
loop1: ;Eticheta
div idv ;Impartire fara semn
;In ax = catul impartirii
;In dx = restul (0->9) - adica folosim numai val din dl
;CONVERSIA numarului in codul ASCII corespunzator cifrei:
;Adunam la codul caracterului "0" valoarea cifrei
add dl, '0' ;Initializam registru dl la valoarea 0
mov nstr[si],dl
dec si ;Decrementare Si , scoate 1 din si
mov dx,0 ;Initializam registru dx la valoarea 0
;Daca catul != 0 continua transf. cifrelor
cmp ax,0 ;Compara registul AX cu 0
jne loop1 ;Jump not equal - executa bucla pana la valoarea 0
listn: ;Eticheta
mov ah, 09h ;Sir de caractere se afişează pe ecran
mov dx, offset nstr ;Afisare in promoter ,adresa relativă a locaţiei de unde începe stocarea sa în memorie
int 21h ;Interrupt
stopprg: ;Eticheta
mov ah, 4ch ;Utilizată pentru terminarea programului
int 21h ;Interrupt
end ;Sfarsit fisier sursa
Schema logica
nstr[6] = {ᴗ, ᴗ, ᴗ, ᴗ, ᴗ, ᴗ}
idv=10
a=8 b=9 c=7 d=67 e=82
Si=? s=? x=? y=?
x=a+b+c
y=d+e
s=x+y
si=5
nstr[Si]=‘$’
ax=s
dx=0
Si=Si-1
Afiseaza nstr
dx=ax mod10
aduna cod
asci ‘0’ la dl
nstr[Si]=dl
Si=Si-1
dx=0
Ax>0
DA NU
START
STOP

Weitere ähnliche Inhalte

Empfohlen

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Empfohlen (20)

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 

Proiect2

  • 1. Proiect II Proiect Arhitectura Sistemelor de Calcul - Dec. 2018 - UNIVERSITATEA TITU MAIORESCU Facultatea de INFORMATICĂ
  • 2. Tema de proiect Sa se realizeze un program in assembler care calculeaza suma a trei variabile, apoi suma a doua variabile, aduna cele doua sume si afiseaza rezultatul
  • 3. Cod ASM - 1 ; Suma in dubla precizie a variabilelor de tip cuvant dublu a,b,c. ; Rezultatul este plasat in variabile s. ; N E A G O E C R I S T I A N ; 78 69 65 85 76 69 67 82 73 83 84 73 65 78 ;------------------------------------------------------------------------------------------------------------------------------------------------ .model small ;Marimea maxima data,stack si cod este de 64 biti .stack 100h ;Program executatbil cu mai multe segmente , rezerva 100h pentru stack . .data ;Directive pentru procesor - prepara asamblorul pentru codul nostu nstr db 6 dup(' ') ;Sir format din spatii, spatiul rezerva in memorie este de 6x idv dw 10 ;Divizorul = 10 a dw 8 ;Variabila N - 78 : ultima cifra 8 b dw 9 ;Variabila E - 69 : ultima cifra 9 c dw 7 ;Variabila A - 67 : ultima cifra 7 x dw ? ;Variabila x=a+b+c d dw 67 ;Variabila C - 67 : corespondentul in ASCII 67 e dw 82 ;Variabila R - 82 : corespondentul in ASCII 82 y dw ? ;Variabila y=d+e s dw ? ;Variabila s=x+y .code ;Directive pentru procesor - prepara asamblorul pentru codul nostru .startup ;Directive pentru procesor - prepara asamblorul pentru codul nostru ;Ds - initializare registru data storage , dgroup - nume segment mov ax, dgroup mov ds, ax ;ax registru care preia valoarile .
  • 4. Cod ASM - 2 ; x = a+b+c mov ax, a ;In dx:ax transfera valoarea lui a add ax, b ;Aduna la ax cuvantul mai putin semnificativ al lui b add ax, c ;Aduna la ax cuvantul mai putin semnificativ al lui c mov x, ax ;In x transfera rezultatul a+b+c ; y = d+e ;In dx:ax transfera valoarea lui d mov ax, d add ax, e ;Aduna la ax cuvantul mai putin semnificativ al lui e mov y, ax ;In y transfera rezultatul d+e ; s = x+y mov ax, x add ax, y mov s , ax ;In s transfera rezultatul x+y mov si,5 ;Terminatorul de sir ,indice 5 mov nstr[si], '$' ;Marcheaza finalizarea sirului, dec si ;Decrementare Si , scoate 1 din sir ;La impartire numarul se gaseste in dx:ax mov ax, s ;Muta valarea lui s in ax mov dx,0
  • 5. Cod ASM - 3 loop1: ;Eticheta div idv ;Impartire fara semn ;In ax = catul impartirii ;In dx = restul (0->9) - adica folosim numai val din dl ;CONVERSIA numarului in codul ASCII corespunzator cifrei: ;Adunam la codul caracterului "0" valoarea cifrei add dl, '0' ;Initializam registru dl la valoarea 0 mov nstr[si],dl dec si ;Decrementare Si , scoate 1 din si mov dx,0 ;Initializam registru dx la valoarea 0 ;Daca catul != 0 continua transf. cifrelor cmp ax,0 ;Compara registul AX cu 0 jne loop1 ;Jump not equal - executa bucla pana la valoarea 0 listn: ;Eticheta mov ah, 09h ;Sir de caractere se afişează pe ecran mov dx, offset nstr ;Afisare in promoter ,adresa relativă a locaţiei de unde începe stocarea sa în memorie int 21h ;Interrupt stopprg: ;Eticheta mov ah, 4ch ;Utilizată pentru terminarea programului int 21h ;Interrupt end ;Sfarsit fisier sursa
  • 6. Schema logica nstr[6] = {ᴗ, ᴗ, ᴗ, ᴗ, ᴗ, ᴗ} idv=10 a=8 b=9 c=7 d=67 e=82 Si=? s=? x=? y=? x=a+b+c y=d+e s=x+y si=5 nstr[Si]=‘$’ ax=s dx=0 Si=Si-1 Afiseaza nstr dx=ax mod10 aduna cod asci ‘0’ la dl nstr[Si]=dl Si=Si-1 dx=0 Ax>0 DA NU START STOP