function *read_one_command( words ) { let pos = 0; while( pos < words.length ) { let header = words[pos+1]; let [reg, size] = read_header(header); let param = [words[0]] let idx = pos+2; while( size-- > 0 ) param.push( words[idx++] ); pos += 2 + ( (size%2) ? size+1 : size ); yield {reg, param} } } function *parse( bytes ) { const words = new Uint32Array( bytes ); let output = []; while( 1 ){ let command = yield read_one_command( words ); if( command == null ) break; else output.push( command ); } return output; }