coltoff@burdvax.UUCP (Joel Coltoff) (12/05/84)
< assembler source looks like curses in comic strips > An application I am working on requires output to be delivered in binary form. i.e. for a 6 bit value of 17 I want to write out 010001 for the two bit ( pun intended ) value 3 I need 11 and so on. (The 48 bit values could still be a problem to deal with.) This task is not a particularly difficult but it occurred to me that doprnt comes very close to doing this already including the much needed leading zero padding. The code below is the changes to make to doprnt.s to make a %b option available to printf. Before the portability people scream at me I want to say that portability isn't an issue with this program ( especially not now ). If it was I wouldn't have done this. The first printf is well commented so the code can be easily changed at a later date. Besides someone has to stand up for the rights of the E.E.'s on the net. rcsdiff -r1.1 -r1.2 doprnt.s RCS file: RCS/doprnt.s,v retrieving revision 1.1 retrieving revision 1.2 diff -r1.1 -r1.2 216c216 < .word fmtbad-L5 # b --- > .word bin-L5 # b 260a261,266 > bin: > movl $31,r2 > movl $1,r3 > movab htab,llafx > jbr L10 > 282c288 < skpc $'0,$11,4(sp) # skip over leading zeroes --- > skpc $'0,$31,4(sp) # skip over leading zeroes 285a292,293 > cmpl r3,$1 # is this binary > jeql prn3 # yes, go away -- Joel Coltoff {sdcrdcf,bpa,psuvax1}!burdvax!coltoff (215)648-7258