- Tuesday 3/18
- Thursday 3/20
- finish Class 15 slides (Y86 ISA)
- Tuesday 4/1
- Thursday 4/3
(Added 3/17/08)
Reading for Weeks 9, 10:
Chapter 3, Sections 3.12, 3.13, 4.1, 4.2, 4.3
(Added 3/16/08)
Homework 3 question and answer
- Question:
Dear Professor,
For the subfac.s program, it seems impossible to get it down to 50 bytes given that just the following statement:
.globl _subfac
_subfac:
pushl %ebp
movl %esp, %ebp
is 59 bytes. How is it possible to reduce this code even further when I haven't even added the body yet?
- Answer:
The 50 bytes are bytes of object code. The assignment says:
To see your code, use
gcc subfac.s -c
to produce object file
subfac.o ,
then use
objdump -d subfac.o .
This will show your assembly code and the machine code that it produces, with addresses.
Looking at the addresses will tell you how many bytes of object code there are. Here is the
output for your example.
subfac.o: file format coff-go32
Disassembly of section .text:
00000000 <_subfac>:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3:
The addresses are in the first column. Your code is at addresses 0 through 2.
The pushl instruction takes 1 byte (55) and the movl takes 2 bytes (89 e5).
So you have 47 more bytes to work with. But don't worry too much about counting bytes
until you have the program written and working. Then look it over and see if you can get
the same function with fewer bytes of object code. But this is secondary to getting the assembly
code written and working.
(Added 3/10/08)
Slides for week 8:
(Added 3/06/08)
Homework 3
(Added 3/06/08)
Slides 12 and 13 correction
Typos have been corrected in the posted slides for Class 12 and Class 13.
If you downloaded them before 3:15pm on 3/6, please do it again.
(Added 3/05/08)
Slides for week 8:
- Tuesday
- Thursday
- midterm exam #1
- bring calculator, 1 8.5 x 11 page notes (two sided)
- closed book, no computers or electronic gadgets
(Added 3/04/08)
Slides for week 7:
- Tuesday
- Thursday
- finish Class 12 slides (hw 2 and review)
(Added 3/04/08)
Reading for Week 7:
Chapter 3, Sections 3.8, 3.9
(Added 3/03/08)
Homework 2 solutions:
are posted.
floatparts.c,
buildfloat.c,
Problems 2 key.doc
The grading script is available:
hw2grade.bat
You need to use the id and password that were given in class.
(Added 3/02/08)
Midterm date clarification
There was a conflict between the dates on the Green Sheet and the Semester Schedule.
The correct date for the first midterm is Thursday, March 13.
(Added 2/26/08)
Homework 2 correction
Another typo has been corrected in Problem 2. If you have downloaded the problems, please do it again.
(Added 2/27/08)
Slides for week 6:
(Added 2/21/08)
Homework 2 due date change
Homework 2 is due on Thursday, Feb. 28 instead of Tuesday Feb. 26.
(Added 2/20/08)
Homework 2 correction
A typo has been corrected in Problem 2. If you have downloaded the problems, please do it again.
(Added 2/20/08)
Homework 2 clarifications
The following is my answer to a student's question. It might be useful to others working on HW #2.
The arguments to floatparts/dblparts are (decimal) floating point numbers as they would be printed
by a C program using %f or %g formats. You are correct that you can produce answers
for the "binary" column of Problem 1 by applying floatparts/dblparts to the number in the "decimal"
column and converting the resulting hex significand to binary, adjusting the binary point
according to the exponent.
The third argument to buildfloat/builddbl is a hex number with 0 or 1 to the left of the hex point
and 6 (13 for dbl) hex digits to the right of it. The very last bit of the sixth hex digit in the float
case is not used, since only 23 binary digits are needed for the float. You may assume that
inputs will have the full number of digits (6 or 13) beyond the hex point. I don't want to make
your programs even more complex by handling the case of fewer digits.
(My program treats 1.8 as 1.000008, which is not ideal. But it handles 1.800000 just fine.)
You are correct about the 1.[270] problem. The repetition period of the binary expansion is 36.
It is much easier to get the fraction by computing in decimal.
Use 10^3 where you used 2^36, and you get the same fraction much quicker.
It is a goof on my part that the binary expansion does not come out with a shorter period. I did not
intend that problem to be so hard. (Using floatparts or a calculator might help students who haven't
written dblparts. 23 bits will be good enough. I will grade this one answer,
binary expansion of 1.[270], as extra credit.)
(Added 2/19/08)
Homework 1 solutions:
are posted.
d2h.c,
h2d.c,
run_test_show_bytes.c,
exam_style key.doc
The grading script is available:
hw1grade.bat
You need to use the id and password that were given in class.
Send me e-mail if you missed class and did not get them.
(Added 2/18/08)
Slides for week 5:
- Tuesday
- continuing with Class 7 slides (assembly language)
- Thursday Class 9 slides (control flow in assembly)
(Added 2/18/08)
Reading for Week 5:
Chapter 3, Sections 3.5, 3.6, 3.7
(Added 2/14/08)
Homework
(Added 2/11/08)
Slides for week 4:
- Tuesday
- continuing with Class 5 slides (floating point)
- Thursday Class 7 slides (assembly language)
(Added 2/11/08)
Reading for Thursday, February 14:
Chapter 3, Sections 3.1, 3.2, 3.3, 3.4
(Added 2/07/08)
Downloading gcc:
The easiest way to set up gcc on your computer is to do the following.
- Follow the djgpp link from the Green Sheet
- Select Zip Picker (second link on the djgpp page)
- Pick the delorie ftp site from the menu provided (or pick its html site)
- Leave other settings at default values (deselecting RHIDE is ok)
- Hit "Tell me which files I need"
- Download the listed files into a folder c:/DJGPP/ or c:/Program Files/DJGPP/
- Read the file readme.1st and follow its instrucitons.
You will unzip several .zip files and edit the PATH settings.
At this point you should have a file /DJGPP/bin/gcc.exe along with many others.
- You don't need a special editor; any simple text editor will work to create your
source files: notepad and wordpad both work for me.
(Added 2/04/08)
Slides for week 3:
Homework 1 has been updated to clarify the requirements for the programs.
- Tuesday
- Thursday Class 5 slides (floating point)
(Added 1/27/08)
Reading for Tuesday, February 5:
Reading for Thursday, February 7:
Finish Chapter 2, Sections 2.4, 2.5
(Added 1/31/08)
Homework
(Added 1/27/08)
Slides for week 2:
(Added 1/27/08)
Reading for Tuesday, January 29:
Read Chapter 1. Preview the C language resources listed above.
Reading for Thursday, January 31:
Read Chapter 2, Sections 2.1, 2.2, 2.3
(Added 1/13/08)
C Language Resources:
(Added 1/13/08) Here is the first set of slides:
Preliminary Material and Information for the Course
Format of this file:
You can tell whether this file has changed since you last looked at
it by checking the Last update information at the top. I will
always
add new material to this file at the top, just under the Last update
line, and will generally mark the newest material with the
thumbnail
graphic. I will also put a horizontal bar between things added to this
file at different times. So, for example, your first assignment in this
course
in my standard format looks like this:
(Added 1/23/08) Assignment for
Tuesday, January 29:
Read Chapter 1. Preview the C language resources listed above.