No work No points globl bar type bar function bar pushl ebp movl esp ebp movl

No work no points globl bar type bar function bar

  • Rutgers University
  • CS 211
  • Test Prep
  • HimadriB
  • 13
  • 100% (20) 20 out of 20 people found this document helpful

This preview shows page 4 - 8 out of 13 pages.

the assembly statements. No work. No points..globl bar.typebar, @functionbar:pushl%ebpmovl%esp, %ebpmovl8(%ebp), %eaxaddl$10, %eaxpopl%ebpret.globl foo.typefoo, @functionfoo:pushl%ebpmovl%esp, %ebpsubl$24, %espmovl%ebx, -8(%ebp)movl%esi, -4(%ebp)movl8(%ebp), %ebxmovl$1, %eaxcmpl$1, %ebxjle.L5movl%ebx, (%esp)callbarmovl%eax, %esisubl$1, %ebxmovl%ebx, (%esp)callfooimull%esi, %eax.L5:movl-8(%ebp), %ebxmovl-4(%ebp), %esimovl%ebp, %esppopl%ebpret4
Background image
2. (5 points) Write the simplified version of the C code to accomplish the same function?5
Background image
Problem 3: Diffusing the Assembly Bomb (25 points)The bomblab designer was upset that a significant portion of the students in his class openly collaborated(and likely cheated) instead of learning the expected skills. To identify the students who learned the expectedskills, the bomblab designer has designed the following question that tests the skills learned.As with the bomblab, you have to devise the inputs to this program. There are multiple inputs that solvethis phase namedfoo.Identify all the inputs that would defuse this phase. The functionexplodebombhas the same behavior as in bomblab. The functionsscanfhas the following prototype:int sscanf(const char *str, const char *format, ...);sscanfreads its input from the character string pointed to by str. It returns the number of input itemssuccessfully matched to the format and assigned. An example usage issscanf(ptr, "%d %d %d", &a, &b, &c);The function prototype of the phase is as follows:void foo(char* input);Further, the bomblab designer has ensured that this phase can indeed be diffused without requiring gdb.To help the students the bomblab designer has also annotated the assembly code.The required ASCII table for alphabets and numbers is provided for reference.ASCII codeCharacterASCII codeCharacter48’0’65’A’49’1’66’B’50’2’67’C’51’3’68’D’52’4’69’E’53’5’70’F’54’6’71’G’55’7’72’H’56’8’73’I’57’9’74’J’6
Background image
.LC0:.string "%d %c\n"### some global string.text.globl foo.typefoo, @function### phase begins herefoo:pushl%ebp### stack frame setupmovl%esp, %ebp### stack frame setupsubl$40, %esp### reserving stack spaceleal-13(%ebp), %eaxmovl%eax, 12(%esp)### sscanf has some arguments, store them on the stackleal-12(%ebp), %eaxmovl%eax, 8(%esp)### sscanf has some arguments, store them on the stackmovl$.LC0, 4(%esp)### sscanf has some arguments, store them on the stackmovl8(%ebp), %eaxmovl%eax, (%esp)
Background image
Image of page 8

You've reached the end of your free preview.

Want to read all 13 pages?

  • Spring '08
  • Chakraborty
  • ASCII, eax

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture