On Fri, Apr 30, 2010 at 9:49 AM, Payton Byrd <plbyrd@gmail.com> wrote: > > > On Fri, Apr 30, 2010 at 1:08 AM, Ullrich von Bassewitz <uz@musoftware.de>wrote: > >> _cbm_k_open: >> jsr OPEN ; <- KERNAL call >> ldx #0 ; Clear high byte >> bcs @NotOk >> txa >> @NotOk: rts >> > > > Just out of curiosity, what's the point of using X to clear the carry bit > of A? Wouldn't this be more efficient? > The return value for C callers is stored in A and X, with the low byte in A and the high byte in X. That LDX is just making sure the high byte is zero. LDX doesn't touch the carry bit, as you can see by looking it up in the opcodes section of the PRG, so the BCS will still be triggered if OPEN returned an error indication, in which case whatever OPEN put in the accumulator is returned in the low byte. If OPEN returns no error, then the TXA clears the accumulator and thus makes the whole two-byte return value zero. -- Mark J. Reed <markjreed@gmail.com> ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo@musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.Received on Fri Apr 30 15:54:27 2010
This archive was generated by hypermail 2.1.8 : 2010-04-30 15:54:30 CEST