Assembler equivalents virgo for common c control flow

Assignment Help Assembly Language
Reference no: EM131111860

In this Lab you will code 8086 assembler equivalents (Virgo) for common C control flow instructions. This will give you an appreciation for how control flow is implemented in assembly (and machine) language. You will find that it is not quite as simple as it is with a high- level language. See special instructions for submission at the end of this file.

This lab contains a BONUS section worth an additional 4 points on your final mark!

Here is a list of the C instructions for which you will code assembly language equivalents:

If statement

C code

if (condition) { statements

}

If-Else statement

C code

if (condition) { then_statements

} else { else_statements

}

While loop

C code

while (condition) { statements

}

 

Do-While loopC code do {
statements

} while (condition);

For loop

C code

for (initialization; condition; increment) { statements

}

Switch statement

C code

switch (expression) { case val_1:
case_1_statements

case val_2: case_2_statements

.

.

.

case val_n: case_n_statements

default: default_statements
}

Normally, C Switch statements have a Break statement at the end of each case.

You will also need to implement Break and Continue statements which can be used inside some of these control flow instructions.

Break statements

A Break statement can occur inside a C loop or Switch statement. It is implemented as an unconditional branch to a label immediately following the loop or Switch statement.

Continue statements

A Continue statement can occur inside a C loop . For While and Do-While loops, it is implemented as an unconditional branch to a label for the condition test of the While or Do-While statement.

A Continue statement in a For loop is implemented as an unconditional branch to a label immediately preceding the code to implement the increment statement.

Note that the assembly code you develop for these C-structure equivalents need only be shown as pseudo-code; that is, since the actual conditions are not given, neither the test for the condition nor the jump statement for this test can actually be shown. Typically, the test will be some sort of compare (cmp) instruction and the jump will be one of the many jmp variants. It is only necessary to state that a test must be done at a certain point and that a jump relating to that test should then be done at some other point. In the second and third parts of the assignment, you will code and test two of these instructions using actual assembly language.

Coding for the IF statement is given below as an example of the syntax required. Use a similar syntax for the remaining control flow instructions.

If statement

C code

if (condition) { statements
}

Assembler pseudo-code

IF:

test condition

jump to Next if false assembly code for statements

Next:

Part A) Write pseudo-code for the remaining five control flow statements given above and for the Break and Continue statements.

Part B) Code a Do-While loop for the following C-code example in Virgo assembly language (assume int's are words of 2 bytes). Place each C-code statement at the appropriate place in your assembly code as a comment:

int x = 0;

do
{
x++;

if (x == 5) continue; sum += x;

} while (x < 10);

Bonus) Code a Switch statement for the following C-code example in assembly language (assume int's are words of 2 bytes). Place each C-code statement at the appropriate place in your assembly code as a comment:

int a;

int b = 0x12; int c = 0x34;

int p = some constant value;

switch (p)

{

case 0: a = b + c; break; case 1: a = b - c; break; case 3: a = b; break; case 7: a = c; break; default: a = 0;
}

Reference no: EM131111860

Questions Cloud

Leadership and ethics : Leaders are constantly faced with making challenging decisions. Sometimes the decisions are difficult due to how they affect others; other times, the decisions are difficult because of ethical concerns.
Influence of entertainment media : Write a 400- to 700-word paper in which you investigate the interrelationship between the entertainment media and culture. Answer the following questions:
Construct a boxplot of the dataset : Construct a boxplot of the dataset - List the number of outcomes in the sample space when you roll both dice.
Various leadership theories in relationship : In this module, you looked at various leadership theories in relationship to how to effectively manage. In this assignment, you will review the Managing Teams video and then compare and contrast the Situational Approach to leadership with the Styl..
Assembler equivalents virgo for common c control flow : Assembler equivalents (Virgo) for common C control flow instructions. This will give you an appreciation for how control flow is implemented in assembly (and machine) language. You will find that it is not quite as simple as it is with a high- level ..
Style and situational leadership : In this module you learned about the Style and Situational approaches to leadership. In this assignment, you will provide your analysis of the two approaches and discuss the best of the two approaches to your chosen organization.
Basic characteristics of segmented buyers : What are the basic characteristics of segmented buyers in a given business market?
A prompt to help guide you with your writing : This is just a prompt to help guide you with your writing; you do not need to answer all of these questions. If you want to write about a different aspect of the readings and the film, you can do so, but make sure that it pertains to the film and ..
Qualitative and quantitative possibilities : In an effort to increase their business, WWR drops its price to $40 per rafter and expects to serve 6,000 rafters, leaving your company (BWR) with the remaining 2,000 rafters. What do you do? Can you meet that price? Can you charge less than $39? ..

Reviews

Write a Review

Assembly Language Questions & Answers

  Design an expanding opcode to allow to be encoded

Design an expanding opcode to allow all the following to be encoded in a 32-bit in- struction: 15 instructions with two 12-bit addresses and one 4-bit register number 650 instructions with one 12-bit address.

  Analog measurements prepare an assembly program for the

analog measurements prepare an assembly program for the correctly measures the wind direction to a precision of 45deg n

  Write a set of assembly codes in uvision

Write a set of assembly codes in uVision that performs the function described below. Begin with the assumption that 10 randomly selected integer numbers (data) are stored at 0x20002000 to 0x20002024 in sequence in the memory region.

  Displays a single character at 100 random screen

Write a program that displays a single character at 100 random screen locations, with a delay factor of 100 milliseconds.Hint: set the console window screen height to 200 at runtime.

  Write a nonrecursive version of the factorial procedure

(Nonrecursive Factorial) Write a nonrecursive version of the Factorial procedure (Section 8.3.2) that uses a loop. (A VideoNote for this exercise is posted on the Web site.) Write a short program that interactively tests your Factorial procedure.

  Write code for an assembly language function

Write code for an assembly language function named rot_left which rotates a given integer (provided in R6 by a value given in R12. The result should be returned in R4.

  Prepare an assembly program that reads in a number of cents

prepare an assembly program that reads in a number of cents. the program will write out the number of dollars and cents

  Cache statistics for two versions of matrix multiplication

Explore the cache statistics for two versions of matrix multiplication - Cache can be configured using the preference in ARMSim. For getting cache statistics, first put a breakpoint on SWI 0x11 instruction, and then note the statistics from cache

  Motorola assembly language

The objective is to review the programmer's model, the Motorola assembly language, and the instruction execution cycle. To achieve these objectives, you will write a short program(s) satisfying the requirements below

  Give a disadvantage of self-modifying code

Devise an addressing mechanism that allows an arbitrary set of 64 addresses, not nec- essarily contiguous, in a large address space to be specifiable in a 6-bit field. Give a disadvantage of self-modifying code that was not mentioned in the text..

  Create a short assembly program

You need to create a short assembly program named char_int, stored in file char_int.asm, that prompts the user for a character, and then for an integer.

  Advantage of assembly and high-level programming languages?

What are the advantages and disadvantage of assembly and high-level programming languages?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd