1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lyudmila [28]
1 year ago
8

Translate the following C program to Pep/9 assembly language.

Computers and Technology
1 answer:
docker41 [41]1 year ago
8 0

In this exercise we have to use the knowledge of computational language in C code to write a code that Translate the following C program to Pep/9 assembly language.

<h3>Writting the code:</h3>

  • In C code:

<em>#include <stdio.h></em>

<em>int myAge;</em>

<em>void </em><em>putNext</em><em>(int age) {</em>

<em>int nextYr;</em>

<em>nextYr = age + 1;</em>

<em>printf("Age: %d\n", age);</em>

<em>printf("Age next year: %d\n", nextYr);</em>

<em>}</em>

<em>int </em><em>main </em><em>() {</em>

<em>scanf("%d", &myAge);</em>

<em>putNext(myAge);</em>

<em>putNext(64);</em>

<em>return 0;</em>

<em>}</em>

  • In Pep 9 CODE-

<em>myAge:</em>

<em>.zero 4</em>

<em>.LC0:</em>

<em>.</em><em>string </em><em>"Age: %d\n"</em>

<em>.LC1:</em>

<em>.string "Age </em><em>next </em><em>year: %d\n"</em>

<em>_Z7putNexti:</em>

<em>pushq %rbp</em>

<em>movq %rsp, %rbp</em>

<em>subq $32, %rsp</em>

<em>movl %edi, -20(%rbp)</em>

<em>movl -20(%rbp), %eax</em>

<em>addl $1, %eax</em>

<em>movl %eax, -4(%rbp)</em>

<em>movl -20(%rbp), %eax</em>

<em>movl %eax, %esi</em>

<em>movl $.LC0, %edi</em>

<em>movl $0, %eax</em>

<em>call printf</em>

<em>movl -4(%rbp), %eax</em>

<em>movl %eax, %esi</em>

<em>movl $.LC1, %edi</em>

<em>movl $0, %eax</em>

<em>call printf</em>

<em>nop</em>

<em>leave</em>

<em>ret</em>

<em>.LC2:</em>

<em>.</em><em>string </em><em>"%d"</em>

<em>main:</em>

<em>pushq %rbp</em>

<em>movq %rsp, %rbp</em>

<em>movl $myAge, %esi</em>

<em>movl $.LC2, %edi</em>

<em>movl $0, %eax</em>

<em>call scanf</em>

<em>movl myAge(%rip), %eax</em>

<em>movl %eax, %edi</em>

<em>call _Z7putNexti</em>

<em>movl $64, %edi</em>

<em>call _Z7putNexti</em>

<em>movl $0, %eax</em>

<em>popq %rbp</em>

<em>ret</em>

See more about C code at  brainly.com/question/18502436

#SPJ1

You might be interested in
Premise: Tracy has a file that contains a list of actors and the movies in which they acted. She wants to know the top 3 ranked
anzhelika [568]

Answer:

see explaination

Explanation:

Python version : 2.7

Python program to read an input file with specified number of records to read

and output the top 3 ranked actors

The format of input file:

<number of records to read>

<actor_name>,<movie_name>

<actor_name>,<movie_name>

....

'''

#define the file name

filename = 'actors_movies.txt'

# create an empty dictionary to contain the actor name as key and number of movies they have acted as value

actors_movie_count = {}

# open the flie

fp = open(filename)

line = fp.readline() # read the first line

count = int(line)

i = 0

# loop to read count number of lines from file

while i < count:

line = fp.readline() # read a line

data = line.split(",") # split the input data into list of strings using comma as the delimiter

# check if actor name is present in the dictionary, then add 1 to its value

# strip is used to remove any leading or trailing space

if data[0].strip() in actors_movie_count:

actors_movie_count[data[0].strip()] += 1

else: # else insert a new record with actor name as its key and 1 as value

actors_movie_count[data[0].strip()] = 1

i += 1

# close the file

fp.close()

# get the list of names of actors and list of number of movies they have acted

actors = actors_movie_count.keys()

num_movies = actors_movie_count.values()

# loop to sort the actors list and num_movies list in descending order of count of movies

for i in range(len(num_movies)-1):

max = i

for j in range(i+1,len(num_movies)):

if num_movies[j] > num_movies[max]:

max = j

if max != i:

actors[max], actors[i] = actors[i], actors[max]

num_movies[max], num_movies[i] = num_movies[i], num_movies[max]

# rank the actors to add top 3 ranked actors to rank_actors list

rank = 1

rank_actors = []

# add the first actor to list

rank_actors.append(actors[0])

# loop from second to end of actors list

for i in range(1,len(actors)):

# if this actor has same number of movies as the actor before him, then assign same rank

if num_movies[i] == num_movies[i-1]:

# if rank <= 3, add the actor in rank_actors list

if rank <= 3:

rank_actors.append(actors[i])

else: # rank > 3, exit the loop

break

else: # assign 1 more rank that the previous

rank += 1

# if rank <= 3, add the actor in rank_actors list

if rank <= 3:

rank_actors.append(actors[i])

else: # rank > 3, exit the loop

break

# loop to display the top 3 ranked actors

for actor in rank_actors:

print(actor)

#end of program

see attachment for the program screenshot and output

5 0
3 years ago
I was killed <br><br> යඞ <br><br> what do i do
KiRa [710]
Answer:

Ok all you have to do is live if you died , very simple and basic anyone can do it
8 0
3 years ago
54 points!!! Cyber security
Veseljchak [2.6K]

Answer:

a

Explanation:

3 0
3 years ago
What is the hexadecimal equivalent of the decimal number 256?
svp [43]

Answer:

0.100 look it up

Explanation:

3 0
3 years ago
Explain the components of Information System?​
slavikrds [6]

Answer:

An information system is essentially made up of five components hardware, software, database, network and people. These five components integrate to perform input, process, output, feedback and control. Hardware consists of input/output device, processor, operating system and media devices.

Explanation:

7 0
3 years ago
Other questions:
  • If you are planning to carry a large balance on your credit card, which of the following credit card features should you look fo
    7·2 answers
  • What does this say:<br> √ans
    6·2 answers
  • HELP 25 POINTS!!!!!
    6·2 answers
  • Briefly summarize two examples of cybercrime stories.<br> quick pleaseeee
    10·1 answer
  • What are the advantages of customer relationship managment​
    10·1 answer
  • Describe how data is transmitted using half-duplex serial data transmission.
    9·1 answer
  • What are the benefits and risks of a client-server network?
    5·1 answer
  • EMERGENCY- I am giving 55 points for this, please help. WITH working out
    7·1 answer
  • What is Utility Software ? Name any two utility programs. <br>​
    15·2 answers
  • Instant Search can NOT be used to search through archived messages.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!