The following guidelines are expected for all homework submissions:
all over the mapon my computer or printer. USE SPACES INSTEAD. You can set up almost every modern text editor to insert spaces whenever you press the TAB key, or you can simply pound the spacebar.
pair programmingwhich is part of the Extreme Programming [Agile] software development method. Feel free to collaborate in your pairs as much as you want, doing the entire assignment together. Only submit ONE copy for the both of you.
stanley/penguin
language as your
guide, write an assembly program using nasm called findGCD.nasm
which
will find the GCD of the two numbers 3113041662
and 11570925
. Read the
two numbers from the keyboard at port stdinusing the
scanf()
function from the
Cstandard library and a format string. Write the result to port
stdoutusing the
printf()
function from the Cstandard library and a different format string.
Cprogram. Then write a program
gcdFinder.c
containing
the code in Cto call your function. Use the
assert()
functions from
the Clibrary. You can link this into your program by
#include <assert.h>
as you've seen in class. Your assembly code should take the two numbers as arguments which are
passed from the Ccode.
1in a sequence of bits. It is used to help guarantee that nothing has gone wrong with the bit sequence during transmission. Parity is calculated based on the number of
1bits in a byte, and a ninth bit, the parity bit, is either set or cleared to achieve the proper parity, either even or odd. For example, for the byte
01101001
, assuming even
parity, the parity bit would be cleared so that the count of 1bits remains even for all nine bits; for the byte
10101110
,
assuming even parity, the parity bit would be set so that the count of
1bits remains even. Note that the parity bit IS NOT PART of the byte, IT IS A NINTH BIT which is separate.
paritygen.nasm
that will count the
onebits in a byte of data and print the proper value for the parity bit assuming we are using odd parity. Use a call to the
printf()
Cfunction to display the result. You may use whatever number you wish, hard-coded into your program, just make sure there are a few bits that are "1" in it somewhere.
All-zeroor
all-onevalues are probably not the best to use…
Cprogram
whichEndIsUp.c
that will
determine whether your computer is big-endian or little-endian.
Cfunction
makeNBOC.c
that takes an
unsigned integer as argument and puts it into network byte order, then returns the result. You can
include your code from the previous problem as a function in your file as
well. Then in another file, make a program in Ccalled
makeNBOCtest.c
that reads
an UNSIGNED 32-BIT INTEGER number from the command line arguments and swaps its byte order by calling
your new function from the other file. You only need to swap the byte order if that is necessary.
NOTE: at the last minute, I realized that you should NOT have a main()
method in the
function file, only in the test program file,
so don't do that or it will play havoc with the next problem. Also note the name change on the
function file from makeNBO.c
to makeNBOC.c
.
makeNBO.nasm
which does the
byte order swapping BY CALLING YOUR Cfunction. Make your nasm program call the function at least five times with different values to test it. Feel free to hard-code whatever values you wish in the program, but try to use values that you can easily see the swapping occur. Usually hexadecimal values are best for this.