Question

First clear all your general purpose registers by moving the value “0” into them. Initialize a...

  1. First clear all your general purpose registers by moving the value “0” into them.

Initialize a variable for a BYTE, WORD, DWORD storage size each with any desired value in the data segment. Initialize another variable called Result with the size of a DWORD and make the value as an uninitialized value.

In the code segment, create a label called L1 that moves the variables in the appropriate sized register and making sure NOT to overwrite them in the process.

After, create another label L2 that adds all these values together and at the end of your program make sure your ECX register contains the final value.

Call the DUMPREGS instruction to display your register values and move the final result into the Result variable.

  1. Use the following code below as a template and follow the instructions written in the comments

;Assume I have the following data segment written:

.data

val1 BYTE 10h

val2 WORD 8000h

val3 DWORD 0FFFFFh

val4 WORD 7FFFh

           

;1. Write an instruction that increments val2.

;2. Write an instruction that subtracts val3 from EAX.

;3. Write instructions that subtract val4 from val2.

.code

;Write your instructions here

This is what I have so far and need to build off this:

.386
.model flat,stdcall
.stack 4096
ExitProcess proto,dwExitCode:dword

INCLUDE Irvine32.inc

.data

mov eax, 0
mov ebx, 0
mov ecx, 0
mov edx, 0

val1 byte 10h
val2 word 2000h
val3 dword 30000000h
result dword ????

.code
main PROC

   MOV EAX, 10
   ADD EAX, 50

   call DumpRegs ;Check registers via output

   invoke ExitProcess,0

main ENDP
end main

Homework Answers

Answer #1

.386
.model flat,stdcall
.stack 4096
ExitProcess proto,dwExitCode:dword

INCLUDE Irvine32.inc

.data

MOV EAX, 0
MOV EBX, 0
MOV ECX, 0
MOV EDX, 0

val1 BYTE 10h
val2 WORD 8000h
val3 DWORD 0FFFFh
val4 DWORD 7FFFFh
result DWORD FFFFFh

.code
main PROC

MOV EAX, 10

L1:
   INC val2 // Incrementing val2
SUB EAX,val3 //Subtracting val3 from EAX and storing it in EAX
MOV EBX,val4   
SUB val2,EBX // No registers are over-written at the end of L1
MOV EDX,val2 // Subtracting val4 from val2 and the result is moved into EDX register
L2:
ADD EDX,EAX
ADD EDX,EBX // Adding all the values
MOV ECX,EDX // At the end of L2 the result is being moved to ECX register

   call DumpRegs ;Check registers via output
MOV result,ECX // Moving the final result from ECX register to the result variable

   invoke ExitProcess,0

main ENDP
end main

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
A) Is the code below secure? Explain your rationale. ExitProcess PROTO .data firstval qword 20002000h secondval...
A) Is the code below secure? Explain your rationale. ExitProcess PROTO .data firstval qword 20002000h secondval qword 11111111h thirdval qword 22222222h sum qword 0 .code main proc      mov rax,firstval                         add rax,secondval             add    rax,thirdval      mov    sum,rax      mov    ecx,0      invoke ExitProcess main endp end main b) Transmitted messages often include a parity bit, whose value is combined with a data byte to produce an even number of 1 bits. Suppose a message byte in the AL...
Implement the following expression in assembly language:                                  &nb
Implement the following expression in assembly language:                                                 BX = –val2 + 7 - (- val3 + val1) * 2 Assume that val1, val2, and val3 are 8-bit integer variables Initialize val1 with 12, val2 with 9, and val3 with 2 You are only allowed to use 16-bit registers to hold intermediate results, whenever needed. Use ONLY mov, add, sub, movzx, movzx, or neg instructions whenever needed. Use the debugger to verify your answer. Please answer using this format for...
Write a sequence of two instructions that copies bits 0-5 from AL to bits 0-5 in...
Write a sequence of two instructions that copies bits 0-5 from AL to bits 0-5 in BL. Bits 6-7 in BL should be cleared, and AL should be unchanged             Mov al, bl       And 00111111, bl       Write a sequence of two instructions that copies the integer in bits 4-7 from AL register into bits 0-3 of the BL register. Upper 4 bits of AL and BL will be cleared             Shr al, 4       Mov bl,...
In assembly masm use the code below! Write a program that reverse a string using indirect...
In assembly masm use the code below! Write a program that reverse a string using indirect addressing (may not use the stack - push/pop). The string will be given by the user and be up to 64 characters long INCLUDE Irvine32.inc INCLUDE macros.inc MAX = 64 .data source BYTE MAX DUP('#'),0 destination BYTE LENGTHOF source DUP('*'),0 actual_length DWORD ? ask BYTE "Enter a String: ",0 .code main proc ; ask user for input mov edx, OFFSET ask call WriteString ;...
Write an assembly procedure Find to return the index of the first occurrence of a character...
Write an assembly procedure Find to return the index of the first occurrence of a character ch in a string str. If ch is not found in str the return value should be -1. Input parameters: None. Preconditions: The base address of str is stored in ecx. str is ‘\0’ terminated. ch is strored in bl. Return value: The return value should be stored in eax. Run and test your procedure using the following driver program: .386 .model flat, stdcall...
I. What value will be in register r2 after execution of the following instructions? Show your...
I. What value will be in register r2 after execution of the following instructions? Show your work with the register values after executing each instruction. MOV r2, #0x0 LDR r1, =0xCF MOVS r1, r1, LSR #1 ADC r2, r2, #0 MOVS r1, r1, LSR #1 ADC r2, r2, #0 II. Assume a 32 bit register holds a data of four bytes as B3B2B1B0. Write a sequence of ARM instruction that takes this data as input and swaps the bytes 0...
Objectives: ⦁   Declare and initialize null-terminated string ⦁   Apply indirect address ⦁   Write loop ⦁   Apply...
Objectives: ⦁   Declare and initialize null-terminated string ⦁   Apply indirect address ⦁   Write loop ⦁   Apply Irvine.inc library functions to display a string Problem Description: Write a program with a loop and indirect address that copies a string from source to target. Revising the character order in the process. Use the following variables: source BYTE “This is the string that will be reversed”, 0 target BYTE SIZEOF source DUP(‘#’) You may refer to the Programming Exercise #7 on Page 138...
program has to be written in X86 processor assy language. Write a program that find the...
program has to be written in X86 processor assy language. Write a program that find the minimum number of coins that can represent an amount of money under $1. The amount of money is a random number between 0 and 99 (cents). The randomRange procedure is used to get a random number. Review the sample code in lab4.asm and run it to see how randomRange works. Each time randomRange is called, it creates a random number between 0 and the...
Microprocessor 8086 material. Choose the correct answer. 1- For a (64K x 8) RAM, the number...
Microprocessor 8086 material. Choose the correct answer. 1- For a (64K x 8) RAM, the number of address lines is: * 17 19 16 15 20 14 18 2-Which of the following instructions requires (BYTE PTR)? * SHR [500H], 3h LDS SI, [1000H] LAHF PUSH [9AAH] ADD AX, [800H] 3-Where are the interrupt vectors located in the microprocessor’s memory? * in the first 64K byte in the first 1K byte in the first 256K byte in the first 1M byte...
(Sure, take your time. would you like me to post this again?) Thanks in advance !...
(Sure, take your time. would you like me to post this again?) Thanks in advance ! Write the following methods in java class ARM that represent state information as well as functional blocks of the ARM platform. [Go through the following 5 classes then write methods for the instructions: mov, str, ldr, add in class ARM, finally, write a print method for ARM that can display the registers and the memory locations that have been used. (make sure to make...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT