Guide to Assignment 3 and 4 Programming Tasks 1 CSE 2312 Computer Organization and Assembly Language Programming Vassilis Athitsos University of Texas.

Slides:



Advertisements
Similar presentations
compilers and interpreters
Advertisements

SYMBOL TABLES &CODE GENERATION FOR EXECUTABLES. SYMBOL TABLES Compilers that produce an executable (or the representation of an executable in object module.
Chapter 11 Implementing an Assembler and a Linker Using C++ and Java.
Write a program step by step. Step 1: Problem definition. Given the coordinate of two points in 2-D space, compute and print their straight distance.
Computer Science 101 Data Encryption And Computer Networks.
Programming Types of Testing.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
Chapter 1 Data Storage. 2 Chapter 1: Data Storage 1.1 Bits and Their Storage 1.2 Main Memory 1.3 Mass Storage 1.4 Representing Information as Bit Patterns.
William Stallings Data and Computer Communications 7 th Edition (Selected slides used for lectures at Bina Nusantara University) Error Control.
Assembly & Machine Languages
By: Mr. Baha Hanene Chapter 3. Learning Outcomes We will cover the learning outcome 02 in this chapter i.e. Use basic data-types and input / output in.
More on Functions CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Guide to Assignment 3 Programming Tasks 1 CSE 2312 Computer Organization and Assembly Language Programming Vassilis Athitsos University of Texas at Arlington.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
Structured COBOL Programming, Stern & Stern, 9th edition
INTRODUCTION TO C PROGRAMMING LANGUAGE Computer Programming Asst. Prof. Dr. Choopan Rattanapoka and Asst. Prof. Dr. Suphot Chunwiphat.
CPS120: Introduction to Computer Science
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
A First Program CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington Credits: a significant part of.
Computer Programming Basics Assistant Professor Jeon, Seokhee Assistant Professor Department of Computer Engineering, Kyung Hee University, Korea.
Guide To UNIX Using Linux Fourth Edition
Pengantar Teknologi Informasi dan Ilmu Komputer Information Technology and Data Representation PTIIK- UB.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Chapter 1 What is Programming? Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
PHP meets MySQL.
Digital Logic Lecture 4 Binary Codes The Hashemite University Computer Engineering Department.
Mastering Char to ASCII AND DOING MORE RELATED STRING MANIPULATION Why VB.Net ?  The Language resembles Pseudocode - good for teaching and learning fundamentals.
Data Representation and Storage Lecture 5. Representations A number value can be represented in many ways: 5 Five V IIIII Cinq Hold up my hand.
Digital Logic Design Lecture 3 Complements, Number Codes and Registers.
Based on slides by:Charles Kime & Thomas Kaminski © 2004 Pearson Education, Inc. ECE/CS 352: Digital System Fundamentals Lecture 2 – Binary Codes.
Computer Systems Organization CS 1428 Foundations of Computer Science.
CS151 Introduction to Digital Design
Python From the book “Think Python”
Chapter 9 1 Chapter 9 – Part 1 l Overview of Streams and File I/O l Text File I/O l Binary File I/O l File Objects and File Names Streams and File I/O.
1 Binary Codes Digital systems use 2-state devices that understand only 2 binary values (0 and 1). But we communicate using various symbols and methods.
Error Control Code. Widely used in many areas, like communications, DVD, data storage… In communications, because of noise, you can never be sure that.
جلسه هشتم شبکه های کامپیوتری به نــــــــــــام خدا.
Homework #5 New York University Computer Science Department Data Structures Fall 2008 Eugene Weinstein.
Data and Computer Communications by William Stallings Eighth Edition Digital Data Communications Techniques Digital Data Communications Techniques Click.
ENEE244-02xx Digital Logic Design Lecture 3. Announcements Homework 1 due next class (Thursday, September 11) First recitation quiz will be next Monday,
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
What is Programming? A program is a list of instructions that is executed by a computer to accomplish a particular task. Creating those instructions is.
Intermediate 2 Computing Unit 2 - Software Development Topic 2 - Software Development Languages and Environments.
A First Program CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington Credits: a significant part of.
1/30/ :20 PM1 Chapter 6 ─ Digital Data Communication Techniques CSE 3213 Fall 2011.
More on Assembly 1 CSE 2312 Computer Organization and Assembly Language Programming Vassilis Athitsos University of Texas at Arlington.
Chapter – 8 Software Tools.
Computer Architecture Error Correcting Codes Ralph Grishman Oct (Text pp and B-65-67) NYU.
1 Product Codes An extension of the concept of parity to a large number of words of data 0110… … … … … … …101.
MEGGIT DECODER. PROBLEM STATEMENT To correct all single errors in n-bit codeword, n error patterns of single errors and their corresponding syndromes.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 10 – Loaders.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages.
The ASCII Alphanumeric Code What is it? Why use it? How do we use it?
INTRODUCTION TO PROGRAMING System Development Mansoura October 2015.
Software Engineering Algorithms, Compilers, & Lifecycle.
Linux CSE 1222 CSE1222: Lecture 1BThe Ohio State University1.
Bitwise Operations C includes operators that permit working with the bit-level representation of a value. You can: - shift the bits of a value to the left.
Logic and Computer Design Fundamentals
Overview Part 2 – Combinational Logic Functions and functional blocks
Lecture 1 Introduction Richard Gesick.
Character coding schemes
System Programming and administration
Representing characters
Slide design: Dr. Mark L. Hornick
Guide To UNIX Using Linux Third Edition
Chapter 1 Data Storage.
Homework Applied for cs240? (If not, keep at it!) 8/10 Done with HW1?
Presentation transcript:

Guide to Assignment 3 and 4 Programming Tasks 1 CSE 2312 Computer Organization and Assembly Language Programming Vassilis Athitsos University of Texas at Arlington

Task 1 Goal: convert a data file from one endian format to the other. Program flow: – Open input and output files. – While there is input data to be processed: Read the next record from the input file. Convert the record to the other endian format. Save the record to the output file. – Close input and output files. 2

Task 1 Goal: convert a data file from one endian format to the other. Program flow: – Open input and output files. – While there is input data to be processed: Read the next record from the input file. Convert the record to the other endian format. Save the record to the output file. – Close input and output files. If you use task1.c, you just have to write the function that converts the record and saves it to the output file. 3

Task 1 Sample Output (1) Run on an Intel machine (little endian):./a.out 0 test1_little.bin test2_big.bin read: Record: age = 56, name = john smith, department = 6 read: Record: age = 46, name = mary jones, department = 12 read: Record: age = 36, name = tim davis, department = 5 read: Record: age = 26, name = pam clark, department = 10 4

Task 1 Sample Output (2) Run on an Intel machine (little endian):./a.out 0 test2_big.bin out2_little.bin read: Record: age = , name = john smith, department = read: Record: age = , name = mary jones, department = read: Record: age = , name = tim davis, department = read: Record: age = , name = pam clark, department = Since the machine is little endian and the input data is big endian, the printout is nonsense. 5

Task 2 Goal: do parity-bit encoding/decoding of a file. Program flow: – Open input and output files. – While there is input data to be processed: Read the next word W1 from the input file. If (number == 0) convert W1 from original word to codeword W2. If (number == 1): – convert W1 from codeword to original word W2. – print out a message if an error was detected. Save W2 to the output file. – Close input and output files. 6

Task 2 Goal: do parity-bit encoding/decoding of a file. Program flow: – Open input and output files. – While there is input data to be processed: Read the next word W1 from the input file. If (number == 0) convert W1 from original word to codeword W2. If (number == 1): – convert W1 from codeword to original word W2. – print out a message if an error was detected. Save W2 to the output file. – Close input and output files. If you use task2.c, you just have to write the functions that convert between original words and codewords. 7

Task 2 Files Task 2 works with bit patterns. In principle, the input and output files could be binary. Problem: difficult to view and edit (for debugging). Solution: use text files. – Bit 0 is represented as character '0'. – Bit 1 is represented as character '1'. 8

Task 2 Unencoded File (in1.txt) This binary pattern contains the 7-bit ASCII codes for: "The kangaroo is an animal that lives in Australia." 9

Task 2 Encoded File (coded1.txt) This binary pattern is the parity-bit encoding for: "The kangaroo is an animal that lives in Australia." 10

Task 2 - Sample Output (1) Encoding:./a.out 0 in1.txt out1.txt Start of translation: The kangaroo is an animal that lives in Australia. End of translation 11

Task 2 - Sample Output (2) Decoding (no errors found):./a.out 1 parity1.txt out2.txt Start of translation: The kangaroo is an animal that lives in Australia. End of translation 12

Task 2 - Sample Output (3) Decoding (errors found): 1 parity2.txt out2.txt error detected at word 0 error detected at word 8 error detected at word 16 error detected at word 24 error detected at word 32 error detected at word 48 Start of translation: he kangAroo is qn animad that lmves in Australi`. End of translation 13

Practice Question 1 Goal: do encoding/decoding of a file using an error correction code. It is specified as a text file, that the program reads. Example: code1.txt: – 3 is the number of bits in each original word. – 6 is the number of bits in each codeword. – 000 gets mapped to – 001 gets mapped to – and so on

Practice Question 1 Program flow: – Read code. – Open input and output files. – While there is input data to be processed: Read the next word W1 from the input file. If (number == 0) convert W1 from original word to codeword W2. If (number == 1): – convert W1 from codeword to original word W2. – print out a message if an error was corrected or detected. Save W2 to the output file. – Close input and output files. In general_codes.c, you just have to write the functions that convert between original words and codewords. 15

Practice Question 1: Code Struct This is the datatype that we use to store a code. struct code_struct { int m; // number of bits in original word int n; // number of bits in codeword columns. char ** original; // original words char ** codebook; // legal codewords }; 16

Practice Question 1: Encoding Logic Let W1 be the original word. Find the index K of W1 among the original words in the code book. Return the codeword stored at index K among the codewords. 17

Practice Question 1: Decoding Logic Let W1 be the codeword. Find the index K of the legal codeword L most similar to W1, among all legal codewords. – If L == W1, no errors. – If L != W1: If unique L, error detected and corrected. If multiple legal codewords were as similar to W1 as L was, error detected but not corrected. Return the original word stored at index K among the original words in the code book. 18

Assignment 4 Task 1 Goal: do Hamming encoding/decoding of a file Original words: 7-bit ASCII codes. Hamming codes: 11 bits. 19

Assignment 4 Task 1 Program flow: – Open input and output files. – While there is input data to be processed: Read the next word W1 from the input file. If (number == 0) convert W1 from original word to codeword W2. If (number == 1): – convert W1 from codeword to original word W2. – print out a message if an error was corrected or detected. Save W2 to the output file. – Close input and output files. In task1.c, you just have to write the functions that convert between original words and codewords. Harder than other tasks, lines of code (or more?) 20

Assignment 4 Task 1 It is harder than Assignment 3 Task 2. Comparable to Practice Question 1 on Assignment 3. My solution is 110 lines of code. – Many of them empty lines, or lines just including a brace. 21

Assignment 4 Task 1: Encoding Encoding: (see slides on Hamming coding) Create 11-bit word. Copy the 7 bits of the original word to the corresponding positions in the 11-bit word. Compute the value for each of the extra four bits. 22

Assignment 4 Task 1: Decoding Decoding: (again, see slides on Hamming coding) Input: 11-bit Hamming codeword. You do four parity checks (on four different sets of bits). If all four parity checks are correct, no errors. If one or more parity checks are incorrect: – Compute the position of the error. – Change the bit value at that position. Create 7-bit word. Copy to the 7-bit word the appropriate positions from the 11-bit codeword. 23