Provided by: mawk_1.3.4.20240622-2_amd64

**NAME**

mawk-code - dumping mawk's byte-code

**SYNOPSIS**

At startup,mawkcompiles the script into byte-code. After that, it interprets the compiled byte-code. Use the-Wdumpoption to show the byte-code.

**PROGRAM** **CODES**

Asmawkexecutes the program, it maintains a reference to the command to execute incdp. After that there may be data and/or references incdp[0],cdp[1], etc. When an operation requires operands,mawkpushes the values (or array/string references) onto the stack, which updates the stack pointersp. When the operation completes,mawkconsumes those entries on the stack, pushing the result (if any) onto the stack. While executing user-defined functions,mawkmaintains aframepointerfpto address the function's local variables.a_catConcatenatearray-indices. Usage: Forms a multiple array index by concatenating the elements ofsp[1-cnt..0], with each element separated bySUBSEP. Parameters: cdp[0]cnt, the number of elements to concatenate follows the command. sp[0]..sp[1-cnt] hold reference to the elements to concatenate. Returns the index in sp[0].a_delDeleteanarrayitem. Usage: delete array[expr] Parameters: sp[0] points toarraysp[-1] is anexpra_lengthFindthelengthofanarray. Usage: length(array) Parameters: sp[0] points toarray. Returns the length of the array in sp[0].a_pushaPusharrayaddressontostack. Usage: This is used to set up a calling argument for a function. Parameters: cdp[0] array reference follows the command. Returns the array in sp[0].a_testTestifanexpressionispresentinanarray. Usage: (expression in array) Parameters: sp[0] points toanarray. sp[-1] is anexpression. Returns 1 in sp[0] if the expression is found, 0 otherwise.addAddtwonumbers. Usage:first+secondParameters: sp[0] holds thesecondvalue. sp[-1] holds thefirstvalue. Returns the sum in sp[0].add_asgCombinedaddition/assignment. Usage:target+=sourceParameters: sp[0] is thesourceexpression sp[-1] points to thetargetStores the sum in thetarget, leaving sp[0] pointing to thetarget.ae_pushaPushreferencetoarraycell,givenexpressionforitsindex. Usage:arrayname[expression] Parameters: cdp[0] an array reference follows the command. sp[0] has an expression, used for the index of a cell in the array. Returns a reference to the addressed cell in sp[0].ae_pushiPushcontentsofarraycell,givenexpressionforitsindex. Usage:arrayname[expression] Parameters: sp[0] has an expression, used for the index of a cell in the array. Returns contents of the addressed cell in sp[0].aloopUpdatereferencetonextcellforarrayloop. Usage: for (iinarrayname)statementParameters: noneMawkmaintains a stack of array-loop state. It updates the array/cell references in the current loop's state.assignAssignsavalue. Usage:target=sourceParameters: sp[0] is thesourceexpression sp[-1] points to thetargetStores the sum in thetarget, leaving sp[0] pointing to thetarget.atan2Computearc-tangentoftwovalues. Usage: atan2(first,second) Parameters: sp[0] holds thesecondvalue sp[-1] holds thefirstvalue Returns the result in sp[0].callCallafunction. Usage:function() Parameters: cdp[0] is a reference to the function block cdp[1] holds number of input arguments Returns function value in sp[0].catConcatenatetwostrings. Usage:firstsecondParameters: sp[0] is thesecondstring. sp[-1] is thefirststring. Returns the result in sp[0].closeClosethefileorpipeassociatedwithanexpression. Usage: close(expression) Parameters: sp[0] holds theexpressionidentifying the file to close Returns the status from closing the file, 0 on success or -1 on failure.cosComputethecosineofavalueinradians. Usage: cos(value) Parameters: sp[0] is thevalue. Returns the result in sp[0].del_aDeleteanarray. Usage: delete(array) Parameters: sp[0] is thearrayto delete.divDivideonenumberbyanother. Usage:first/secondParameters: sp[0] is thesecondvalue. sp[-1] is thefirstvalue. Returns the quotient in sp[0].div_asgCombineddivision/assignment. Usage:target/=sourceParameters: sp[0] is thesourcesp[-1] points to thetargetStores the quotient in thetarget, leaving sp[0] pointing to the target.eqComparetwovalues. Usage:first==secondParameters: sp[0] is thesecondvalue sp[-1] is thefirstvalue Returns 1 in sp[0] if the values are equal, otherwise 0.exitExitsmawkwithaspecificexit-code. Usage: exit(exit_code) Parameters: sp[0] is theexit_codeexit0ExitsmawkwithsuccessUsage: exit Parameters: noneexpComputebase-eexponentialfunctionofavalue. Usage: exp(value) Parameters: sp[0] is thevalueReturns the result in sp[0].f_add_asgCombinationaddition/assignmenttoNF. Usage: NF +=expressionParameters: sp[0] is theexpressionto addf_assignAssignanexpressiontoNF. Usage: NF =expressionParameters: sp[0] is theexpressionf_div_asgCombinationdivision/assignmenttoNF. Usage: NF /=expressionParameters: sp[0] is theexpressionf_mod_asgCombinationmodulus/assignmenttoNF. Usage: NF %=expressionParameters: sp[0] is theexpressionf_mul_asgCombinationmultiplication/assignmenttoNF. Usage: NF *=expressionParameters: sp[0] is theexpressionf_post_decPost-decrementusingNF. Usage: NF-- Parameters: holds a reference to the field to usef_post_incPost-incrementusingNF. Usage: NF++ Parameters: holds a reference to the field to usef_pow_asgExponentiationusingNF. Usage: NF ^=expressionParameters: sp[0] is the expression to usef_pre_decPredecrementusingNF. Usage: --NF Parameters: sp[0] holds a reference to the field to usef_pre_incPreincrementusingNF. Usage: ++NF Parameters: sp[0] holds a reference to the field to usef_pushaPusharrayreferencetodatasplit-upasfields.. Usage: $0 =expressiongetline Parameters: cdp[0] is a reference to the data to be split/assigned. Returns the resulting array reference in sp[0].f_pushiPushcontentsofnumberedfield. Usage: $expressionParameters: cdp[0] holds a reference to $expressioncdp[1] holdsexpressionReturns the field's value in sp[0].f_sub_asgCombinationsubtraction/assignmenttoNF. Usage: NF -=expressionParameters: sp[0] holds a reference to the field to usefe_pushaPushreferencetonumberedfield. Usage: $numberParameters: sp[0] holds the fieldnumberReturns a reference to the field in sp[0].fe_pushiPushcontentofnumberedfield. Usage: $numberParameters: sp[0] holds the fieldnumberReturns the field's content in sp[0].fflushFlushtheoutputfileorpipeassociatedwithanexpression. Usage: fflush(expression) Parameters: sp[0] is theexpressionvalue Returns the result in sp[0].gtTestiffirstvalueisgreaterthanthesecond. Usage:first>secondParameters: sp[0] holds thesecondvalue. sp[-1] holds thefirstvalue. Returns 1 in sp[0] if thefirstvalue is greater than, otherwise 0.gteTestiffirstvalueisgreaterthanorequaltothesecond. Usage:first>=secondParameters: sp[0] holds thesecondvalue. sp[-1] holds thefirstvalue. Returns 1 in sp[0] if thefirstvalue is greater than or equal, otherwise 0.indexFindthepositionofthesecondstringinthefirst. Usage: index(first,second) Parameters: sp[0] is thesecondstring sp[0] is thefirststring Returns the position in sp[0] starting at 1 if found, 0 if not found.intReturnsavaluetruncatedtowardszero.. Usage: int(value) Parameters: sp[0] is the value Returns the result in sp[0].jmainGofromBEGINcodetoMAINcode. Usage: (internal state) Parameters: nonejmpJumptoanewbyte-codeposition,byagivennumberofbytes. Usage: (internal state) Parameters: cdp[0] holds the (signed) number of bytes by which to jump.jnzJumptoanewbyte-codepositionifsp[0]isnonzero,byagivennumberofbytes. Usage: (internal state) Parameters: cdp[0] holds the (signed) number of bytes by which to jump. sp[0] holds a value to compare against 0.jzJumptoanewbyte-codepositionifsp[0]iszero,byagivennumberofbytes. Usage: (internal state) Parameters: cdp[0] holds the (signed) number of bytes by which to jump. sp[0] holds a value to compare against 0.l_pushaPushalocaladdressontotheevaluationstack. Usage: (internal state) Parameters: cdp[0] holds the offset from theframepointerfp. Returns the address in sp[0].l_pushiPushcontentsofalocalvariableontotheevaluationstack. Usage: (internal state) Parameters: cdp[0] holds the offset from theframepointerfp. Returns the contents of the local variable in sp[0].la_pushaPushesareferencetoanarrayontotheevaluationstack. Usage:arraynameParameters: cdp[0] holds the offset from theframepointerfpof a reference to an array. Returns a reference to the array in sp[0].lae_pushaPushesareferencetoagivenarraycellontotheevaluationstack. Usage:arrayname[expression] Parameters: cdp[0] holds the offset from theframepointerfpof a reference to an array. sp[0] holds anexpressionReturns a reference to the specified array cell in sp[0].lae_pushiPushesthecontentsofagivenarraycellontotheevaluationstack. Usage:arrayname[expression] Parameters: cdp[0] holds the offset from theframepointerfpof a reference to an array. sp[0] holds anexpressionReturns the contents of the specified array cell in sp[0].lengthReturnsthelengthofastringorarrayvalue. Usage: length(value) Parameters: sp[0] is the string or array reference Returns the length in sp[0].ljnzSpecialjumpforlogical-OR,alwaysprecededbytest.Usage: (internal state) Parameters: cdp[0] holds the (signed) number of bytes by which to jump if the value is nonzero. sp[0] holds a value to compare against 0.ljzSpecialjumpforlogical-OR,alwaysprecededbytest.Usage: (internal state) Parameters: cdp[0] holds the (signed) number of bytes by which to jump if the value is zero. sp[0] holds a value to compare against 0.logComputethenaturallogarithmofavalue. Usage: log(value) Parameters: sp[0] is the value Returns the result in sp[0].ltTestiffirstvalueislessthanthesecond. Usage:first<secondParameters: sp[0] holds thesecondvalue. sp[-1] holds thefirstvalue. Returns 1 in sp[0] if thefirstvalue is less than, otherwise 0.lteTestiffirstvalueislessthanorequaltothesecond. Usage:first<=secondParameters: sp[0] holds thesecondvalue. sp[-1] holds thefirstvalue. Returns 1 in sp[0] if thefirstvalue is less than or equal, otherwise 0.match0Testif$0matchesagivenregularexpression. Usage: $0 ~regexParameters: cdp[0] holds a reference to a regular expression. Returns 1 in sp[0] if$0matches the regular expression, 0 otherwise.match1Testifagivenexpressionmatchesagivenregularexpression. Usage:expression~regexParameters: cdp[0] holds a reference to a regular expression. sp[0] holds an expression to test. Returns 1 in sp[0] if the expression matches the regular expression, 0 otherwise.match2Testifanexpressioninsp[-1]matchestheregularexpressioninsp[0]. Usage:expression~regexParameters: sp[0] holds a reference to a regular expression. sp[-1] holds an expression to test. Returns 1 in sp[0] if the expression matches the regular expression, 0 otherwise.mktimeConvertsadatespecificationinsystimeformattoatimestamp. Usage: mktime(string) Parameters: sp[0] holds the date-specification string Returns the result in sp[0].modComputemodulus/remainderwithtwooperands. Usage:first%secondParameters: sp[0] holds thesecondoperand sp[-1] holds thefirstoperand Returns the remainder in sp[0].mod_asgAssignmodulus/remainderwithtwooperands. Usage:first%=secondParameters: sp[0] holds thesecondoperand cdp[0] holds thefirstoperand Returns the remainder in sp[0] as well as replacing thefirstvalue.mulComputeproductwithtwooperands. Usage:first*secondParameters: sp[0] holds thesecondvalue sp[-1] holds thefirstvalue Returns the product in sp[0].mul_asgAssignproductwithtwooperands. Usage:first*=secondParameters: sp[0] holds thesecondvalue sp[-1] holds thefirstvalue Returns the product in sp[0] as well as replacing thefirstvalue.neqComparetwovalues. Usage:first!=secondParameters: sp[0] is thesecondvalue sp[-1] is thefirstvalue Returns 1 in sp[0] if the values are not equal, otherwise 0.nextReadthenextrecord,restartpatterntesting. Usage: next Parameters: nonenextfileBeginprocessingthenextfilelistedonthecommandline. Usage: nextfile Parameters: nonenf_pushiPushthenumberoffields(NF)ontotheevaluationstack. Usage: (internal state) Parameters: nonenotComputealogicalnegation. Usage: !valueParameters: sp[0] holds a value to negate. Returns the result on the evaluation stack, i.e., 0 if the value is nonzero and 1 otherwise.ol_glReadinto$0usinggetline. Usage: getline Parameters: noneol_gl_nrReadinto$0usinggetline,updatingNRandFNR. Usage: getline <fileParameters: noneomainStartexecutingthemainsectionofthescript(betweenBEGINandEND). Usage: (internal state) Parameters: nonepopPoptheevaluationstack,discardingthevalue. Usage: (internal state) Parameters: nonepop_alFinishanarray“in”loop,deallocatingthestateinformation. Usage: (internal state) Parameters: nonepost_decPost-decrementavalue. Usage:value-- Parameters: sp[0] holds the value to decrement Returns the updated value in sp[0].post_incPost-incrementavalue. Usage:value++ Parameters: sp[0] holds the value to increment Returns the updated value in sp[0].powComputethefirstvalueraisedtothepowerofthesecondvalue. Usage:first^secondParameters: sp[0] holds thesecondvalue sp[-1] holds thefirstvalue Returns the result in sp[0].pow_asgAssignthefirstvalueraisedtothepowerofthesecondvalue. Usage:variable=first^secondParameters: cdp[0] is a reference to the variable which will be assigned the result sp[0] holds thesecondvalue sp[-1] holds thefirstvaluepre_decPre-decrementavalue. Usage: --valueParameters: sp[0] holds thevalueto decrement. Returns the updated value in sp[0];.pre_incPre-incrementavalue. Usage: ++valueParameters: sp[0] holds thevalueto decrement. Returns the updated value in sp[0];.pushaPusharrayaddressontostack. Usage: (internal state) Parameters: cdp[0] array reference follows the command. Returns the array in sp[0].pushcPushadatacellontotheevaluationstack. Usage: (internal state) Parameters: cdp[0] is a reference to the data to push Returns a reference to the result in sp[0].pushdPushadoublefloatingvalueontotheevaluationstack. Usage: (internal state) Parameters: cdp[0] is a reference to the data to push Returns a reference to the result in sp[0].pushiPushcontentsofnextreferencedvariableontotheevaluationstack. Usage: (internal state) Parameters: cdp[0] is a reference to the data cell to copy. Returns a reference to the result in sp[0].pushintReservethenextslotontheevaluationstack,settingitstype. Usage: (internal state) Parameters: cdp[0] holds the type to set in the new slot, e.g., for data via I/O redirection Returns a reference to the result in sp[0].pushsPushareferencetoastringvalueontotheevaluationstack. Usage: (internal state) Parameters: cdp[0] holds a reference to the string value Returns a reference to the result in sp[0].randReturnsarandomnumberbetweenzeroandone.. Usage: rand() Parameters: none Returns the result in sp[0].rangeTestarangepattern:pat1,pat2{action}. Usage: (internal state) Parameters: cdp[0].op a flag, testpat1if on elsepat2cdp[1].op offset ofpat2code from cdp cdp[2].op offset of action code from cdp cdp[3].op offset of code after the action from cdp cdp[4] start ofpat1code sp[0] holds arguments for the action.retReturnafunctionvalue. Usage: returnvalueParameters: sp[0] holds the return value When calling a function,mawksaves the current stack, creating a new one. On return,mawkrestores the previous stack and returns the function value in sp[0].ret0Returnfromafunctionwithoutprovidingareturn-value. Usage: return Parameters: sp[0] is modified to make the value uninitialized. As in theretoperation,mawkrestores the previous stack. After the return, sp[0] is an uninitialized value.set_alBeginanarray“in”loop. Usage: for (iteratorinarrayname)statementParameters: sp[0] holds a reference to the array sp[-1] holds a reference to the iteration variableMawkpushes a new entry onto the array loop stack, and updates cdp to point to the statement to execute.sinComputethesineofavalueinradians. Usage: sin(value) Parameters: sp[0] holds the value Returns the result in sp[0].sprintfReturnsastringconstructedfromexpression-listaccordingtoformat. Usage: sprintf(format[, value1 [,... ] ] ) Parameters: sp[0] is the last parameter value; there can be up to 255. Returns the resulting string in sp[0].sqrtReturnsthesquarerootofavalue. Usage: sqrt(value0 Parameters: sp[0] is the value Returns the result in sp[0].srandSeedstherandomnumbergenerator. Usage: srand(value) srand( ) Parameters: sp[0] is the seed value, which may be uninitialized Returns the previous seed value in sp[0].stopFinisharangepattern. Usage: (internal state) Parameters: nonestrftimeFormatsthegiventimestampusingthegivenformat. Usage: strftime(format,timestamp,utc) strftime(format,timestamp) strftime(format) strftime( ) Parameters: Zero to three parameters may be on the stack. If all three are used, they are as follows: sp[0] is theutcflag sp[-1] is thetimestampvalue sp[-2] is theformatReturns the result in sp[0].subSubtractthesecondvaluefromthefirst. Usage:first-secondParameters: sp[0] holds thesecondvalue sp[-1] holds thefirstvalue Returns the result in sp[0].sub_asgAssignthedifferenceoftwovaluestoavariable. Usage:target=first-secondParameters: cdp[0] holds a reference to the variable to which to assign the result sp[0] holds thesecondvalue sp[-1] holds thefirstvalue Stores the difference in thetarget, leaving sp[0] pointing to thetarget.substreturnsthesubstringofstrings,startingatindexi,oflengthn. Usage: substr(s,i,n) substr(s,i) Parameters: Two or three parameters may be on the stack. If all three are used, they are as follows: sp[0] holds the lengthn. sp[0] holds the indexi. sp[0] holds the strings.systemExecutesacommand,returningthewait-status. Usage: status = system(command) Parameters: sp[0] is the command to execute Returns the wait-status in sp[0].systimeReturnsthecurrenttimeofdayasthenumberofsecondssincetheEpoch. Usage: systime( ) Parameters: none Returns the result in sp[0].testTestalogicalexpression. Usage:valueParameters: sp[0] holds a value to test. Returns the result on the evaluation stack, i.e., 1 if the value is nonzero and 0 otherwise.tolowerCopyastring,convertingtolowercase. Usage: tolower(value) Parameters: sp[0] is the value to convert Returns the result in sp[0].toupperCopyastring,convertingtouppercase. Usage: toupper(value) Parameters: sp[0] is the value to convert Returns the result in sp[0].uminusUnitaryminus. Usage: -valueParameters: sp[0] contains a value to negate. As a side-effect, if the value is a string, it is cast to double floating point. Returns the result in sp[0].uplusUnitaryplus. Usage: +valueParameters: sp[0] contains a value to use. As a side-effect, if the value is a string, it is cast to double floating point. Returns the result in sp[0].

**REGULAR** **EXPRESSIONS**

M_1Jmandatory jumpM_2JAoptional (undesirable) jumpM_2JBoptional (desirable) jumpM_2JCpop pos'n, optional jump if advancedM_ACCEPTend of matchM_ANYarbitrary character (.)M_CLASScharacter classM_ENDend of string ($)M_SAVE_POSpush position onto stackM_STARTstart of string (^)M_STRmatching a literal stringM_Uarbitrary string (.*)