Description:
Compare the top two shorts on the stack . If they are equal, pop them both and branch to the requested address. Otherwise, pop only the top short and continue.
Data (2 bytes):
short: 2-byte value for branch address
Pseudo Code:
short1 = stack[sp - 4]
short2 = stack[sp - 2]
if (short1 == short2)
sp = sp - 4
pc = branch address
else
sp = sp - 2
pc = pc + 3
Flags Affected:
Possible Errors:
Examples:
cmpsbr (top two shorts are equal)
Before
| stack | | | top | | 1 | 0x35 | | 2 | 0x02 | | 3 | 0x35 | | 4 | 0x02 | | | bottom |
|
| | |
cmpsbr (top two shorts are not equal)
Before
| stack | | | top | | 1 | 0xAB | | 2 | 0x04 | | 3 | 0x35 | | 4 | 0x02 | | | bottom |
|
| | After
| stack | | | top | | 1 | 0x35 | | 2 | 0x02 | | | bottom |
|
|
version: 1.0, build n.a.
© Copyright 1994-2012 Acroname, Inc., Boulder, Colorado. All rights reserved.