if you want to remove an article from website contact us from top.

    show machine code generated for following assembly level program along with data structures entries


    Guys, does anyone know the answer?

    get show machine code generated for following assembly level program along with data structures entries from screen.


    Assembly - Quick Guide, Each personal computer has a microprocessor that manages the computer's arithmetical, logical, and control activities.

    Assembly - Quick Guide

    Advertisements Previous Page Next Page

    Assembly - Introduction

    Assembly - Introduction What is Assembly Language?

    Each personal computer has a microprocessor that manages the computer's arithmetical, logical, and control activities.

    Each family of processors has its own set of instructions for handling various operations such as getting input from keyboard, displaying information on screen and performing various other jobs. These set of instructions are called 'machine language instructions'.

    A processor understands only machine language instructions, which are strings of 1's and 0's. However, machine language is too obscure and complex for using in software development. So, the low-level assembly language is designed for a specific family of processors that represents various instructions in symbolic code and a more understandable form.

    Advantages of Assembly Language

    Having an understanding of assembly language makes one aware of −

    How programs interface with OS, processor, and BIOS;

    How data is represented in memory and other external devices;

    How the processor accesses and executes instruction;

    How instructions access and process data;

    How a program accesses external devices.

    Other advantages of using assembly language are −

    It requires less memory and execution time;

    It allows hardware-specific complex jobs in an easier way;

    It is suitable for time-critical jobs;

    It is most suitable for writing interrupt service routines and other memory resident programs.

    Basic Features of PC Hardware

    The main internal hardware of a PC consists of processor, memory, and registers. Registers are processor components that hold data and address. To execute a program, the system copies it from the external device into the internal memory. The processor executes the program instructions.

    The fundamental unit of computer storage is a bit; it could be ON (1) or OFF (0) and a group of 8 related bits makes a byte on most of the modern computers.

    So, the parity bit is used to make the number of bits in a byte odd. If the parity is even, the system assumes that there had been a parity error (though rare), which might have been caused due to hardware fault or electrical disturbance.

    The processor supports the following data sizes −

    Word: a 2-byte data item

    Doubleword: a 4-byte (32 bit) data item

    Quadword: an 8-byte (64 bit) data item

    Paragraph: a 16-byte (128 bit) area

    Kilobyte: 1024 bytes

    Megabyte: 1,048,576 bytes

    Binary Number System

    Every number system uses positional notation, i.e., each position in which a digit is written has a different positional value. Each position is power of the base, which is 2 for binary number system, and these powers begin at 0 and increase by 1.

    The following table shows the positional values for an 8-bit binary number, where all bits are set ON.

    Bit value 1 1 1 1 1 1 1 1

    Position value as a power of base 2 128 64 32 16 8 4 2 1

    Bit number 7 6 5 4 3 2 1 0

    The value of a binary number is based on the presence of 1 bits and their positional value. So, the value of a given binary number is −

    1 + 2 + 4 + 8 +16 + 32 + 64 + 128 = 255

    which is same as 28 - 1.

    Hexadecimal Number System

    Hexadecimal number system uses base 16. The digits in this system range from 0 to 15. By convention, the letters A through F is used to represent the hexadecimal digits corresponding to decimal values 10 through 15.

    Hexadecimal numbers in computing is used for abbreviating lengthy binary representations. Basically, hexadecimal number system represents a binary data by dividing each byte in half and expressing the value of each half-byte. The following table provides the decimal, binary, and hexadecimal equivalents −

    Decimal number Binary representation Hexadecimal representation

    0 0 0 1 1 1 2 10 2 3 11 3 4 100 4 5 101 5 6 110 6 7 111 7 8 1000 8 9 1001 9 10 1010 A 11 1011 B 12 1100 C 13 1101 D 14 1110 E 15 1111 F

    To convert a binary number to its hexadecimal equivalent, break it into groups of 4 consecutive groups each, starting from the right, and write those groups over the corresponding digits of the hexadecimal number.

    Example − Binary number 1000 1100 1101 0001 is equivalent to hexadecimal - 8CD1

    To convert a hexadecimal number to binary, just write each hexadecimal digit into its 4-digit binary equivalent.

    Example − Hexadecimal number FAD8 is equivalent to binary - 1111 1010 1101 1000

    Binary Arithmetic

    The following table illustrates four simple rules for binary addition −

    (i) (ii) (iii) (iv) 1 0 1 1 1 +0 +0 +1 +1 =0 =1 =10 =11

    Rules (iii) and (iv) show a carry of a 1-bit into the next left position.


    Decimal Binary 60 00111100 +42 00101010 102 01100110

    A negative binary value is expressed in two's complement notation. According to this rule, to convert a binary number to its negative value is to .


    Number 53 00110101

    Reverse the bits 11001010

    Add 1 00000001 Number -53 11001011

    To subtract one value from another, .


    Subtract 42 from 53 Number 53 00110101

    स्रोत : www.tutorialspoint.com

    Introduction of Assembler

    A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.

    Introduction of Assembler

    Difficulty Level : Easy

    Last Updated : 21 Aug, 2019

    Assembler is a program for converting instructions written in low-level assembly code into relocatable machine code and generating along information for the loader.

    It generates instructions by evaluating the mnemonics (symbols) in operation field and find the value of symbol and literals to produce machine code. Now, if assembler do all this work in one scan then it is called single pass assembler, otherwise if it does in multiple scans then called multiple pass assembler. Here assembler divide these tasks in two passes:


    Define symbols and literals and remember them in symbol table and literal table respectively.

    Keep track of location counter

    Process pseudo-operations


    Generate object code by converting symbolic op-code into respective numeric op-code

    Generate data for literals and look for values of symbols

    Firstly, We will take a small assembly language program to understand the working in their respective passes. Assembly language statement format:

    [Label] [Opcode] [operand]

    Example: M ADD R1, ='3'

    where, M - Label; ADD - symbolic opcode;

    R1 - symbolic register operand; (='3') - Literal

    Assembly Program:

    Label Op-code operand LC value(Location counter)

    JOHN START 200

    MOVER R1, ='3' 200

    MOVEM R1, X 201

    L1 MOVER R2, ='2' 202

    LTORG 203

    X DS 1 204

    END 205

    Let’s take a look on how this program is working:

    START: This instruction starts the execution of program from location 200 and label with START provides name for the program.(JOHN is name for program)MOVER: It moves the content of literal(=’3′) into register operand R1.MOVEM: It moves the content of register into memory operand(X).MOVER: It again moves the content of literal(=’2′) into register operand R2 and its label is specified as L1.LTORG: It assigns address to literals(current LC value).DS(Data Space): It assigns a data space of 1 to Symbol X.END: It finishes the program execution.Working of Pass-1: Define Symbol and literal table with their addresses.

    Note: Literal address is specified by LTORG or END.

    Step-1: START 200 (here no symbol or literal is found so both table would be empty)Step-2: MOVER R1, =’3′ 200 ( =’3′ is a literal so literal table is made)

    Literal Address =’3′ – – –

    Step-3: MOVEM R1, X 201

    X is a symbol referred prior to its declaration so it is stored in symbol table with blank address field.

    Symbol Address X – – –

    Step-4: L1 MOVER R2, =’2′ 202

    L1 is a label and =’2′ is a literal so store them in respective tables

    Symbol Address X – – – L1 202 Literal Address =’3′ – – – =’2′ – – –

    Step-5: LTORG 203

    Assign address to first literal specified by LC value, i.e., 203

    Literal Address =’3′ 203 =’2′ – – –

    Step-6: X DS 1 204

    It is a data declaration statement i.e X is assigned data space of 1. But X is a symbol which was referred earlier in step 3 and defined in step 6.This condition is called Forward Reference Problem where variable is referred prior to its declaration and can be solved by back-patching. So now assembler will assign X the address specified by LC value of current step.

    Symbol Address X 204 L1 202

    Step-7: END 205

    Program finishes execution and remaining literal will get address specified by LC value of END instruction. Here is the complete symbol and literal table made by pass 1 of assembler.

    Symbol Address X 204 L1 202 Literal Address =’3′ 203 =’2′ 205

    Now tables generated by pass 1 along with their LC value will go to pass-2 of assembler for further processing of pseudo-opcodes and machine op-codes.

    Working of Pass-2:

    Pass-2 of assembler generates machine code by converting symbolic machine-opcodes into their respective bit configuration(machine understandable form). It stores all machine-opcodes in MOT table (op-code table) with symbolic code, their length and their bit configuration. It will also process pseudo-ops and will store them in POT table(pseudo-op table).

    Various Data bases required by pass-2:

    1. MOT table(machine opcode table)

    2. POT table(pseudo opcode table)

    3. Base table(storing value of base register)

    4. LC ( location counter)

    Take a look at flowchart to understand:

    As a whole assembler works as:

    स्रोत : www.geeksforgeeks.org

    Program Location Counter

    Program Location Counter

    Program Location Counter Related terms:

    Arithmetic Logic UnitCompilerAssembly CodeCentral Processing UnitSubroutinesTimer Interrupt

    View all Topics

    Program Design and Analysis

    Marilyn Wolf, in Computers as Components (Third Edition), 2012

    5.4 Assembly, Linking, and Loading

    Assembly and linking are the last steps in the compilation process—they turn a list of instructions into an image of the program's bits in memory. Loading actually puts the program in memory so that it can be executed. In this section, we survey the basic techniques required for assembly linking to help us understand the complete compilation and loading process.

    Program generation work flow

    Figure 5.10 highlights the role of assemblers and linkers in the compilation process. This process is often hidden from us by compilation commands that do everything required to generate an executable program. As the figure shows, most compilers do not directly generate machine code, but instead create the instruction-level program in the form of human-readable assembly language. Generating assembly language rather than binary instructions frees the compiler writer from details extraneous to the compilation process, which includes the instruction format as well as the exact addresses of instructions and data. The assembler's job is to translate symbolic assembly language statements into bit-level representations of instructions known as object code. The assembler takes care of instruction formats and does part of the job of translating labels into addresses. However, because the program may be built from many files, the final steps in determining the addresses of instructions and data are performed by the linker, which produces an executable binary file. That file may not necessarily be located in the CPU's memory, however, unless the linker happens to create the executable directly in RAM. The program that brings the program into memory for execution is called a loader.

    Sign in to download full-size image

    Figure 5.10. Program generation from compilation through loading.

    Absolute and relative addresses

    The simplest form of the assembler assumes that the starting address of the assembly language program has been specified by the programmer. The addresses in such a program are known as absolute addresses. However, in many cases, particularly when we are creating an executable out of several component files, we do not want to specify the starting addresses for all the modules before assembly—if we did, we would have to determine before assembly not only the length of each program in memory but also the order in which they would be linked into the program. Most assemblers therefore allow us to use relative addresses by specifying at the start of the file that the origin of the assembly language module is to be computed later. Addresses within the module are then computed relative to the start of the module. The linker is then responsible for translating relative addresses into addresses.

    5.4.1 Assemblers

    When translating assembly code into object code, the assembler must translate opcodes and format the bits in each instruction, and translate labels into addresses. In this section, we review the translation of assembly language into binary.

    Labels make the assembly process more complex, but they are the most important abstraction provided by the assembler. Labels let the programmer (a human programmer or a compiler generating assembly code) avoid worrying about the locations of instructions and data. Label processing requires making two passes through the assembly source code:


    The first pass scans the code to determine the address of each label.


    The second pass assembles the instructions using the label values computed in the first pass.

    Symbol table

    As shown in Figure 5.11, the name of each symbol and its address is stored in a symbol table that is built during the first pass. The symbol table is built by scanning from the first instruction to the last. (For the moment, we assume that we know the address of the first instruction in the program.) During scanning, the current location in memory is kept in a program location counter (PLC). Despite the similarity in name to a program counter, the PLC is not used to execute the program, only to assign memory locations to labels. For example, the PLC always makes exactly one pass through the program, whereas the program counter makes many passes over code in a loop. Thus, at the start of the first pass, the PLC is set to the program's starting address and the assembler looks at the first line. After examining the line, the assembler updates the PLC to the next location (because ARM instructions are four bytes long, the PLC would be incremented by four) and looks at the next instruction. If the instruction begins with a label, a new entry is made in the symbol table, which includes the label name and its value. The value of the label is equal to the current value of the PLC. At the end of the first pass, the assembler rewinds to the beginning of the assembly language file to make the second pass. During the second pass, when a label name is found, the label is looked up in the symbol table and its value substituted into the appropriate place in the instruction.

    स्रोत : www.sciencedirect.com

    Do you want to see answer or more ?
    Mohammed 5 month ago

    Guys, does anyone know the answer?

    Click For Answer