📄 stdin.hhf
字号:
#if( ! @defined( stdin_hhf ))?stdin_hhf := true;#includeOnce( "hla.hhf" )#includeOnce( "stdio.hhf" )/***********************************************************************//* *//* The stdin Namespace: *//* *//***********************************************************************/namespace stdin; @fast; procedure handle; @returns( "eax" ); @external( "STDIN_GETSTDINHANDLE" ); procedure read( var buffer:byte; count:dword ); @external( "STDIN_READ" ); procedure readLn; @external( "STDIN_READLN" ); procedure flushInput; @external( "STDIN_FLUSHINPUT" ); procedure eoln; @returns( "al" ); @external( "STDIN_EOLN" ); procedure eoln2; @returns( "al" ); @external( "STDIN_EOLN2" ); procedure getc; @returns( "al" ); @external( "STDIN_GETC" ); procedure peekc; @returns( "al" ); @external( "STDIN_PEEKC" ); procedure gets( s:string ); @returns( "eax" ); @external( "STDIN_GETS" ); procedure a_gets; @returns( "eax" ); @external( "STDIN_A_GETS" ); procedure geti8; @returns( "al" ); @external( "STDIN_GETI8" ); procedure geti16; @returns( "ax" ); @external( "STDIN_GETI16" ); procedure geti32; @returns( "eax" ); @external( "STDIN_GETI32" ); procedure geti64; @returns( "edx:eax" ); @external( "STDIN_GETI64" ); procedure geti128( var dest:lword ); @external( "STDIN_GETI128" ); procedure getu8; @returns( "al" ); @external( "STDIN_GETU8" ); procedure getu16; @returns( "ax" ); @external( "STDIN_GETU16" ); procedure getu32; @returns( "eax" ); @external( "STDIN_GETU32" ); procedure getu64; @returns( "edx:eax" ); @external( "STDIN_GETU64" ); procedure getu128( var dest:lword ); @external( "STDIN_GETU128" ); procedure geth8; @returns( "al" ); @external( "STDIN_GETH8" ); procedure geth16; @returns( "ax" ); @external( "STDIN_GETH16" ); procedure geth32; @returns( "eax" ); @external( "STDIN_GETH32" ); procedure geth64; @returns( "edx:eax" ); @external( "STDIN_GETH64" ); procedure geth128( var dest:lword ); @external( "STDIN_GETH128" ); procedure getf; @returns( "st0" ); @external( "STDIN_GETF" ); #macro get( _parms_[] ): _curparm_, _pType_, _arg_, _id_, _tempid_, _saveTrace_; // Turn off tracing through this macro. ?_saveTrace_ := @trace; ?@trace := false; ?_curparm_:uns32 := 0; // Save important registers that the "GET" macro uses. push( eax ); // The following loop repeats once for each GET parameter // we process. #while( _curparm_ < @elements( _parms_ )) // If this parameter begins with an identifier, // there are some problems to deal with. // The symbol table functions (e.g., @ptype) don't // allow address expression components after the // symbol name. Named constants, however, do allow // such entities. The following code determines // (1) is this a symbol? (2) if it is a symbol, is // it a constant? // // For non-constant symbols, we need to strip any // trailing non-symbol characters from the string // (e.g., "[0]" ). ?_arg_ := @trim( _parms_[ _curparm_ ], 0 ); #if( char( _arg_ ) in stdio._idchars_ ) // If this parameter begins with an id character, // then strip away any non-ID symbols from the // end of the string. Then determine if we've // got a constant or some other class (e.g., // variable or procedure). If not a constant, // keep only the name. If a constant, we need // to keep all trailing characters as well. ?_id_ := stdio._GetID_( _arg_ ); #if ( @class( @text( _id_ )) = hla.cConstant | @class( @text( _id_ )) = hla.cValue ) ?_id_ := _arg_; #endif #else // If it's not an ID, we need to keep everything. ?_id_ := _arg_; #endif // Determine the type of this parameter so we can // call the appropriate routine to input it. ?_pType_ := @pType( @text( _id_ )); ?_tempid_ := _id_; #while( _pType_ = hla.ptArray ) ?_tempid_ := @typename( @text( _tempid_ )); ?_pType_ := @pType( @text( _tempid_ )); #endwhile // Based on the type, call the appropriate library // routine to print this value. #if( _pType_ = hla.ptBoolean ) #error( "Boolean input is not supported" ); #elseif( _pType_ = hla.ptUns8 ) stdin.getu8(); #if( _arg_ = "al" ) mov( al, [esp] ); #elseif( _arg_ = "ah" ) mov( al, [esp+1] ); #else mov( al, @text( _arg_ )); #endif #elseif( _pType_ = hla.ptUns16 ) stdin.getu16(); #if( _arg_ = "ax" ) mov( ax, [esp] ); #else mov( ax, @text( _arg_ )); #endif #elseif( _pType_ = hla.ptUns32 ) stdin.getu32(); #if( _arg_ = "eax" ) mov( eax, [esp] ); #else mov( eax, @text( _arg_ )); #endif #elseif( _pType_ = hla.ptUns64 ) push( edx ); stdin.getu64(); mov( eax, @text( "(type dword " + _arg_ + ")" )); mov( edx, @text( "(type dword " + _arg_ + "[4])" )); pop( edx ); #elseif( _pType_ = hla.ptUns128 ) stdin.getu128( @text( _arg_ ) ); #elseif( _pType_ = hla.ptByte ) stdin.geth8(); #if( _arg_ = "al" ) mov( al, [esp] ); #elseif( _arg_ = "ah" ) mov( al, [esp+1] ); #else mov( al, @text( _arg_ )); #endif #elseif( _pType_ = hla.ptWord ) stdin.geth16(); #if( _arg_ = "ax" ) mov( ax, [esp] ); #else mov( ax, @text( _arg_ )); #endif #elseif( _pType_ = hla.ptDWord ) stdin.geth32(); #if( _arg_ = "eax" ) mov( eax, [esp] ); #else mov( eax, @text( _arg_ )); #endif #elseif( _pType_ = hla.ptQWord ) push( edx ); stdin.geth64(); mov( eax, @text( "(type dword " + _arg_ + ")" )); mov( edx, @text( "(type dword " + _arg_ + "[4])" )); pop( edx ); #elseif( _pType_ = hla.ptLWord ) stdin.geth128( @text( _arg_ ) ); #elseif( _pType_ = hla.ptInt8 ) stdin.geti8(); #if( _arg_ = "al" ) mov( al, [esp] ); #elseif( _arg_ = "ah" ) mov( al, [esp+1] ); #else mov( al, @text( _arg_ )); #endif #elseif( _pType_ = hla.ptInt16 ) stdin.geti16(); #if( _arg_ = "ax" ) mov( ax, [esp] ); #else mov( ax, @text( _arg_ )); #endif #elseif( _pType_ = hla.ptInt32 ) stdin.geti32(); #if( _arg_ = "eax" ) mov( eax, [esp] ); #else mov( eax, @text( _arg_ )); #endif #elseif( _pType_ = hla.ptInt64 ) push( edx ); stdin.geti32(); mov( eax, @text( "(type dword " + _arg_ + ")" )); mov( edx, @text( "(type dword " + _arg_ + "[4])" )); pop( edx ); #elseif( _pType_ = hla.ptInt32 ) stdin.geti128( @text( _arg_ ) ); #elseif( _pType_ = hla.ptChar ) stdin.getc(); #if( _arg_ = "al" ) mov( al, [esp] ); #elseif( _arg_ = "ah" ) mov( al, [esp+1] ); #else mov( al, @text( _arg_ )); #endif #elseif( _pType_ = hla.ptCset ) #error( "Cset input is not supported" ); #elseif ( _pType_ = hla.ptReal32 | _pType_ = hla.ptReal64 | _pType_ = hla.ptReal80 ) stdin.getf(); fstp( @text( _arg_ )); #elseif( _pType_ = hla.ptString ) #if( _arg_ = "eax" ) stdin.gets( [esp] ); #else stdin.gets( @text( _arg_ )); #endif #else #error ( "stdin.get: Unknown data type (" + _parms_[ _curparm_ ] + ":" + @typename( @text( _id_ )) + ")" ); #endif ?_curparm_ := _curparm_ + 1; #endwhile // Restore the registers pushed earlier for this call to // the GET macro. Note that this statement does not end // with a semicolon. This is to force the programmer to // put a semicolon after the stdin.get(--) invocation. pop( eax ) // Restore trace flag: ?@trace := _saveTrace_; #endmacro end stdin;#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -