For this homework assignment, consider the following Pascal procedure, also shown in C for comparison:
procedure zip( a: integer; var b: char ); (void) zip( a, b ) var c: integer; int a; d: packed array[1..10] of char; char * b; begin { if a < 0 int c; then c := -a; char d[11]; else c := a; if (a < 0) { if (c > 0) and (c < 11) then begin c = -a; d := 'abcdefghij'; } else { d[c] := b; c = a; b := d[(c mod 10) + 1]; } writeln( d ); if ((c>0) && (c<11)) { end; strcpy( d, "abcdefghij" ); end; d[c-1] = *b; *b = d[(c mod 10)]; puts( d ); } }In responding to the following questions, please confine yourself to "simple brute force" translation of Pascal (or C) to assembly code. Don't try to optimize! Don't try to make effective use of registers! Pass parameters on the stack, allocate local variables on the stack, and allocate global variables statically in memory. Assume that type integer is -32768..32767.
program main( output ); char e; var e: char; begin (void) main() e := 'x'; { zip( 5, e ); e = 'x'; write( e ); zip( 5, &e ); end; putc( e ); exit(0); }
X * Y = X.L*Y.L + B*X.H*Y.L + B*X.L*Y.H + B*B*X.H*Y.H