GATE Computer ScienceVery hardGATE CS (PYQ pattern)
An 8-bit x86-style SUB computes 0x01 − 0xFF. In this convention CF = 1 exactly when the unsigned subtraction needs a borrow, OF = signed overflow, SF = sign of the result and ZF = zero. Which result and flags are produced?
- A. 0x02; SF=0 ZF=0 CF=0 OF=0
- B. 0x02; SF=0 ZF=0 CF=1 OF=1
- C. 0x02; SF=0 ZF=0 CF=1 OF=0
- D. 0xFE; SF=1 ZF=0 CF=1 OF=0
Correct answer: C. 0x02; SF=0 ZF=0 CF=1 OF=0
Unsigned 1 − 255 needs a borrow, so CF = 1 and the byte is 0x02. Signed it is 1 − (−1) = 2, which fits, so OF = 0. CF = 0 would be the ARM convention, where C is the inverted borrow; 0xFE is 0xFF − 0x01 (operands swapped).
Practise more Computer Organization and Architecture questionsComputer Organization and Architecture: notes and key points
More Computer Organization and Architecture questions
- A two-level memory has a 32 KB cache costing 100 per KB (access 10 ns) and a 4 MB main memory costing 1 per KB (access 100 ns); total…
- A write-back, write-allocate cache has a 2 ns hit time and a 5% miss rate. A miss that evicts a clean block costs 40 ns; a miss that…
- An 8-bit CPU multiplies the two's-complement bytes 0xF6 and 0x0D as signed numbers into a 16-bit product. What is the product, and is the…
- A branch behaves T, T, N, N repeatedly for 32 executions. A 2-bit saturating counter starts at state 0 and predicts taken in states 2 and…
- A 32-bit machine uses a 2-level page table with 4 KB pages and 4-byte entries (10 + 10 + 12 bit split). A process uses exactly 4 MB + 8 KB…
- Which of the following statements about performance are correct? I. A lower CPI always means a faster machine. II. Execution time =…