0% found this document useful (0 votes)
18 views2 pages

Discussion Assignment Unit 7

Discussion Assignment Unit 7 - uop

Uploaded by

Majd Haddad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Discussion Assignment Unit 7

Discussion Assignment Unit 7 - uop

Uploaded by

Majd Haddad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Discussion Assignment Unit 7

CS 1104 -Computer Systems

Term 2-2021/2022

University of the People

Majd Alhaddad

For your discussion question response, please provide a response to each of the
following questions. Make sure that you include the question followed by your
answer to the question in your posting.

1. The Hack assembler is a two-pass assembler. Explain why there is a need


for going twice over the code.

An assembler is a program for converting instructions written in low-level


assembly code into portable machine code and generating information along
with the loader.

Generates instructions through symbols in the process field and finds symbol
value and letters to produce machine code. Now, if the assembler does all of
this work in one scan, it's called the single-pass assembler, otherwise, if it does
it in multiple scans, it's called the multipass assembler. Here the complex
divides these tasks into two phases:

pass 1:

 Define the symbols and glyphs and remember them in the


symbol table and the glyph table respectively.
 Location Counter Tracking
 Pseudo-operational operations

pass 2:

 Create object code by converting the symbolic reference code


to its digital reference code
 Generate data for literals and search for symbol values

2. There is a method named backpatching that solves this issue with one
pass only. Describe this method.

Backpatching can be used to create a program for logical expressions and the
flow of control statements in a single pass. In this, the compound adjectives
and non-terminal false list B are used to handle the labels in the jump symbol
for Boolean expressions.

Specifically, B.truelist will be a list of the jump or conditional jump


instructions to which you should add the label that the control goes to if B is
true. b- false list similarly is the instruction list that finally gets the label that
the controls go to when B is false.

Since the program is produced for B, the jumps to true and false are
incomplete, with the label field not populating. These elementary jumps are
found in the lists noted by B.

Similarly, the S statement has a compound attribute S.nextlist, which indicates


a list of jumps to instructions that immediately follow the S code. It can
produce instructions in an instruction array, and the labels will be pointers in
that array. To manipulate the list of jumps we use three functions −

 Makelists(i) - Creates a new list that includes only I, an index in the


instruction set; makelist returns a pointer to the newly created list.
 Merge(p1, p2) - joins the referenced lists to p1 and p2 and returns a
pointer to the concatenated list.
 Backpatch (p, i) - inserts i like the target label for each of the
instructions in the register referenced by p.

3. What are the pros and cons for one pass assembly vs. two pass assembly?

The one-pass assembler passes the source file exactly once, in the same path
collects labels, solves future references, and does the actual compilation. The
tricky part is solving future label references, known as the forward reference
problem, and compiling the code in one pass. The one-pass assembler is an
intermediate file, which is used as input by the two-pass assembler.

The two-pass assembler makes two passes over the source file and the second
pass can be over an intermediate file created in the first pass of the assembler.
In the first pass, all it does is look up the label definitions and present them in
the symbol table which is a dynamic table that includes the label name and
title for each label in the source program. In the second pass, after the symbol
table is complete, it does the actual compilation by translating the operations
into machine codes and so on.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy