AC Lab 3 [PDF]

  • 0 0 0
  • Gefällt Ihnen dieses papier und der download? Sie können Ihre eigene PDF-Datei in wenigen Minuten kostenlos online veröffentlichen! Anmelden
Datei wird geladen, bitte warten...
Zitiervorschau

Ministerul Educației al Republicii Moldova Universitatea Tehnică a Moldovei Facultatea Calculatoare, Informatică şi Microelectronică Departamentul Ingineria Software şi Automatică

Raport Lucrarea de laborator nr.3 Disciplina: Arhitectura Calculatoarelor

A efectuat:

st. gr.TI-174 Iepuraș Daniel

A verificat:

conf.univ. V.Colesnic

Chișinău - 2018

Scopul Lucrării: Lucrarea prezintă instrucțiunile pentru transferuri de date,instrucțiunile în aritmetica binară şi în aritmetica BCD. Sarcina Lucrării: Conform variantei elaboraţi 2 variante de program : a)cu introducerea datelor de la tastatură şi afişarea rezultatelor pe ecran. b)cu generarea datelor de intrare, utilizănd procedurile Random32, RandomRange. Varianta 7 𝑌/2 + 𝑋, 𝑍={ 2𝑌 + 32𝑋

𝑑𝑎𝑐ă 𝑌/2 > 0 , 𝑑𝑎𝑐ă 𝑌/2 ≤ 0

a)cu introducerea datelor de la tastatură şi afişarea rezultatelor pe ecran. Codul sursa al programului INCLUDE Irvine32.inc .data mes1 byte "Introduceti valoarea X:", 0 mes2 byte "Introduceti valoarea Y:", 0 mes3 byte "Rezultatul este:", 0 vrx dword 0 vry dword 0 rez dword 0 interm dw ? .code main proc mov edx, offset mes1 call WriteString; call ReadInt; mov vrx, eax; mov edx,offset mes2 call WriteString; call ReadInt; mov vry,eax mov eax, vry cwd mov ebx, 2 idiv bx cmp eax, 0 jna con1 mov mov mov mov

eax, vry ebx, 0 bx, 2 dx, 0

idiv bx add eax, vrx jmp ex con1:mov eax,vry mov bx,2 mul bx mov interm,ax mov eax,vrx mov bx,32 mul bx xchg ax, interm add ax,interm mov rez,eax ex: mov edx,offset mes3 call WriteString call WriteInt call Crlf exit main ENDP END main

Listingul programului: INCLUDE Irvine32.inc C ; Include file for Irvine32.lib C C ;OPTION CASEMAP:NONE

(Irvine32.inc) ; optional: make identifiers

C C INCLUDE SmallWin.inc

; MS-Windows prototypes,

case-sensitive

structures, and constants

00000000 00000000 49 64 69 6F 20 00000018 49 64 69 6F 20 00000030 52 74 20 3A

6E 75 20 61 58 6E 75 20 61 59 65 61 65 00

74 63 76 72 3A 74 63 76 72 3A 7A 74 73

72 65 61 65 00 72 65 61 65 00 75 75 74

6F 74 6C 61

C .NOLIST C .LIST C C INCLUDE VirtualKeys.inc C ; VirtualKeys.inc C .NOLIST C .LIST C C C .NOLIST C .LIST C .data mes1 byte "Introduceti valoarea X:", 0

6F 74 6C 61

mes2 byte "Introduceti valoarea Y:", 0

6C 6C 65

mes3 byte "Rezultatul este:", 0

00000041 00000045 00000049 0000004D

00000000 00000000 00000000 0000

vrx dword 0 vry dword 0 rez dword 0 interm dw ?

00000000 00000000 00000000 00000005 0000000A 0000000F 00000014 00000019 0000001E 00000023

BA E8 E8 A3 BA E8 E8 A3

00000028 0000002D 00000032 00000036 0000003A 0000003D 00000042 00000044

A1 00000045 R BB 00000000 66| BB 0002 66| BA 0000 66| F7 FB BB 00000000 3B C3 76 1D

mov eax, vry mov ebx, 0 mov bx, 2 mov dx, 0 idiv bx mov ebx, 0 cmp eax, ebx jna con1

00000046 0000004B 00000050 00000054 00000058 0000005B 00000061

A1 00000045 R BB 00000000 66| BB 0002 66| BA 0000 66| F7 FB 03 05 00000041 R EB 31

mov eax, vry mov ebx, 0 mov bx, 2 mov dx, 0 idiv bx add eax, vrx jmp ex

00000063 00000068 0000006C 0000006F 00000075 0000007A 0000007E 00000081 00000088 0000008F

.code 00000000 00000000 00000000 00000041 00000018 00000000 00000000 00000045

main proc mov edx, offset mes1 call WriteString; call ReadInt; mov vrx, eax; mov edx,offset mes2 call WriteString; call ReadInt; mov vry,eax

R E E R R E E R

A1 00000045 R 66| BB 0002 66| F7 E3 66| A3 0000004D R A1 00000041 R 66| BB 0020 66| F7 E3 66| 87 05 0000004D R 66| 03 05 0000004D R A3 00000049 R

00000094 00000099 0000009E 000000A3

BA E8 E8 E8

00000030 00000000 00000000 00000000

000000A8 000000AA 000000AF

6A 00 * E8 00000000 E

con1:mov eax,vry mov bx,2 mul bx mov interm,ax mov eax,vrx mov bx,32 mul bx xchg ax, interm add ax,interm mov rez,eax

R E E E

ex: mov edx,offset mes3 call WriteString call WriteInt call Crlf

*

exit push +000000000h call ExitProcess main ENDP END main

b)cu generarea datelor de intrare, utilizănd procedurile Random32, RandomRange. Codul sursa al programului INCLUDE Irvine32.inc .data mes1 byte "X=",0 mes2 byte "Y=",0 mes3 byte "Rezultatul este:",0 vrx dword 0 vry dword 0 rez dword 0 interm dw ? .code main proc call Randomize mov edx,offset mes1 call WriteString; call Random32; call WriteInt call Crlf mov vrx,eax; mov edx,offset mes2 call WriteString; call Random32; call WriteInt call Crlf mov vry,eax mov eax, vry cwd mov ebx, 2 idiv bx cmp eax, 0 jna con1 mov eax, vry mov ebx, 0 mov bx, 2 mov dx, 0 idiv bx add eax, vrx jmp ex con1:mov eax,vry mov bx,2 mul bx mov interm,ax mov eax,vrx mov bx,32 mul bx xchg ax, interm add ax,interm

mov rez,eax ex: mov edx,offset mes3 call WriteString call WriteInt call Crlf exit main ENDP END main

Listingul programului: INCLUDE Irvine32.inc C ; Include file for Irvine32.lib C C ;OPTION CASEMAP:NONE

(Irvine32.inc) ; optional: make identifiers

C C INCLUDE SmallWin.inc

; MS-Windows prototypes,

case-sensitive

structures, and constants

00000000 00000000 58 3D 00 00000003 59 3D 00 00000006 52 65 7A 75 6C 74 61 74 75 6C 20 65 73 74 65 3A 00 00000017 00000000 0000001B 00000000 0000001F 00000000

C .NOLIST C .LIST C C INCLUDE VirtualKeys.inc C ; VirtualKeys.inc C .NOLIST C .LIST C C C .NOLIST C .LIST C .data mes1 byte "X=",0 mes2 byte "Y=",0 mes3 byte "Rezultatul este:",0

vrx dword 0 vry dword 0 rez dword 0

00000023 0000 00000000 00000000 00000000 00000005 0000000A 0000000F 00000014 00000019 0000001E 00000023 00000028 0000002D 00000032 00000037

interm dw ? .code

E8 BA E8 E8 E8 E8 A3 BA E8 E8 E8 E8

00000000 00000000 00000000 00000000 00000000 00000000 00000017 00000003 00000000 00000000 00000000 00000000

E R E E E E R R E E E E

main proc call Randomize mov edx,offset mes1 call WriteString; call Random32; call WriteInt call Crlf mov vrx,eax; mov edx,offset mes2 call WriteString; call Random32; call WriteInt call Crlf

0000003C

A3 0000001B R

mov vry,eax

00000041 00000046 0000004B 0000004F 00000053 00000056 0000005B 0000005D

A1 0000001B R BB 00000000 66| BB 0002 66| BA 0000 66| F7 FB BB 00000000 3B C3 76 1D

mov eax, vry mov ebx, 0 mov bx, 2 mov dx, 0 idiv bx mov ebx, 0 cmp eax, ebx jna con1

0000005F 00000064 00000069 0000006D 00000071 00000074 0000007A

A1 0000001B R BB 00000000 66| BB 0002 66| BA 0000 66| F7 FB 03 05 00000017 R EB 31

mov eax, vry mov ebx, 0 mov bx, 2 mov dx, 0 idiv bx add eax, vrx jmp ex

0000007C 00000081 00000085 00000088 0000008E 00000093 00000097 0000009A 000000A1 000000A8

A1 0000001B R 66| BB 0002 66| F7 E3 66| A3 00000023 R A1 00000017 R 66| BB 0020 66| F7 E3 66| 87 05 00000023 R 66| 03 05 00000023 R A3 0000001F R

000000AD 000000B2 000000B7 000000BC

BA E8 E8 E8

00000006 00000000 00000000 00000000

000000C1 000000C3 000000C8

6A 00 * E8 00000000 E

con1:mov eax,vry mov bx,2 mul bx mov interm,ax mov eax,vrx mov bx,32 mul bx xchg ax, interm add ax,interm mov rez,eax

R E E E

ex: mov edx,offset mes3 call WriteString call WriteInt call Crlf

*

exit push +000000000h call ExitProcess main ENDP END main

Concluzie In lucrarea de laborator nr.3 am realizat un program ce rezolva o operatie.Au fost obtinute noi abilitati in utilizarea instructiunilor in aritmetica binara:adunare,scadere,inmultire,impartire si utilizarea salturilor conditionate si neconditionate.De asemenea am utilizat procedurile Random32 si RandomRange.