----boundary-LibPST-iamunique-2064654928_-_-
Content-type: text/plain
Hello, Robert,
I disassembled and analysed some code produced by
BlackBox compiler. My old variant:
dummy := WinApi.SetConsoleCP(cp);
dummy := WinApi.SetConsoleOutputCP(cp);
.004010CC: FF7508 push d,[ebp][00008]
.004010CF: E872000000 call .000401146 ; SetConsoleCP
.004010D4: 8945F4 mov [ebp][-000C],eax ; --- superfluous code
.004010D7: FF7508 push d,[ebp][00008]
.004010DA: E861000000 call .000401140 ; SetConsoleOutputCP
.004010DF: 8945F4 mov [ebp][-000C],eax ; --- superfluous code
---------------------------------------------------------------------------
And your variant, Robert:
IF WinApi.SetConsoleCP(cp) = 0 THEN END;
IF WinApi.SetConsoleOutputCP(cp) = 0 THEN END;
.004010BF: FF7508 push d,[ebp][00008]
.004010C2: E87F000000 call .000401146 ; SetConsoleCP
.004010C7: 09C0 or eax,eax ; --- superfluous code
.004010C9: 0F8500000000 jne .0004010CF ; --- superfluous code
.004010CF: FF7508 push d,[ebp][00008]
.004010D2: E869000000 call .000401140 ; SetConsoleOutputCP
.004010D7: 09C0 or eax,eax ; --- superfluous code
.004010D9: 0F8500000000 jne .0004010DF ; --- superfluous code
.004010DF:
---------------------------------------------------------------------------
Today I found better method to do it more effectively:
SYSTEM.PUTREG(0, WinApi.SetConsoleCP(cp)); (* Put result to reg EAX *)
SYSTEM.PUTREG(0, WinApi.SetConsoleOutputCP(cp)); (* Put result to reg EAX *)
.004010CC: FF7508 push d,[ebp][00008]
.004010CF: E86E000000 call .000401142 ; SetConsoleCP
.004010D4: FF7508 push d,[ebp][00008]
.004010D7: E860000000 call .00040113C ; SetConsoleOutputCP
The complier KNOWS that a result is ALREADY in register EAX,
and does not generates a superfluous code. All what I need :-)
Thank you.
BTW, I agreed with m-r. Marco Ciot - "A function that returns
a value that is allowed to be ignored is a "bad" function.".
> What I do is
> IF WinApi.??? () = 0 THEN END;
> Not very elegant, but saves declaring unused variables.
Oleg N. Cher,
Colossoft Research.
allot{([at]})nowhere.xy
2007-08-15
--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy
----boundary-LibPST-iamunique-2064654928_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTFcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIEhlbGxvLCBSb2JlcnQsXHBhcg0KXHBhcg0KSSBk
aXNhc3NlbWJsZWQgYW5kIGFuYWx5c2VkIHNvbWUgY29kZSBwcm9kdWNlZCBieVxwYXINCkJsYWNr
Qm94IGNvbXBpbGVyLiBNeSBvbGQgdmFyaWFudDpccGFyDQpccGFyDQpcdGFiIGR1bW15IDo9IFdp
bkFwaS5TZXRDb25zb2xlQ1AoY3ApO1xwYXINClx0YWIgZHVtbXkgOj0gV2luQXBpLlNldENvbnNv
bGVPdXRwdXRDUChjcCk7XHBhcg0KXHBhcg0KLjAwNDAxMENDOiBGRjc1MDggICAgICAgIHB1c2gg
ICAgZCxbZWJwXVswMDAwOF1ccGFyDQouMDA0MDEwQ0Y6IEU4NzIwMDAwMDAgICAgY2FsbCAgIC4w
MDA0MDExNDYgICAgICAgIDsgU2V0Q29uc29sZUNQXHBhcg0KLjAwNDAxMEQ0OiA4OTQ1RjQgICAg
ICAgIG1vdiAgICAgW2VicF1bLTAwMENdLGVheCA7IC0tLSBzdXBlcmZsdW91cyBjb2RlXHBhcg0K
Lj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