delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/05/22/10:37:22

Message-ID: <0b3001c3206f$a20aeeb0$0600000a@broadpark.no>
From: "Gisle Vanem" <giva AT bgnett DOT no>
To: "djgpp workers" <djgpp-workers AT delorie DOT com>
Subject: Add with carry
Date: Thu, 22 May 2003 16:37:12 +0200
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Reply-To: djgpp-workers AT delorie DOT com

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' ?

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.

--gv

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019