9 Nov 2008 12:44
Re: ( picoVerse-:( picoLARC AssemblerLisp test cases so far ) )
On Sat, 2008-11-08 at 15:29 -0800, Kjell Godo wrote: > If you know how to make these tools work off the top of your > head could you help me a little? I don't know anything about > executable file formats. I conjecture that flat file is what I want. > Since Udo tells CodeX to generate flat file in his Dolphin inline > assembler. Yes, you probably want the flat file format. > nasm ... ??? <---[ is it documented somewhere? a lot of times there > is no doc ] It has a manual > And then I don't know how to make a propper .asm file either so I will > have to learn propper assembler unless you could attach one. I think it might be useful for you to learn some assembler before you carry on with your code generator. I suggested nasm because it works on windows and you use ndisasm (which comes with it) to disassemble machine code. > Unix cmp or diff or ndisasm. I have Cygwin. I don't know how to use > it. Ming something for Ocean. I wonder if I should have Ming instead > of Cygwin. I downloaded all the development stuff into Cygwin but it > was huge and I feel like I should delete it the development > stuff again. > > I don't know how to use Unix. So I'd have to learn it. Any ideas how > I could do that quickly? You don't have to learn UNIX. I suggested diff but you could you use any text editor which shows differences between two files. > So it looks like it would be a lot more work for me to try to use > these unfamiliar tools than to just do it all in Dolphin Smalltalk > like I have done so far. But thank you for the pointers. Perhaps you > are suggesting that a lot of test cases could be generated > automatically? Perhaps not automatically (althought that is also possible), but you could do it in one big "batch" instead of writing a test case for each variation of every opcode (which will be a lot of cases). > Also : half of what I want to do is make a clear connection between > the source code and the machine code generated. So that this can be > like a live documentation for machine language. For newbies like me > and such. For instance: I found the Intel docs to be very > intimidating for years. I would just kind of stare at them and wonder > what the hell was going on in there. And then go on to something > else. I think it should be a lot easier than that. I'm trying to > make it so that a newbie can pick it up in less time than I did. I understand what you mean, but you have to think carefully about a better way to explain it. Is your code really clearer than the intel docs? > So perhaps if I could get the whole thing working a lot faster than I > am doing as you suggest if I knew how to work all the things you > brought up but even so maybe I would still do it the slow way so as to > make the clear association between source and machine code. Half of > what I am doing is rewriting the Intel docs in Smalltalk. > > It is a lot more readable when it is in color in Dolphin Smalltalk. > > I will try to think about what you said. > > What do you mean by simplify? > > Perhaps later on when if I get to the point where I am actually > generating multiple machine instructions I will want to come back to > your ideas here. Yes, don't you think it will be soon that have you to generate multiple machine instructions? > Will the user have to download a lot of stuff. Could I include that > stuff in a distribution. Could I run it all from Smalltalk. Udo runs > the CodeX assembler from Smalltalk. Yes you could. John > On Fri, Nov 7, 2008 at 1:18 PM, John Leuner > <jewel@...> wrote: > I think you could simplify your testing by writing the output > from a > sequence of tests to a binary file. > > Then use a command line assembler (like nasm) to assemble > source code > with the same desired output. > > Then simply compare the binary files, if they differ, try to > find where > they differ (with a tool like UNIX cmp), or generate a diff of > the > disassembly (using something like ndisasm) > > John > > > On Fri, 2008-11-07 at 12:42 -0800, Kjell Godo wrote: > > Below is the sequence of 9 tests of the picoLARC > AssemblerLisp's > > ability to generate machine code. My hat is off to the > person who > > suggested using ollydbg to generate the codes that can then > be > > tested against. That really made things a lot easier. I > seem to be > > able to understand machine code a little now. Which is > something > > that I despaired for a long time that I would ever be able > to do. So > > thank you to this mailing list for all your help. Thank you > so much. > > > > These tests are mainly supposed to test the addressing > modes. > > The next tests will be to test the scale:index:base: > addressing > > modes. > > > > Eventually I hope to have a Smalltalk Class implemented for > each > > Intel machine instruction. And a >>test: method for each of > those. > > > > I hope that in this way I can make a live documentation in > Smalltalk > > that shows how all the Intel machine codes work. > > > > There is also a CPU simulation included in each machine > instruction > > that needs to be tested. Hopefully that will make it easier > to make > > machine code that works. > > > > Once the ADD instruction is fully done I will post the > Smalltalk code > > to sourceforge.net in case anyone wants to step through the > tests > > shown below to see how they work. I think it is a clean > design that > > uses double dispatch to minimize the code a lot. > > > > That's one down 500+ to go. How long will all that take. > > > > I will try to get all the instructions implemented that you > need to > > get > > Udo's InLine Assembler thing to work in Dolphin Smalltalk. > He > > dumps machine code into a ByteArray in an ExternalMethod and > > then evaluates it and gets back an answer. That would be > cool. > > > > It will also be cool to somehow make an AssemblerLisp > debugger > > that would also understand picoLARC data Objects so you > > wouldn't be staring at addresses and hex numbers all the > time. > > > > > > > > > > "(| defineMethod-:(" test: testSelectionSeq ") > > notes-:( Method Version: keg1. > > © Copyright Kjell E Godø 20081021 > > copyLefted as GPL Open Source: Please execute ( Object > copyLeft ) for > > details. > > Date of Last Revision: Date today tradePrint 20081021 > > << OWNER-: Kjell E Godø SOFTWARE-: picoVerse VERSION-: 1 >> > > )-notes methodBody-:( > > (| let-:(" ") > > letBody-:(" "( MT b:#test: s:self )." > > ^( [ :testOC | > > testSelectionSeq testsToRun collect:[ :i | > > KEGTestResults new > > name:( ( testOC at:( i ) ) at:1 ) ; > > testIsSuccess:( > > [ ( ( testOC at:( i ) )at:2 )value ] on: Error do:[ :e > | e ] ) ; > > yourself ] > > ] value:( OrderedCollection new > > > "<------------------------------------------------------------------------------[ :testOC ]" > > > > add:( "<---[ ( 1 ) ]" > > Array with:( 'Test: ( add ( into:From: EAX 1 ) )' )with:[ > > ( KEGLambdaLispInterpreterV6p1 new > > compileAndGenerateByteCodesFor:( ' > > ( asm add ( into:From: EAX 1 ) ) ' ) ) > > contents"<---[ ollydbg : add eax, 1 ]" > > = ( ByteArray fromHexString: > > '83','C0','01' ) ] ) ;"<---[ register is set to > zero=000 in the > > ModR/M byte=2r11000000. mode=3=2r11 r/m=000 ]" > > > > add:( "<---[ ( 2 ) ]" > > Array with:( 'Test: ( add ( into:From: EBX 1 ) )' )with:[ > > ( KEGLambdaLispInterpreterV6p1 new > > compileAndGenerateByteCodesFor:( ' > > ( asm add ( into:From: EBX 1 ) ) ' ) ) > > contents"<---[ ollydbg : add ebx, 1 ]" > > = ( ByteArray fromHexString: > > '83','C3','01' ) ] ) ;"<---[ register is set to > zero=000 in the > > ModR/M byte=2r11000011. mode=3=2r11 r/m=011 ]" > > > > add:( "<---[ ( 3 ) This one also tests the hex > constants. ]" > > Array with:( 'Test: ( add ( into:From: EAX > 16r1000 ) )' )with:[ > > ( KEGLambdaLispInterpreterV6p1 new > > compileAndGenerateByteCodesFor:( ' > > ( asm add ( into:From: EAX 16r1000 ) ) ' ) ) > contents > > = ( ByteArray fromHexString: > > '05','00100000' ) ] ) ; > > > > add:( "<---[ ( 4 ) This one also tests the hex > constants. ]" > > Array with:( 'Test: ( add ( into:From: EAX > -16r1000 ) )' )with:[ > > ( KEGLambdaLispInterpreterV6p1 new > > compileAndGenerateByteCodesFor:( ' > > ( asm add ( into:From: EAX -16r1000 ) ) ' ) ) > contents > > = ( ByteArray fromHexString: > > '05','00F0FFFF' ) ] ) ; > > > > add:( "<---[ ( 5 ) This one also tests the hex > constants. ]" > > Array with:( 'Test: ( add ( into:From: EBX > 16r1000 ) )' )with:[ > > ( KEGLambdaLispInterpreterV6p1 new > > compileAndGenerateByteCodesFor:( ' > > ( asm add ( into:From: EBX 16r1000 ) ) ' ) ) > contents > > = ( ByteArray fromHexString: > > '81','C3','00100000' ) ] ) ;"<---[ 16rC3 = 2r11000011 > mode=11 > > reg=000 r/m=011 => EBX ]" > > > > add:( "<---[ ( 6 ) Test the address displacement and > immediate > > value. ]" > > Array with:( 'Test: ( add ( into:From: ( at ( + EBP 4 ) ) > > 16r1000 ) )' )with:[ > > ( KEGLambdaLispInterpreterV6p1 new > > compileAndGenerateByteCodesFor:( ' > > ( asm add ( into:From: ( at ( + EBP 4 ) ) 16r1000 ) ) > ' ) ) > > contents > > = ( ByteArray fromHexString: > > '81','45','04','00100000' ) ] ) ; "<---[ ollydbg : add > dword[ ebp > > + 4 ], 1000 ]" > > > > add:( "<---[ ( 7 ) Test negative address displacement and > immediate > > value. ]" > > Array with:( 'Test: ( add ( into:From: ( at ( - EBP 4 ) ) > > 16r1000 ) )' )with:[ > > ( KEGLambdaLispInterpreterV6p1 new > > compileAndGenerateByteCodesFor:( ' > > ( asm add ( into:From: ( at ( - EBP 4 ) ) 16r1000 ) ) > ' ) ) > > contents > > = ( ByteArray fromHexString: > > '81','45','FC','00100000' ) ] ) ; "<---[ ollydbg : add > dword[ ebp > > - 4 ], 1000 ]" > > "<---[ 16r45 = 2r01000101 => mod=01 reg=000 r/m=101 , > 16rFC = > > 2r11111100 = -4 ]" > > > > add:( "<---[ ( 8 ) Test the address displacement and > immediate > > value. ]" > > Array with:( 'Test: ( asm add ( into:From: ( at ( + EBP > 16r1000 ) ) > > -1 ) )' )with:[ > > ( KEGLambdaLispInterpreterV6p1 new > > compileAndGenerateByteCodesFor:( ' > > ( asm add ( into:From: ( at ( + EBP 16r1000 ) ) -1 ) ) > ' ) ) > > contents > > = ( ByteArray fromHexString: > > '83','85','00100000','FF' ) ] ) ; "<---[ ollydbg : add > dword[ ebp > > + 1000 ], -1 ]" > > "<---[ 16r85 = 2r10000101 => mod=10 reg=000 r/m=101 ]" > > > > add:( "<---[ ( 9 ) Test negative address displacement and > immediate > > value. ]" > > Array with:( 'Test: ( add ( into:From: ( at ( - EBP > 16r1000 ) ) > > 1 ) )' )with:[ > > ( KEGLambdaLispInterpreterV6p1 new > > compileAndGenerateByteCodesFor:( ' > > ( asm add ( into:From: ( at ( - EBP 16r1000 ) ) 1 ) ) > ' ) ) > > contents > > = ( ByteArray fromHexString: > > '83','85','00F0FFFF','01' ) ] ) ; "<---[ ollydbg : add > dword[ ebp > > - 1000 ], 1 ]" > > "<---[ 16r85 = 2r10000101 => mod=10 reg=000 r/m=101 ]" > > > > add:( "<---[ ( ) Test negative address displacement and > immediate > > value. ]" > > Array with:( 'Test: ( add ( into:From: ( at:sized: ( - > EBP 4 ) 4 ) > > 16r1000 ) )' )with:[ > > ( KEGLambdaLispInterpreterV6p1 new > > compileAndGenerateByteCodesFor:( ' > > ( asm add ( into:From: ( at:sized: ( - EBP 4 ) 4 ) > > 16r1000 ) ) ' ) ) contents > > = ( ByteArray fromHexString: > > '81','45','FC','00100000' ) ] ) ; "<---[ ollydbg : add > dword[ ebp > > - 4 ] 1000 ]" > > "<---[ 16r45 = 2r01000101 => mod=01 reg=000 r/m=101 , > 16rFC = > > 2r11111100 = -4 ]" > > > > yourself > > )"<---[ testOC ]" > > > > )"return:( MT e:#test: s:self )" > > > > ")-letbod )-let > > )-methBod > > methodDescriptionSummary-:( > > > > This is the main test method for self-:( this Class ). > > It takes in a sequence of test Symbols and performs all the > > associated tests and > > returns a sequence of KEGTestResults which mainly contain > Booleans. > > > > )-summary > > methodDescriptionDetail-:( > > > > These tests verify that the picoLARC AssemblerLisp is > generating the > > same > > machine byte codes that the program OllyDbg generates. > Here is how > > OllyDbg > > is used to generate the machine byte codes shown above. > > ( begin > > ( find odbg200h.zip at http://www.ollydbg.de ) > > ( Open using Windows compressed folder opener if > necessary at > > into > > C:\Kris\Kjell\Downloads\Languages\OllyDbg\odbg200h.zip ) > > ( Open OllyDbg at: C:\Kris\Kjell\Downloads\Languages > \OllyDbg > > \odbg200h.zip\ollydbg.exe ) > > ( copy c:\windows\notepad.exe to c:\Kris\Kjell > \Downloads > > \Languages\JunkExecutableFile\notepad.exe ) > > ( ollydbg menuBar=> File=> Open..=> > JunkExecutableFile=> > > notepad.exe=> Open ) > > ( select a section of the code by LeftClick followed > by Shift > > +LeftClick ) > > ( RightClick=> Assemble...=> Type in the Assembler to > compile=> > > Assemble > > Also you can uncheck the Keep Size checkbox to get more > space for > > the next instruction ) > > ( Now look in the code column to find the newly > assembled code ) > > )-[ begin ] > > > > )-detail > > usage-:( > > usage > > )-usage > > toDebugEvaluate-:( > > KEGGenDebugger > > editDebugPresent:( 'KEGLambdaLispCompilerV6p1>>test:' ) > > )-todebug > > todos-:( > > todos > > )-todos > > changes-:( > > (| KEG4-:( Changes onDate-:( ... ) > > madeChanges-:( ... )-madechanges )-chg )-keg4 > > or > > (| KEG4-:( Changes onDate-:( ... ) theOldCode-:( ... ) > > wasReplacedBy-:( ... ) )-chg )-keg4 > > (| KEG3-:( Changes onDate-:( ... ) theOldCode-:( ... ) > > wasReplacedBy-:( ... ) )-chg )-keg3 > > (| KEG2-:( Changes onDate-:( ... ) theOldCode-:( ... ) > > wasReplacedBy-:( ... ) )-chg )-keg2 > > )-changes > > testCases-:( > > testCases > > )-testCases > > alternateCode-:( > > )-alternateCode > > designs-:( > > ( DESIGN subject-:( aPackageName )of-:( > > )-of )-design > > )-designs > > rants-:( > > rantsrantsrants rantsrants > > )-rants )-defineMethod" > > > > > _______________________________________________ > > fonc mailing list > > fonc@... > > http://vpri.org/mailman/listinfo/fonc > > > _______________________________________________ > fonc mailing list > fonc@... > http://vpri.org/mailman/listinfo/fonc >
RSS Feed