Re: Howto try small machine code programs in BASIC ?
Posted: Thu Oct 24, 2013 10:04 am
Sorry for my long line Thanks for your patience
But i need some explicit examples.
e.g.: (pseudo code):
In which case are HNZVC set?
In DragonPy i made this:
Now in DragonPy theses flags are set:
H set if A == 16,32,48,64,80,96,112,128,144,160,176,192,208,224,240,0
N is set if A between 128 - 255
Z is only set if A == 0
V is only set if A == 128
C is only set on A == 0 (in the 256 iteration where A wrap around: 0xff+1 = 0x0)
I Updated my testCC_ADDA.bas and these values are exactly the same with it in XRoar: https://github.com/jedie/PyDragon32/blo ... C_ADDA.bas Now i would like to so the same with SUBA, INCA and DECA...
ADDA and INCA should set the same CC values, except H and C, isn't it?
OK, i think i understand it a little bit more.sixxie wrote:It's just that a signed 2's complement 8-bit integer can hold values -128 to +127. If an addition's result exceeds that range, that's an overflow. The sign is a separate issue (and indeed, in 2's complement 0 is considered positive).
But i need some explicit examples.
e.g.: (pseudo code):
Code: Select all
A = 0
while True:
HNZVC = 0 # Clear CC flags
ADDA #1
In DragonPy i made this:
Code: Select all
self.cpu_test_run(start=0x1000, end=None, mem=[
0x86, 0x0, # LDA #0
])
for i in xrange(256):
self.cpu_test_run(start=0x1000, end=None, mem=[
0x5f, # CLR B
0x1f, 0x9a, # TFR B,CC
0x8B, 0x01, # ADDA #1
])
print i, self.cpu.cc.get_info
H set if A == 16,32,48,64,80,96,112,128,144,160,176,192,208,224,240,0
N is set if A between 128 - 255
Z is only set if A == 0
V is only set if A == 128
C is only set on A == 0 (in the 256 iteration where A wrap around: 0xff+1 = 0x0)
I Updated my testCC_ADDA.bas and these values are exactly the same with it in XRoar: https://github.com/jedie/PyDragon32/blo ... C_ADDA.bas Now i would like to so the same with SUBA, INCA and DECA...
ADDA and INCA should set the same CC values, except H and C, isn't it?