UNIVERZITET U BEOGRADU ELEKTROTEHNIČKI FAKULTET

Similar documents
AM2: Programming with Contemporary Instruction Set

AM2: Protected-Mode Programming

RAČUNARSKA ELEKTRONIKA VEŽBE 4

Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB. Lab # 10. Advanced Procedures

Assembly Language. Lecture 5 Procedures

Assembly Language. Lecture 5 Procedures

Marking Scheme. Examination Paper Department of CE. Module: Microprocessors (630313)

Marking Scheme. Examination Paper Department of CE. Module: Microprocessors (630313)

COMPUTER ENGINEERING DEPARTMENT

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 5: Procedures. Chapter Overview. The Book's Link Library

In order to run the program, go to the folder Release and run project.exe.

Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB. Lab # 8. Conditional Processing

Programiranje III razred

COMPUTER ENGINEERING DEPARTMENT

Assembly Language for Intel-Based Computers, 5 th Edition. Chapter 9: Strings and Arrays

Jump instructions. Unconditional jumps Direct jump. do not change flags. jmp label

Lab 5: Input/Output using a Library of Procedures

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 5: Procedures

Uputstvo za korišćenje logrotate funkcije

Izrada VI laboratorijske vježbe

Basic Assembly Instructions

Lab 6: Conditional Processing

We will first study the basic instructions for doing multiplications and divisions

Conditional Processing

X86 Addressing Modes Chapter 3" Review: Instructions to Recognize"

Microprocessors ( ) Fall 2010/2011 Lecture Notes # 15. Stack Operations. 10 top

namespace spojneice { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

Marking Scheme. Examination Paper. Module: Microprocessors (630313)

Uputa: Zabranjeno je koristiti bilo kakva pomagala. Rje²enja pi²ete desno od zadatka. Predajete samo ovaj list.

EECE.3170: Microprocessor Systems Design I Summer 2017 Homework 4 Solution

Programiranje Programski jezik C. Sadržaj. Datoteke. prof.dr.sc. Ivo Ipšić 2009/2010

Vežbe - XII nedelja PHP Doc

Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB

Dežurni nastavnik: Kolokvijum traje 1.5 sat, prvih sat vremena nije dozvoljeno napuštanje kolokvijuma. Upotreba literature nije dozvoljena.

Required Setup for 32-bit Applications

mith College Computer Science CSC231 Assembly Week #9 Spring 2017 Dominique Thiébaut

Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB

Topic 6: Code Generation

mith College Computer Science CSC231 Assembly Week #10 Fall 2017 Dominique Thiébaut

b) program deljiv3; uses wincrt; var i:integer; begin i:=3; while i<100 do begin write(i:5); i:=i+3; end; end.

Procedure-Calling Conventions October 30

Assembly Language for Intel-Based Computers, 4 th Edition

Q1: Multiple choice / 20 Q2: Data transfers and memory addressing

Marking Scheme. Examination Paper. Module: Microprocessors (630313)

;this variable is used to keep the mans position. ;this variable is used to keep the zombies position

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 6: Conditional Processing. Chapter Overview. Boolean and Comparison Instructions

Libraries and Procedures

I PISMENI ZADATAK III6 I GRUPA IME I PREZIME

NIZOVI.

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 6: Conditional Processing

pojedinačnom elementu niza se pristupa imeniza[indeks] indeks od 0 do n-1

Libraries and Procedures

Assembly Language for Intel-Based Computers, 4 th Edition. Lecture 25: Interface With High-Level Language

1/26 Tuesday, January 26, :17 PM

db "Please enter up to 256 characters (press Enter Key to finish): ",0dh,0ah,'$'

Computer Architecture and Assembly Language. Practical Session 5

Učitati cio broj n i štampati njegovu recipročnu vrijednost. Ako je učitan broj 0, štampati 1/0.

16.317: Microprocessor Systems Design I Fall 2014

SOEN228, Winter Revision 1.2 Date: October 25,

Assembly Language for Intel-Based Computers, 5 th Edition. Kip R. Irvine. Chapter 6: Conditional Processing

16.317: Microprocessor Systems Design I Spring 2015

COMP211 ASSEMBLY PROGRAMMING

COE 205. Computer Organization and Assembly Language Dr. Aiman El-Maleh

Overview: 1. Overview: 2

PREDMET. Osnove Java Programiranja. Čas JAVADOC

Branching and Looping

Osnove programskog jezika C# Čas 5. Delegati, događaji i interfejsi

Assembly Language for Intel-Based Computers, 4 th Edition

Stack -- Memory which holds register contents. Will keep the EIP of the next address after the call

Assembly Language for Intel-Based Computers, 4 th Edition

Uvod u programiranje - vežbe. Kontrola toka izvršavanja programa

CSC 8400: Computer Systems. Machine-Level Representation of Programs

Branching and Looping

Conditional Processing

Macros. Introducing Macros Defining Macros Invoking Macros Macro Examples Nested Macros Example Program: Wrappers

Introduction to 8086 Assembly

Branching and Looping

complement) Multiply Unsigned: MUL (all operands are nonnegative) AX = BH * AL IMUL BH IMUL CX (DX,AX) = CX * AX Arithmetic MUL DWORD PTR [0x10]

VHDLPrimeri Poglavlje5.doc

Introduction to 8086 Assembly

Writing 32-Bit Applications

16.317: Microprocessor Systems Design I Fall 2015

Modbus TCP i dva PLC S7 1200

Basic Pentium Instructions. October 18

Informacioni sistemi i baze podataka

... ; ako je a n parno. ; ako je a n neparno

SA31675 / CVE

Strings and Arrays. Overview. String primitive instructions MOVSB, MOVSW, MOVSD

Assembler Programming. Lecture 8

VDSL modem Zyxel VMG1312-B10A/B30A

mith College Computer Science CSC231 Assembly Week #11 Fall 2017 Dominique Thiébaut

Programming in Assembler. Laboratory manual. Exercise 3

ECOM Computer Organization and Assembly Language. Computer Engineering Department CHAPTER 7. Integer Arithmetic

Računarske osnove Interneta (SI3ROI, IR4ROI)

CSC 2400: Computer Systems. Towards the Hardware: Machine-Level Representation of Programs

Introduction to Assembly Language

x y = z Zadaci - procedure

NISKE (stringovi) u C-u: podsećanje. 1. Primer programa koji uvodi niske karaktera terminisane nulom

CPS104 Recitation: Assembly Programming

Week /8086 Microprocessor Programming

Transcription:

UNIVERZITET U BEOGRADU ELEKTROTEHNIČKI FAKULTET Katedra za elektroniku Računarska elektronika Grupa br. 11 Projekat br. 8 Studenti: Stefan Vukašinović 466/2013 Jelena Urošević 99/2013

Tekst projekta : Napisati program koji će analizirati ulazni fajl. Svaki red u ulaznom fajlu je sekvenca karaktera: tekst [pauza], gde je tekst-sekvenca karaktera (ne sme da sadrži blanko znak), pauza-vreme u sekundama nakon kojeg treba obrisati poruku sa ekrana I ispisati novu. Na osnovu sadržaja fajla formira se odgovarajući ispis na ekranu. Na kraju izvršavanja programa potrebno je ispisati njegovo vreme izvršavanja. Objašnjenje koda: Formirana je lista korišćenih promenljivih, uključujući i output.txt fajl iz kog se čita željeni tekst, odnosno niz karaktera za ispis. Forma reda u output.txt fajlu je tekst+ +[x], gde je x broj koji oznacava trajanje pauze, a tekst niz karaktera bez blanko znaka. Svaki sledeci red u output.txt fajlu je iste forme. Program je realizovan tako da iščitava karakter po karakter, dok ne dodje do blanko znaka. To se postiže manipulacijom registara, nakon sto se adresa od koje kreće output.txt fajl smesti u registar edx. Iščitavanjem karaktera se postize formiranje sekvence za ispis koja će nakon x vremena biti izbrisana da bi se ispisao sledeci red itd. U petlji loop1 se iščitava niz karaktera sve dok se ne dođe do blanko znaka, dok se u loop2 iščitava vremenski period, odnosno trajanje pauze tokom koje taj niz karaktera ostaje ispisan na ekranu. Takođe, na kraju obrade fajla, biće ispisano ukupno trajanje izvršavanja programa uz pomoć GetTickCount funkcije izraženo u milisekundama. Kod: ; Reading a File (ReadFile.asm) ; Opens, reads, and displays a text file using ; procedures from Irvine32.lib. INCLUDE Irvine32.inc INCLUDE macros.inc BUFFER_SIZE = 50 BUFFER_SIZE1 = 5.data buffer BYTE BUFFER_SIZE DUP(?) buffer1 BYTE BUFFER_SIZE1 DUP(?) filename BYTE "output.txt",0 filehandle HANDLE? eax_cnt WORD 0 edx_cnt WORD 0 starttime DWORD?.code main PROC

INVOKE GetTickCount mov starttime,eax ; Open the file for input. mov edx,offset filename call OpenInputFile mov filehandle,eax ; Check for errors. cmp eax,invalid_handle_value ; error opening file? jne file_ok ; no: skip mwrite <"Cannot open file",0dh,0ah> jmp quit ; and quit file_ok: loop1: ; Read the file into a buffer. mov edx,offset buffer add dx,[edx_cnt] call ReadFromFile ;Return arg: If CF = 0, EAX contains the number of bytes read. cmp eax,0 ; je close_file ;kraj fajla ;mov edx,offset buffer ;add dx,[edx_cnt] ;movzx ecx,byte PTR[edx] ;cmp ecx,'eof' ;je close_file ;provera za kraj fajla inc ax add ax,1 cmp buffer[eax-1],' ' jne loop1 mov buffer[eax],0 ; insert null terminator

; Display the buffer. ;mwrite <"Buffer:",0dh,0ah,0dh,0ah> mov edx,offset buffer ; display the buffer call WriteString call Crlf call ReadFromFile mov ax,[eax_cnt] ;edx_cnt=0 ;eax_cnt=0 loop2: add dx,[edx_cnt] call ReadFromFile inc ax add ax,1 cmp buffer1[eax-1],']' jne loop2 mov buffer1[eax],0 ; insert null terminator posle znaka ']' ; Display the buffer. ;mwrite <"Buffer:",0dh,0ah,0dh,0ah> ; ; display the buffer1 koji sadrzi vreme pauze ;call WriteString ;call Crlf

top: xor eax, eax ;xor ecx,ecx movzx ecx,byte PTR[edx] inc edx ;cmp ecx, '0' ; valid? ;jb done cmp ecx, '9' ;prekida kad naidje na ']' ja done sub ecx,'0' imul eax,10 add eax,ecx jmp top done: imul eax,1000 INVOKE SLEEP,eax INVOKE Clrscr jmp loop1 close_file: INVOKE GetTickCount sub eax,starttime call WriteDec mwrite <" milliseconds have elapsed",0dh,0ah> mov call eax,filehandle CloseFile quit: exit main ENDP END main