add hexdump.nas

This commit is contained in:
Li Haokun 2021-08-12 20:01:51 +08:00 committed by GitHub
parent 5fe6681b0d
commit e4c598cae6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 0 deletions

25
test/hexdump.nas Normal file
View File

@ -0,0 +1,25 @@
import("lib.nas");
var hex_num=[
'0','1','2','3',
'4','5','6','7',
'8','9','a','b',
'c','d','e','f'
];
var hex=[];
foreach(var i;hex_num)
foreach(var j;hex_num)
append(hex,'0x'~i~j);
var s=io.fin("lib.nas");
var cnt=0;
print(0,'\t');
for(var i=0;i<size(s);i+=1){
if(cnt==8){
cnt=0;
print('\n',i,'\t');
}
cnt+=1;
print(hex[s[i]],' ');
}
print('\n');