[Mono-list] cpblk?
Michael Giagnocavo
mgg@atrevido.net
Fri, 24 May 2002 11:18:50 -0600
This is a multi-part message in MIME format.
------=_NextPart_000_0008_01C20314.CDF267C0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
>> Just assemble this -- it is a very simple case. It also
>> demonstrates how the cpblk doesn't have to work when the src and dest
>> addresses overlap. Test it on MSFT's CLR and you'll see that it
>> eventually fails (and sometimes works). It'd be cool if Mono's
always
>> worked (even though Partition III specifies "unspecified" behaviour
if
>> src and dest overlap).
> I just implemented it using unix memcpy(). Doku for memcpy states it
> does not work for overlapping regions, but IMO it makes no sense to
make
> that work, it only makes things slower.
Hmm. What if I want to move a block up by a few bytes?
>> This is only a lame test, I'm working on a much longer test
>> that's more accurate (protects IP) -- if you like I can send that
later.
> I would like to have a test that fails if CPBLK does not work. Your
test
> even pass if i implement CPBLK as NOP!
Well, not a NOP, since then the program would be invalid (throws me a
System.InvalidProgramException, since NOP does not have the same
signature. But you're right, I shouldn't have sent such bad code.
>> Is jmp implemented?
> No, but I will implement it as soon as I get some code to test ;-)
Here are you two simple working tests that will print PASS or FAIL.
Which other opcodes need a test?
Thanks,
-Mike
------=_NextPart_000_0008_01C20314.CDF267C0
Content-Type: application/octet-stream;
name="jmpTest.il"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="jmpTest.il"
.assembly extern mscorlib{}
.assembly jmpTest{}
.module jmpTest
.class private auto ansi jmpTest
extends [mscorlib]System.Object {
.method public static void go() cil managed {
.entrypoint
jmp void [jmpTest]jmpTest::pass()
ldstr "FAIL"
call void [mscorlib]System.Console::WriteLine(string)
ret
}
.method public static void pass() cil managed{
ldstr "PASS"
call void [mscorlib]System.Console::WriteLine(string)
ret
}
}
------=_NextPart_000_0008_01C20314.CDF267C0
Content-Type: application/octet-stream;
name="cpblkTest.il"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="cpblkTest.il"
.assembly extern mscorlib{}
.assembly cpblkTest{}
.module cpblkTest
.class private auto ansi test
extends [mscorlib]System.Object {
.field private static valuetype DataType dataField at theData
.method public static void start() cil managed {
.entrypoint
.locals init(int32, unsigned int8)
//store data address
ldsflda valuetype DataType test::dataField
stloc.0
//copy 7 to first position
ldloc.0 //dest
ldloc.0
ldc.i4.6
add //src
ldc.i4.1 //size
cpblk
//ldind value
ldloc.0
ldind.u1
//compare
ldc.i4.7
beq PASS
FAIL:
ldstr "FAIL"
call void [mscorlib]System.Console::WriteLine(string)
ret
PASS:
ldstr "PASS"
call void [mscorlib]System.Console::WriteLine(string)
ret
}
}
.class public explicit ansi sealed DataType
extends [mscorlib]System.ValueType
{.pack 1 .size 10}
.data theData = bytearray (1 2 3 4 5 6 7 8 9 10)
------=_NextPart_000_0008_01C20314.CDF267C0--