Hello everyone,
i have implemented a printf* family (C-like style) functions in assembler for 65816:
http://65xx.unet.bz/mb01/B1603.ziplook at F8/vprint.asm for source code.
Code:
;; C-like format function (as printf())
;;
;; FORMAT STRING
;; '%'[flag][width]['.'precision][modifier]type
;;
;; flags ::= '-' | '+' | ' ' | '#' | '0' | ','
;; width ::= '*' | number (8 bit) (if * byte passd by arg)
;; precision ::= '*' | number (8 bit) (if * byte passd by arg)
;; modifier ::= 'l' | 'h' | 'b' | 'H' | 'B'
;; type ::= 'c' | 's' | 'd' | 'i' | 'u' | 'x' | 'X' | 'p' | 'P' |
;; 'f' | 'F' | 'e' | 'E' | 'g' | 'G'
;;
;; flag '#' - alternate form for hex (C-style:prefix with 0x or 0X)
;; flag '-' - left justify (default)
;; flag '+' - right justify
;; flag ' ' or '0' - fill field with blank or '0'
;; flag ',' - only for d,i,u types - group thousands with
;; ',' as seperator
;; c - character (no modifier allowed)
;; s - ASCIZ string (NULL terminated string)
;; Bs - Pascal/Basic string
;; d,i - signed integer 32 bit (in decimal)
;; u - unsigned integer 32 bit (in decimal)
;; ld, li - long signed integer 64 bit (in decimal)
;; lu - long unsigned integer 64 bit (in decimal)
;; hd, hi - short signed integer 16 bit (in decimal)
;; hu - short unsigned integer 16 bit (in decimal)
;; bd, bi - byte signed integer (in decimal)
;; bu - byte unsigned integer (in decimal)
;; x,X - unsigned integer 32 bit in hex (nocaps/caps)
;; lx,lX - long unsigned integer 64 bit in hex (nocaps/caps)
;; hx,hX - short unsigned integer 16 bit in hex (nocaps/caps)
;; bx,bX - unsigned byte in hex (nocaps/caps)
;; p,P - long pointer (3 bytes) in hex (nocaps/caps)
;; f,F,e,E,g,G - float point number (see sprintf())
Look at F8/fpemu.asm for implementation of 4 basic operation for float encoded in 80 bit (19/20 significance digits) and at F8/intp.asm for implementation of integer (signed/unsigned) operations.
Parameters are passed by a frame stack (see source code) and caller will create frame stack before calling and clean frame stack after return.
Marco
_________________
http://65xx.unet.bz/ - Hardware & Software 65XX family