ACNews #23
17 сентября 2003 |
|
Coding - On yet another way to the fort-like coding.
■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ On yet another way to the fort-like coding Echo35 (2:5029 / 35.26) ZX.SPECTRUM Msg: 447 of 547 -401 Snt Pvt Loc From: Dima Bystrov 2:5029 / 35.26 16 Jan 2003 17:44:07 To: Nick Sevryukov 16 Jan 2003 18:41:12 Subj: Re: FORTH Hello Nick! 14 Jan 2003 12:58, Nick Sevryukov wrote to Valerij Kozhevnikoff: VK>> Here are just a stack to be looked after. And then recover VK>> if necessary. VK>> All depends on how often and how is it called and how VK>> must be VK>> stack all the time. NS> The main thing is that it makes all the prog Nitak wrong. You NS> actually copied, only the last command jp (hl). NS> Read what I wrote earlier in the notes to the way it is NS> should work. NS> This piece is often enough to spoil and a stack of very NS> desirable! Simply, he (the stack) is used actively. [Skip] NS> Or you can arrange for another, only to remember that NS> have an array of addresses, which is posedovatelno NS> transition and a pointer to be automatically NS> rise to the following address (see above). there are more crazy idea:) does not have an array of addresses, and with JP ... a first approximation, it seems that there some losses, but it is not so! let the HL will be the current address (similar to (SP), but without treatment to the stack) why it is profitable to HL, in the course text will be appreciated:) "Larry is as follows: inc hl, hl, hl ... jp (hl) (+ JP = 18 +4 +10 = 32 clocks) (For comparison, call + ret = 27 cycles) best inc hl, hl, hl place at the beginning of subroutine with jp (hl) - in the end. if hl is vital, it can be push hl ... pop hl or (simultaneously with the readout parameter from the stack) ex (sp), hl ... pop hl or (in conjunction with zapihivaniem result in a stack) push hl ... ex (sp), hl (And other variations) (A conventional method, a call-ret, is difficult use the data stack inside a subroutine, call-ret loses about 40 cycles: ex (sp), hl: ld (exit +1), hl: pop hl, de ... exit: jp 0) between the jp-s can be inserted pieces of conventional mashkoda (plain code), but we must not forget to restore hl. for example:ld hl, $ +6 jp kudato +3 thus skipped inc hl, hl, hl. or even ld l, $ +5; h was equal to the old jp kudato +3 if we assume that the run-time "shell" that method and the classic is not just about concede to each other, then there ^ ^ ^ on this piece of plain code we win 8 or 11 bars! (By length is obtained by losing 02.03 bytes) in this case of (those same team) can be written even design plain code; call; goto! (Won by about 18 cycles and an average nibble) so looks like goto in the normal case: jp metka ld hl, kuda jp (hl) In fact, this record will never need, since case where to goto is plain code, we have discussed, so we consider case where the call is to goto: ld hl, kuda; or ld l jp metka +3 (Not quite a logical order, but to write such a compiler can) then winning 8 beats (or 11) and, if lucky, a byte. Now consider konktruktsiyu call with a numeric parameter in ordinary life is ld de, param: call metka but we will have jp metka dw param; so you can make a lot of options ... metka inc hl, hl, hl ld c, (hl) inc hl ld b, (hl) inc hl ... (Of course, the option to ld is also possible, but it is rarely beneficial) conditional branch can be written as: jp jpZ dw kuda ... jpZ inc hl, hl, hl jr z, jpZyes inc hl, hl jp (hl) jpZyes ld a, (hl) inc hl ld h, (hl) ld l, a jp (hl) or, if speed is important, jp z, kuda ld hl, $ +3; or ld l, $ +2 ... kuda ld hl, $ +3 (Then losing 6.5 bytes instead of 2) loop with a precondition: on an ordinary ACME writes: <...> jp while loop while jp cc, loop <...> but we will have (if we assume that <...> was call metka, and was call metka2): ld hl, while; or ld l jp metka +3 loop ld hl, $ +6; or ld l, $ +5 jp metka2 +3 <More body> while jp cc, loop ld hl, $ +6; or ld l, $ +5 [Call metka3 +3] (Gain in speed of approximately 9 cycles per iteration of the loop, loss of $ 5.4 B) intermediate result calculations shall be in the de For example, the expression with the addition of: push de pop hl add hl, de ex de, hl ld hl, $ +3 or subtraction: push de pop hl or a sbc hl, de ex de, hl ld hl, $ +3 or shorter, but more slowly (so you can record and any other operation): push de jp subpp ... subpp inc hl, hl, hl ex (sp), hl or a sbc hl, de ex de, hl pop hl jp (hl) maybe 2 spetsvyzova - jp (ix) and jp (iy), for something very frequent In general, it is less a fort, and the "alternate coding";) - Alone Coder [ZX-Guide] [Inferno] [AlCoNews] [ACEdit] [PT] [Chip] [STS] [ANSI] [8col] [UNRAR] --- GoldED/386 * Origin: The queue is in the store, "said T (c) S,-and this is SHOT :::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::: --------* List Honored Neispolzovateley AC Edit *------- 1) Pawel / Real_soft Paul Kislyak 2:454 / 11.25 2) Kurleson / HorrorSoft Alexey Kravchenko 2:5068 / 6 3) SirX Sergei G. Shelginsky sirx@atnet.ru Arkhangelsk Region., Severodvinsk, ul.Zh / Dorozhnaya 35-51 (818-4) 55-10-89, 8-921-670-02-85 4) Alex_Xor / PSV Alexander D. Shushkov axor@mail.ru (8172) 25-28-71, 160035 Vologda POBox 136 5) Diver/4d Alex Golubtsov orangefox@mail.ru 6) Noviset / Brutal_Creators Igor Shakhov [2:5050 / 109.52] ----------* List Honored Members AC Edit *--------- Honorary and eternal: 1) Nikphe Aleksey Emelyanov 391420 Ryazan region., Chuchkovsky rn, p.Avangard, Ruleznaya 12 2) Mr.Event Alexander Lesovskaya 391420 Ryazan region., Chuchkovo, Kalinin, 26 (8-238) 07/10/1973 3) CyberDemon Maxim Mit'kin 2:5029 / 35.18 Ryazan, ul.Novoselov, 50k2-197 4) Basil Basil E. Loginov, 390035 Ryazan, Poletaeva ,15-5 5) John_Silver Denis E. Loginov there:) 6) TS Sergey Tyurin triod@aport2000.ru 390029 Ryazan, High-,16-53 (0912) 75-40-74 8-903-640-01-49 7) U # 74 Sergey Machines u_74@mail.ru 443065 Samara, Pugachevskiy_trakt d.66 kv.3 8) Shaitan / SoK Maxim Shashkin 2:5057 / 21.36 (8462) 34-82-92 9) Dissonator Constantine Shaev 390048 Ryazan, ul.Zubkovoy ,19-106 (0912) 41-03-50 10) Way of the Samurai, Alexander Golovanov [aiki@mail.nnov.ru] 11) Dark Raven Semen Tsehmeyster 187500, Leningrad Region. g.Tihvin Mashinostroiteley 44, kv.151 12) Disabler / DPL Andrey Gorelov 344045 Rostov-on-Don ul.Mironova 3 / 3, kv.120 13) Max / Cyberax / BDA Maxim Arnold [amv@kuzbass.stack.ru] Other: 1914) Stormbringer / Cobra_Soft Valera Selev 2:462 / 162.7 79022 Ukraine, Lviv-22, PO Box 798 15) AmoNik Nikolai Amosov 2:5030 / 978.14, 500:812 / 2.26 (SPbZXnet) 16) Macros Sergei Gulyaev zxmsf@mail.ru 17) Jerri / AF Yuri Potapov, 2:5057 / 21.89 (8462) 92-73-26 18) Ldir / mp., I8 Jaroslav Turbin (0912) 77-40-37 last_128@mail.ru 390000 Ryazan Pervomajskij Ave 40k.1, kv.18 19) Chapay / mp. Viktor Spiridonov (0912) 76-07-36 mir_tut@mail.ru 390029 Ryazan ul.Stroiteley 1, kv.10 1920) Voodoo / Delirium_Tremens Dmitry Voo vooha@ua.fm 21) Risk / O
Other articles:
News - Pati (EnteR Activity 2003) to be held under the wing of the City Administration 29. |
Thoughts - When a child give to school, no one asked his opinion of the school curriculum. Why? |
Coding - On yet another way to the fort-like coding. |
Similar articles:
В этот день... 21 November