ece330_f10_hw6

ece330_f10_hw6 - ECE 330 Due: 10/04/2010 Homework 6 Fall...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE 330 Homework 6 Fall 2010 Due: 10/04/2010 Page 1 of 3 1. Observe the output for the code in Code 1 below and answer the following questions. // file: hw6.c #include <stdio.h> int main() { unsigned int wa[] = { 0x41424344, 0x51525354, 0x61626364, 0x0 }; int i; unsigned int *pwa; unsigned short *psa; unsigned char *pba; puts( "ECE 330 Homework 6" ); pwa = ( unsigned int *) &wa; psa = ( unsigned short *) &wa; pba = ( unsigned char *) &wa; // Loop 1 for ( i=0; i< sizeof (wa)/ sizeof (wa[0]); i++ ) printf ( "wa[%d]=0x%08x\n" , i, wa[i] ); // Loop 2 while ( *pwa != 0 ) printf ( "%x\n" , *pwa++ ); // Loop 3 while ( *psa != 0 ) printf ( "%x\n" , *psa++ ); // Loop 4 while ( *pba != 0 ) { printf ( "%c[%x] " , *pba, *pba ); pba++; } putchar( '\n' ); printf( "\nall done\n" ); return 0; } Code 1. For each of the loops (4) in Code 1. capture the assembly code produced. Note how the pointers (pwa, psa, pba) are initialized and incremented for each. Questions.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

ece330_f10_hw6 - ECE 330 Due: 10/04/2010 Homework 6 Fall...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online