6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 22, 2024 5:40 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Sat Dec 28, 2013 12:19 pm 
Offline

Joined: Mon Jun 24, 2013 8:18 am
Posts: 83
Location: Italy
Hello everyone,
i have implemented a printf* family (C-like style) functions in assembler for 65816:

http://65xx.unet.bz/mb01/B1603.zip

look 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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: