uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

hexdump.tal (1087B)


      1 ( usage: uxncli hexdump.rom file.bin )
      2 
      3 |10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $1
      4 |a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
      5 
      6 |0000
      7 
      8 	@src $40
      9 
     10 |0100 ( -> )
     11 
     12 	;on-console .Console/vector DEO2
     13 
     14 BRK
     15 
     16 @on-console ( -> )
     17 
     18 	;src STH2
     19 	( read input )
     20 	.Console/read DEI
     21 	DUP #20 LTH OVR #7f GTH ORA ,&end JCN
     22 	STH2kr ,slen JSR #003f GTH2 ,&end JCN
     23 		STH2kr ,scap JSR STA POP2r BRK
     24 		&end
     25 	POP
     26 	STH2r .File/name DEO2
     27 	#0002 .File/length DEO2
     28 	LIT2r 0000
     29 	&stream
     30 		#0000 ,&buf STR2
     31 		;&buf .File/read DEO2
     32 		.File/success DEI2 #0000 EQU2 ,&eof JCN
     33 		;&buf LDA2 ,print JSR #2018 DEO
     34 		INC2r
     35 		( linebreak )
     36 		STH2kr #000f AND2 ORA ,&no-lb JCN
     37 			#0a18 DEO &no-lb
     38 		,&stream JMP &eof
     39 	POP2r
     40 	#010f DEO
     41 
     42 BRK
     43 	&buf $2
     44 
     45 @slen ( str* -- len* )
     46 
     47 	DUP2 ,scap JSR SWP2 SUB2
     48 
     49 JMP2r
     50 
     51 @scap ( str* -- end* )
     52 
     53 	LDAk #00 NEQ JMP JMP2r
     54 	&while
     55 		INC2 LDAk ,&while JCN
     56 
     57 JMP2r
     58 
     59 @print ( short* -- )
     60 
     61 	SWP ,&byte JSR
     62 	&byte ( byte -- ) DUP #04 SFT ,&char JSR
     63 	&char ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
     64 
     65 JMP2r