Question

Question#1 Write a short program demonstrating that the INC and DEC instructions do not affect the...

Question#1

Write a short program demonstrating that the INC and DEC instructions do not affect the Carry flag.

Question#2

Write a program that uses addition and subtraction to set and clear the Overflow flag.

After each addition or subtraction, insert the call DumpRegs statement to display the registers and flags.

Make sure to include an ADD instruction that sets both the Carry and Overflow flags.

Using comments, explain how and why the Overflow flag was affected by each instruction.

Question#3

Write a program that uses addition and subtraction to set and clear the Carry flag.

After each instruction, insert the call DumpRegs statement to display the registers and flags.

Using comments, explain how and why the Carry flag was affected by each instruction.

Question#4

Insert the following variables into a program:

Uarray WORD 1000h, 2000h, 3000h, 4000h

Sarray SWORD -1, -2, -3, -4

Write instructions that use direct-offset addressing to move the four values in Uarray to the EAX, EBX, ECX, and EDX registers.  
When you follow this with a call DumpRegs statement the following register values should display:

EAX=00001000 EBX=00002000 ECX=00003000 EDX=00004000

Then write instructions that use direct-offset addressing to move the four values in Sarray to the EAX, EBX, ECX, and EDX registers.  
When you follow this with a call DumpRegs statement the following register values should display:

EAX=FFFFFFFF EBX=FFFFFFFE ECX=FFFFFFFD EDX=FFFFFFFC

Question#5

Write a program that implements the following arithmetic expression:

EAX = -val2 + 7 – val3 + val1

Use the following data definitions:

val1 SDWORD 8

val2 SDWORD -15

val3 SDWORD -20

In comments next to each instruction, write the hexadecimal value of EAX.

Insert a call DumpRegs statement at the end of the program.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

3)
The required program is: TITLE Subtract/Add Three (subtractThree.asm);
Description:    This program subtracts 3 integers using only 16 bit registers.
INCLUDE Irvine32.inc
.code main PROC mov ax,8000h;
ax = 8000h mov bx,2000h;
bx = 2000h mov cx,3000h;
cx = 3000h sub ax,bx;
subtract bx from ax, ax = 6000h sub ax,cx ;
subtract cx from ax, ax = 3000h sub cx,bx ;
subtract bx from cx, cx = 1000h call DumpRegs ;
display registers exit ;
halt program main ENDP ;
end procedure END main ;
end program Results: EAX=00003000 EBX=7FFD2000 ECX=00121000 EDX=7C90E514 ESI=01CB4228 EDI=D8DB1C09 EBP=0012FFF0 ESP=0012FFC4 EIP=0040102A EFL=00000206 CF=0 SF=0 ZF=0 OF=0 AF=0 PF=1 Press any key to continue

Add a comment
Know the answer?
Add Answer to:
Question#1 Write a short program demonstrating that the INC and DEC instructions do not affect the...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using the AddTwo program from Section 3.2 as a reference, write a program that calculates the...

    Using the AddTwo program from Section 3.2 as a reference, write a program that calculates the following expression, using registers: A = (A + B) + (C + D). Assign integer values to the EAX, EBX, ECX, and EDX registers. AddTwo program: ; AddTwo.asm - adds two 32-bit integers ; Chapter 3 example .386 .model flat,stdcall .stack 4096 ExitProcess PROTO, dwExitCode:DWORD .code main PROC mov eax,5 ; move 5 to the eax register add eax,6 ; add 6 to the...

  • 1) Assume the registers are initialized to the indicated values: Se al A c and code...

    1) Assume the registers are initialized to the indicated values: Se al A c and code frogments MUST use 32 ぁ ar movennes (anor be "nedfra-ne ibrary function or procedural calls ino- Pe Peue c for ll codr ond code frogments only othu ey document your code with Comments unless the code size is Drow Fow Chort for any flow of control involving branches and loops Use PoCedures as modules to organize most of the code and code fragments. In...

  • 1. Assume that you are given values in eax, ebx, ecx. Write an assembly code that...

    1. Assume that you are given values in eax, ebx, ecx. Write an assembly code that does the following: eax = (ecx + edx ) - (eax + ebx) 2. Write a piece of code that copies the number inside al to ch. Example: Assume that Initially eax = 0x15DBCB19. At the end of your code ecx = 0x00001900. Your code must be as efficient as possible. 3. You are given eax = 0x5. Write one line of code in...

  • I need help creating this code. Write an assembly program (MASM and Irvine's libraries) that calculates...

    I need help creating this code. Write an assembly program (MASM and Irvine's libraries) that calculates and prints out the first five Fibonacci numbers FO=0; F1=1; F2=1; F3=F1+F2; F4=F3+F2; F5=F4+F3 If we use 0, 1 and initial conditions the sequence would be: 0, 1, 1, 2, 3 Use the ebx, eax, and ecx registers. Note WriteHex, Writelnt, WriteDec, all use eax So use ebx for first and eax for second and ecx for temporary The calculation could go something like...

  • NOTE: explain the lines in comments for better understanding Write an assembly program (for x86 processors...

    NOTE: explain the lines in comments for better understanding Write an assembly program (for x86 processors - Irvine) that has two procedures, a main procedure and a procedure called Fib. The fib procedure is to uses a loop to calculate and printout the first N Fibonacci numbers. Fibonacci sequence is described by the following formula: Fib(1) = 1, Fib(2) = 1, Fib(n) = Fib(n – 1) + Fib(n – 2). The value of N is to be communicated to this...

  • Subtracting three integers. Using the ADDSUB program from the section 3.2 (shown below) as a reference,...

    Subtracting three integers. Using the ADDSUB program from the section 3.2 (shown below) as a reference, write a program that subtracts three integers only 16-bit registers. Insert a cal DumpRegs statement to display the register values This program must be done using Visual studio. Please submit .asm file or copy/paste your program here. Please note that you will have two extra days of grace period for all homeworks, including midterm and final exam projects. ; AddTwo.asm - adds two 32-bit...

  • Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   please put comment with code! and please do not just copy other solu...

    Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   please put comment with code! and please do not just copy other solutions. Instructions 1. Read instructions carefully! 2. Use C++ syntax only, C syntax will not be accepted. 3. Always use braces to define blocks. 4. Indent all lines within a block. Each block requires one more tab. 5. Organize your code well with proper formatting and a single...

  • C++ please Possible algorithms – (1) use and modify the algorithm from program 2 if possible;...

    C++ please Possible algorithms – (1) use and modify the algorithm from program 2 if possible; (2) use unique value array; (3) use flag array (flags used to avoid counting a number more than 1 time); (4) compute frequency distribution (use unique and count arrays); (5) use count array to store the frequency of a number. No global variable are permitted in this assignment. Do not change the code provided only write the missing code. Write the missing C++ statements...

  • Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQ...

    Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQUIRED for this program will use two stacks, an operator stack and a value stack. Both stacks MUST be implemented using a linked list. For this program, you are to write functions for the linked list stacks with the following names: int isEmpty (stack); void push (stack, data); data top (stack); void pop (stack); // return TRUE if the stack has no...

  • Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQ...

    Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQUIRED for this program will use two stacks, an operator stack and a value stack. Both stacks MUST be implemented using a linked list. For this program, you are to write functions for the linked list stacks with the following names: int isEmpty (stack); void push (stack, data); data top (stack); void pop (stack); // return TRUE if the stack has no...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT