Mail Archives: djgpp-workers/2003/05/22/11:12:08
>
> In libc/crt0/crt0.s (line 250):
>
> /* Maybe lock the initial block, expects BX:CX */
> movl %ecx,%ebx
> movl %edx,%ecx
> addw $4096,%cx /* Skip null page */
> adcl $0,%ebx
>
> -----------
>
> What happens if carry was set prior to the 'addw' ?
It's cleared or reset by addw (depending on the input to addw).
> I was just hit by this elsewhere in some 16-bit nasm code.
> To increment a 32-bit variable I used
> inc word [di]
> adc word [di+2], 0
>
> Seems resonable, but got wrong result cause the carry
> was already set. Adding a 'clc' before the 'inc' fixed it.
inc and dec don't affect the carry flag. add, adc, sub etc. do.
So what happens when [di] == 0xffff and [di+2] == X. You don't want
[di] == 0 and [di+2] == X+1 in that case?
Try
add word [di], 1 ; Needed for setting CF.
adc word [di+2], 0
instead or
inc word [di]
jnz skip_upper_inc
inc word [di+2]
skip_upper_inc:
I'd use the first alternative (unless the second is shorter and I'm
desperate for code size).
Right,
MartinS
- Raw text -