Plan 9 from Bell Labs’s /usr/web/sources/contrib/fgb/root/sys/src/cmd/4th/examples/bin24th.4th

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


\ 4tH binary to .4th file converter - Copyright 2007 J.L. Bezemer
\ You can redistribute this file and/or modify it under
\ the terms of the GNU General Public License

include lib/argopen.4th                \ use ARG-OPEN word
include lib/ulcase.4th                 \ case conversion

10 constant /line                      \ number of bytes per line
/line string line                      \ input buffer

: .char space <# # # #> s>lower type ."  c," ;
: .header ." [hex]" cr ." offset " 1 args type cr ;
: .footer ." [decimal]" cr ;           ( --)
: read 2dup accept tuck <> -rot ;      ( a n1 -- f a n2)
: .line space bounds ?do i c@ .char loop cr ;
: .lines hex begin line /line read .line until ;
: Usage argn 4 < abort" Usage: bin24th offset file 4th-file" ;
: OpenFiles Usage input 2 arg-open output 3 arg-open ;
: Convert Openfiles .header .lines .footer close close ;

Convert

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.