Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I will teach you how to create a new project from scratch in the class in the up

ID: 3799298 • Letter: I

Question

I will teach you how to create a new project from scratch in the class in the upcoming weeks. For now, just follow these steps.

Download the program in section 3.2 from: Click here to download a zip file containing a 32-bit Visual Studio 2015 project

Do the following steps, in order:

Start Visual Studio.

To begin, open our sample Visual Studio project file by selecting File/Open/Project from the Visual Studio menu.

Navigate to your working folder where you unzipped our project file, and select the file named Project.sln.

Once the project has been opened, you will see the project name in the Solution Explorer window.

You should also see an assembly language source file in the project named AddTwo.asm

Double-click the file name to open it in the editor.

3.      You should see the AddTwo assembly program in the editor window

4.       Delete the two instruction there and then add your code in there:

.386

.model flat,stdcall

.stack 4096

ExitProcess proto,dwExitCode:dword

.code

main proc

;add your code here

invoke ExitProcess,0

main endp

5. After you added your code, select Build Project (this will assemble and link your program) from the Build menu. Make sure there are no errors and the project was built successfully

To avoid having the same project folder name in one place, you can create a folder for every part of your assignment and past the project copy there:

C:>As3Part1>Project32_VS2015

Under Project32_VS2015 you will find .asm fiel, solutions files, etc…

For part two of your assignment:

C:>As3Part2>Project32_VS2015

Under Project32_VS2015 you will find .asm fiel, solutions files, etc…

For part three of your assignment:

C:>As3Part3>Project32_VS2015

Under Project32_VS2015 you will find .asm fiel, solutions files, etc…

.386

.model flat,stdcall

.stack 4096

ExitProcess proto,dwExitCode:dword

.code

main proc

;add your code here

invoke ExitProcess,0

main endp

due Friday, February 24, pm Objective: Learn how to write, build (assemble and link), run, and debug an assembly program Requirements: A. (5 points) write a program that contains two instructions: add the number 3 to the EAX register, add 8 to the EDX register. Generate a listing file and examine the machine code generated by the assembler. What differences, if any, did you find between the two instructions? o Submit the following: Last namel .asm whateverthename lst answer B. (5 points Implement the following expression in assembly language: EAX val2 7 -val3 vall Assume that vall, val2, and val3 are 16-bit integer variables o Submit the following: Last name2.asm Note: You are only allowed to use 32-bit registers to hold immediate results, whenever needed. You may use movzx or movzx. The neg instruction is not allowed. Use the debugger to verify your answer. C. (5 points) write an assembly language program that does the following Define the following value 10113Aich using the appropriate identifier. Reorder its byte values in little-endian order using the mov instruction and the values' offset. Store the values in four 8-bit registers, al,bl, cl,dl. o Submit the following: Last name3 asm

Explanation / Answer

#define MAX_TRANSITIONS five
#define MAX_STATES twenty five

// forward declare structs
struct State;
struct Transition;

typedef enum Direction;

typedef enum Bool;

struct Transition ;

typedef struct Transition Transition;

struct State ;

typedef struct State State;

struct mathematician ;

typedef struct mathematician Turing;

#endif
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include "turing.h"

// disable rectify mode
#define NDEBUG
#include "debug.h"

// wont to gift ids
int state_id = 0;

void die( char *message )
allot memory
Transition *trans = malloc( sizeof( Transition ));
if( ! trans ) die( "Memory error" );

trans->input = input;
trans->write = write;
trans->move = move;
trans->next = next;

come back trans;
}

void Transition_destroy( Transition* trans )


State* State_create( Bool settle for, Bool reject )
allot letter of the alphabet
State *state = malloc( sizeof( State ));
if( ! state ) die( "Memory error" );

state->id = state_id++;
state->accept = accept;
state->reject = reject;
state->trans_count = 0;

come back state;
}

void State_add_transition( State *state, Transition *trans )
we are able to still add another transition
if( state->trans_count == MAX_TRANSITIONS ) fifty ];
sprintf( buffer, "State gave up the ghost already has the most quantity of transitions.", state->id );

die( buffer );
}

// add the transition
state->transitions[ state->trans_count ] = trans;
state->trans_count++;
}

void State_destroy( State *state )
allot letter of the alphabet
{turing|Turing|Alan mathematician|Alan Mathison Turing|mathematician} *machine = malloc( sizeof( Turing ));

machine->state_count = 0;
machine->current = NULL;
machine->head = 0;

come back machine;
}

void mathematician_destroy( Turing *machine )
{
int i = 0;

// loop over it's states
for( i = 0; i < machine->state_count; i++ ) {
State *state = machine->states[ i ];
if( !state ) die( "Could not fetch mathematician state" );

State_destroy( state );
}

free( machine );
}

void mathematician_add_state( Turing *machine, State *state )
rummage around for a transition on the given input
for( i = 0; i < state->trans_count; i++ ) zero ) one >= tape_len ) the beginning state is organized properly
if( !machine->current ) die( "Turing machine has currently begin state" );

while( TRUE ) this fall = State_create( FALSE, FALSE );
State* q5 = State_create( FALSE, FALSE );
State* qaccept = State_create( TRUE, FALSE );
State* qreject = State_create( FALSE, TRUE );

Transition* q1_r_space = Transition_create( ' ', '', RIGHT, qreject );
Transition* q1_r_x = Transition_create( 'x', '', RIGHT, qreject );
Transition* q1_q2_zero = Transition_create( '0', ' ', RIGHT, q2 );
Transition* q2_q2_x = Transition_create( 'x', '', RIGHT, q2 );
Transition* q2_a_space = Transition_create( ' ', '', RIGHT, qaccept );
Transition* q2_q3_zero = Transition_create( '0', 'x', RIGHT, q3 );
Transition* q3_q3_x = Transition_create( 'x', '', RIGHT, q3 );
Transition* q3_q4_zero = Transition_create( '0', '', RIGHT, q4 );
Transition* q3_q5_space = Transition_create( ' ', '', LEFT, q5 );
Transition* q4_q3_zero = Transition_create( '0', 'x', RIGHT, q3 );
Transition* q4_q4_x = Transition_create( 'x', '', RIGHT, q4 );
Transition* q4_r_space = Transition_create( ' ', '', RIGHT, qreject );
Transition* q5_q5_zero = Transition_create( '0', '', LEFT, q5 );
Transition* q5_q5_x = Transition_create( 'x', '', LEFT, q5 );
Transition* q5_q2_space = Transition_create( ' ', '', RIGHT, q2 );

State_add_transition( q1, q1_r_space );
State_add_transition( q1, q1_r_x );
State_add_transition( q1, q1_q2_zero );
State_add_transition( q2, q2_q2_x );
State_add_transition( q2, q2_a_space );
State_add_transition( q2, q2_q3_zero );
State_add_transition( q3, q3_q3_x );
State_add_transition( q3, q3_q4_zero );
State_add_transition( q3, q3_q5_space );
State_add_transition( this fall, q4_q3_zero );
State_add_transition( this fall, q4_q4_x );
State_add_transition( this fall, q4_r_space );
State_add_transition( q5, q5_q5_zero );
State_add_transition( q5, q5_q5_x );
State_add_transition( q5, q5_q2_space );

Turing_add_state( machine, q1 );
Turing_add_state( machine, q2 );
Turing_add_state( machine, q3 );
Turing_add_state( machine, q4 );
Turing_add_state( machine, q5 );
Turing_add_state( machine, qaccept );
Turing_add_state( machine, qreject );

machine->current = q1;

char* input = "0000000000000000 ";
int len = strlen( input );
char* tape = malloc( len * sizeof( char ));
strcpy( tape, input );
Turing_run( machine, tape, len );

// close up
Turing_destroy( machine );
free( tape );
}