From f901555264516135c0a2090740ab013dd9132b5c Mon Sep 17 00:00:00 2001 From: cuz Date: Sun, 17 Mar 2002 16:50:35 +0000 Subject: [PATCH] The %p format specifier was missing git-svn-id: svn://svn.cc65.org/cc65/trunk@1198 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- libsrc/common/_printf.s | 43 +++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/libsrc/common/_printf.s b/libsrc/common/_printf.s index d58744e40..d39e1abed 100644 --- a/libsrc/common/_printf.s +++ b/libsrc/common/_printf.s @@ -259,7 +259,7 @@ Save: lda regbank,y sta Format stx Format+1 - jsr popax ; Output descriptor + jsr popax ; Output descriptor sta OutData stx OutData+1 @@ -527,7 +527,7 @@ CheckInt: ; Integer argument - jsr GetSignedArg ; Get argument as a long + jsr GetSignedArg ; Get argument as a long ldy sreg+1 ; Check sign bmi @Int1 ldy Leader @@ -562,29 +562,44 @@ CheckCount: CheckOctal: cmp #'o' - bne CheckString + bne CheckPointer ; Integer in octal representation - jsr GetSignedArg ; Get argument as a long - ldy AltForm ; Alternative form? - beq @Oct1 ; Jump if no - pha ; Save low byte of value + jsr GetSignedArg ; Get argument as a long + ldy AltForm ; Alternative form? + beq @Oct1 ; Jump if no + pha ; Save low byte of value stx tmp1 ora tmp1 ora sreg ora sreg+1 ora Prec - ora Prec+1 ; Check if value or Prec != 0 + ora Prec+1 ; Check if value or Prec != 0 beq @Oct1 lda #'0' jsr PutBuf - pla ; Restore low byte + pla ; Restore low byte -@Oct1: ldy #8 ; Load base - jsr ltoa ; Push arguments, call _ltoa +@Oct1: ldy #8 ; Load base + jsr ltoa ; Push arguments, call _ltoa jmp HaveArg +; Check for a pointer specifier (%p) + +CheckPointer: + cmp #'p' + bne CheckString + +; It's a pointer. Use %#x conversion + + ldx #0 + stx IsLong ; IsLong = 0; + inx + stx AltForm ; AltForm = 1; + lda #'x' + bne IsHex ; Branch always + ; Check for a string specifier (%s) CheckString: @@ -615,13 +630,13 @@ CheckUnsigned: CheckHex: cmp #'x' - beq @IsHex + beq IsHex cmp #'X' bne UnknownFormat ; Hexadecimal integer -@IsHex: pha ; Save the format spec +IsHex: pha ; Save the format spec lda AltForm beq @L1 lda #'0' @@ -641,7 +656,7 @@ CheckHex: jsr _strlower ; Make characters lower case @L2: jmp HaveArg -; Unsigned format character, skip it +; Unknown format character, skip it UnknownFormat: jmp MainLoop -- 2.39.5