Minisham.redbrick.dcu.ie

 CommandsMnemonicParametersDescriptionmov<destination>,<source>Sets <dest> = <src>. Does not affect <src>.nopDoes nothing for a cycle.add<destination>,<source>Sets <dest> = <dest> + <src>. Does not affect <src>.sub<destination>,<source>Sets <dest> = <dest> - <src>. Does not affect <src>.hltFrees up the CPU to do other stuff (?)Crt_printf<source> eg. ADDR string, <arg1>, <arg2>, … , <argx>Prints out the string using the given arguments.MessageBox0, ADDR <message>, ADDR <caption>, MB_OKCreates a message box with <message> in the body and <caption> as the head.ExitProcess0Shuts stuff down. Include this at the end of each program.Sleep<time>Idles for <time> millisecondsversionn/aReturns information about libraries being used.readIntegern/aStores value in eaxreadIntegerWithMessageADDR <message>Stores value in eax, with a given message prompt.writeInteger<source>Stores value from <src> in eaxneg<dst>Negate valueadc<dst>,<src>Add with carrysbb<dst>,<src>Subtract with borrowinc<dst>Increments signed value by onedec<dst>Decrements value by onemul<src>Unsigned multiplication of eax by <src>div<src>Unsigned division of eax by srcimul<src>Signed multiplication. Sets eax = eax*<src>imul<dst>,<src>Signed multiplication. Sets <dst> = <dst>*<src>imul<dst>,<src1>,<src2>Signed multiplication. Sets <dst> = <src1>*<src2>idiv<src>Signed divisionand<dst>,<src>or<dst>,<src>xor<dst>,<src>not<dst>Change 0 to 1 and 1 to 0shr<dst>,<count>Shift logical rightshl<dst>,<count>Shift logical leftsar<dst>,<count>Shift arithmetic rightLED SUBROUTINESwriteRow<row>,<bit value>Writes rowreadRow<row>Reads in supplied row to eaxsetPattern<1-5>Sets a pattern depending on number givenrandom<range>Gives a number between -range and range.Negation is necessary if you only need the positive numbers, using neg.Jump InstructionsMnemonicDescriptionSigned-nessFlagscmp<dest>,<src> Subtracts src from dest but doesn’t store the resultjmpAlwaysjne!=ZF=0je=unsignedZF=1ja>unsignedCF=0 ZF=0jae>=unsignedCF=0 ZF=1jb<unsignedCF=1jbe<=unsignedCF=1 ZF=1jg>signedZF=0 SF=ofjge>=signedSF=ofjl<signedSF != ofjle<=signedZF=1 or SF!= ofjcCF=1jncCF != 1NotesMultiplication works with 64 bits no matter what, when you multiply if it goes over 32 bits the rest of the value goes into edxDivision gives you the quotient (answer) and the remainder. The quotient goes into eax while the remainder goes into edx. Make sure that edx is zero before divisionWhen shifting left or right the last bit will be moved into the carry bit, using this we can shift right and check what the last number was (0/1) by incrementing at the occurrence of the desired numberUsing AND/OR will allow us to see what bits have changedRemember the sizes for each variablebyte "db" = 1 byteword or “dw” = 2 bytesdword or “dd” = 4 bytesCalculator > View > Programmer Calculatorusing sbyte,sword and sdword can be used for integersdon’t have to it just makes differentiating easierMake sure your strings are null terminatedstringName BYTE ‘blah’, 0string BYTE ‘this is an ascii character %c’,0crt_printf, ADDR string, num(between 32 and 127) string BYTE ‘this is a number %d’,0newLine BYTE 13,10,0 (this will print a new line)stringWithNewLine BYTE ‘this is a line’,10,0 (this will print a new line at the end of the message)Largest 32 bit signed integer: 2147483647 (7FFFFFFF)Largest 32 bit unsigned integer: 4294967295 (can’t be in hex)When writing hex do it like “07FFFFFFFh”Code ExamplesSkipping negative numbersinvoke random, 32cmp eax,0jge skipNegneg eaxskipNeg:mov randNum, eaxLoop of N timesi DWORD 0startLoop:cmp eax, Nje endLoopSTUFF GOES HEREinc imov eax,ijmp startLoop(sometimes this doesn’t work so decrement i instead)Checking Carry Flaginvoke readIntegersal eax,1jc flagSetjnc flagNotSetflagSet:invoke crt_printf,ADDR setinvoke ExitProcess,0flagNotSet:invoke crt_printf,ADDR notSetinvoke ExitProcess,0Calculating Factorialinvoke readIntegermov n , eaxmov product , eaxmov counter , eaxdec counterloopStart:cmp counter , 0je loopEndmov eax , productmul countermov product , eaxdec counterjmp loopStartloopEnd:invoke crt_printf , ADDR result , n , productLarger Than 32bitsmov eax,nummov edx,0mov ebx,eaxsal num,1cmp num,0jl largerThan32Bitsmul funccmp edx,0jg largerThan32Bitsinvoke crt_printf,ADDR notSetinvoke ExitProcess,0flagSet:invoke crt_printf,ADDR setinvoke ExitProcess,0largerThan32Bits:invoke crt_printf,ADDR notSetinvoke ExitProcess,0 ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download