Question

A.Write a program fragment that will set the sign flag B.Write a program fragment that will...

A.Write a program fragment that will set the sign flag

B.Write a program fragment that will set the overflow flag.

C. Write a program fragment that sets the zero flag.

D.What will be the value of the parity flag after the following lines execute?

Mov al, 3

Add al, 5

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

Given, Write a program to show sign, overflow and zero flag set using fragment code.

Assume we have AX and BX register fill with 7FFFh and we want to add.

ADD AX, BX

Binary value of 7FFFh => 0111 1111 1111 1111

0111 1111 1111 1111 + 0111 1111 1111 1111 => 1111 1111 1111 1110 (FFFE)

[A]. In the above example the sign flag will be set since MSB bit is 1.

[B]. To set overflow flag add two same bit position number.

example.

Mov BX, 05h

Mov Ax, 05h

ADD Ax, Bx

0100 + 0100 => 1000 (overflow bit flag will be turned on)

Sum of these number yield a sign bit .

[C]. Zero flag get turned on when the value of the result becomes all 0.

MOV BX, 05h

MOV AX, 05h

SUB AX, BX

0100 - 0100 => 0000 (0)

The above instruction result in all 0 bits and hence zeos bit flag will turned on.

[D]. Mov al,3

Add al,5

binary of 3 is 011 and binary of 5 is 101

adding 011 + 101 => 1000 (8)

As in result we can see we have a odd set bit so the parity flag will be 0.

Let me know if you need more help in this.

Add a comment
Know the answer?
Add Answer to:
A.Write a program fragment that will set the sign flag B.Write a program fragment that will...
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
  • What will be the value of the parity flag after the following lines execute? Mov al,...

    What will be the value of the parity flag after the following lines execute? Mov al, 3 Add al, 5 What will be the value of the destination operand after each of the following instructions execute?            .data var1 SBYTE     -1, -2, -3, -4 var2 WORD A000h, B000h, C000h, D000h var3 SWORD     -16, -42 var4 DWORD     11, 22, 33, 44 .code mov ax, var2 mov ax, [var2+4] mov ax, var3 mov ax, [var3-2]

  • Determine the contents of register AL and the carry, sign, zero, and overflow flags after the...

    Determine the contents of register AL and the carry, sign, zero, and overflow flags after the following two 8086 instructions are executed in sequence: MOV AL,0x4C ; Load register AL with 0x4C ADD, AL,0x3E ; Add 0x3E to the contents of AL (which is 0x4C) and place the result (sum) in AL

  • 5.3 Rewrite the following program fragment that is written using the GPR instruction set for execution...

    5.3 Rewrite the following program fragment that is written using the GPR instruction set for execution on a CISC processor that provides the same instruction set as the GPR processor but allows the register addressing mode to be used on the input operands or destination of any instruction. (Yes, the code fragment will execute correctly as written on such a processor. Your goal should be to reduce the number of instructions as much as possible. ) Assume that the program...

  • 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...

  • 1. What will be the contents of BX after the following instructions execute? mov bx,5 stc...

    1. What will be the contents of BX after the following instructions execute? mov bx,5 stc mov ax,60h adc bx,ax 2. Describe the output when the following code executes in 64-bit mode: .data dividend_hi QWORD 00000108h dividend_lo QWORD 33300020h divisor QWORD 00000100h .code mov rdx,dividend_hi mov rax,dividend_lo div divisor 3. The following program is supposed to subtract val2 from val1. Find and correct all logic errors (CLC clears the Carry flag): .data val1 QWORD 20403004362047A1h val2 QWORD 055210304A2630B2h result QWORD...

  • Section B - ARM Assembly Language (25 marks) An ARM instruction set summary is provided at...

    Section B - ARM Assembly Language (25 marks) An ARM instruction set summary is provided at the end of this paper 1. (5 marks) Consider the following assembly instruction STMFD r13!, (r5-6} Before executing this instruction, registers hold the following values: Register Value Register r9 Value r4 0x00400040 0x00000000 r5 r10 0x11223344 0x00800080 r6 0x55667788 r11 0x10001000 r7 0x99aabbcc r12 0x20002000 r8 exddeeff00 r13 ex40004000 What memory locations are affected after executing the above instruction? In a table, with a...

  • PART A: Predict how many lines of output will be displayed by the following program fragment:...

    PART A: Predict how many lines of output will be displayed by the following program fragment: i = 0 ​​ do { ​​for (j = 0; j < 4; j = j + 1) ​​printf("%d\n", i + j); ​​i = i + 1; ​​} while (i < 5); PART B: Then write either a C or a C++ program to verify your prediction. ​​ I know it will output 20 lines, the full C++ code is what I need.

  • Remember to use step into when tracing a procure's call Convention el proc program mple1 Problem ...

    Write full code in microsoft virtual studio ASM only Remember to use step into when tracing a procure's call Convention el proc program mple1 Problem 2: Write and run the following program. Will the program crash? Why? push 6 push 5 call addtwo add esp,4 comment this line and see what happen ret example1 endp C Calling Convention main proc call example1 add al, 1 invoke ExitProcess, e main endp addtwo proc push ebp mov ebp,esp mov eax, [ebp+12] add...

  • Convert the following assembly language program into a C program: *Update: The variables are initialized, in...

    Convert the following assembly language program into a C program: *Update: The variables are initialized, in lines 4 & 6 of the red assembly language code. Convert the following assembly language program into a C program: *Update: The variables are initialized, in lines 4 & 6 of the red assembly language code. include "p24Hxxxx.inc" global__reset bss: Uninitialized data section: Variables start at location 0x0800 x: .space 2: Allocating space (two bytes) to variable. y: .space 2;Allocating space (two bytes) to...

  • Referring to the PCICR and PCMSK registers of the ATMega328P microcontroller, write a fragment of code...

    Referring to the PCICR and PCMSK registers of the ATMega328P microcontroller, write a fragment of code in C to write to the PCICR and the correct PCIMSK register of the ATMega328P microcontroller to set it up for the following operation: Pin Changes on Port D Bit 3 or on Port B bit 4 cause a Pin Change Interrupt request. You may also assume the existence of the macro sei(); to enable global interrupts. Include this in your program fragment in...

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