- How to call a procedure if do not we need a result?

From: [at]} <Aubrey.McIntosh{>
Date: Wed, 15 Aug 2007 07:19:43 -0500

----boundary-LibPST-iamunique-780532810_-_-
Content-type: text/plain

What do you gain by doing this?
What do you lose by doing this?
How does your problem push you to this selection of gain/loss?


On 8/15/07, Oleg N. Cher <allot{([at]})nowhere.xy
> 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
>


-- 
-- Aubrey McIntosh, Ph.D.
--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy----boundary-LibPST-iamunique-780532810_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIFdoYXQgZG8geW91IGdhaW4gYnkgZG9pbmcgdGhp
cz9ccGFyDQpXaGF0IGRvIHlvdSBsb3NlIGJ5IGRvaW5nIHRoaXM/XHBhcg0KSG93IGRvZXMgeW91
ciBwcm9ibGVtIHB1c2ggeW91IHRvIHRoaXMgc2VsZWN0aW9uIG9mIGdhaW4vbG9zcz9ccGFyDQpc
cGFyDQpccGFyDQpPbiA4LzE1LzA3LCBPbGVnIE4uIENoZXIgPGFsbG90QHVrci5uZXQ+IHdyb3Rl
OlxwYXIN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vd2VkIHRvIGJlIGlnbm9yZWQgaXMgYSAiYmFkIiBmdW5jdGlvbi4iLlxwYXINCj5ccGFy
DQo+ID4gV2hhdCBJIGRvIGlzXHBhcg0KPiA+IElGICBXaW5BcGkuPz8/ICgpID0gMCAgVEhFTiAg
RU5EO1xwYXINCj4gPiBOb3QgdmVyeSBlbGVnYW50LCBidXQgc2F2ZXMgZGVjbGFyaW5nIHVudXNl
ZCB2YXJpYWJsZXMuXHBhcg0KPlxwYXINCj4gT2xlZyBOLiBDaGVyLFxwYXINCj4gQ29sb3Nzb2Z0
IFJlc2VhcmNoLlxwYXINCj4gYWxsb3RAdWtyLm5ldFxwYXINCj4gMjAwNy0wOC0xNVxwYXINCj5c
cGFyDQo+IC0tLSBCbGFja0JveFxwYXINCj4gLS0tIHNlbmQgc3ViamVjdCBIRUxQIG9yIFVOU1VC
U0NSSUJFIHRvIGJsYWNrYm94QG9iZXJvbi5jaFxwYXINCj5ccGFyDQpccGFyDQpccGFyDQotLSBc
cGFyDQotLSBBdWJyZXkgTWNJbnRvc2gsIFBoLkQuXHBhcg0KXHBhcg0KLS0tIEJsYWNrQm94XHBh
cg0KLS0tIHNlbmQgc3ViamVjdCBIRUxQIG9yIFVOU1VCU0NSSUJFIHRvIGJsYWNrYm94QG9ifX0A
byBjYXB0dXJlIHQ=
----boundary-LibPST-iamunique-780532810_-_---
Received on Wed Aug 15 2007 - 14:19:43 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:31:24 UTC