ZX Format #03
29 февраля 1996 |
|
Programmers - assembler: Excursion to the anatomy of the ZX
Digression into the anatomy of the ZX (C) DICTATOR _______________________________ Prologue. "And here to submit this Tyapkina-Lyapkin! The reaction of readers to the cycle "Assembler for Dummies" has been so extensive and unexpected that plunged us into deep reflection of the impermanence of all things. By and large, all responses can be divided into two types: "This is that - evil joke?" and "We do not kitchen utensils, our food for the brain is needed, but not for ...". In a word all consider themselves at least "start" and require that it requires deeper their knowledge. Well, here we are, what you answer. Unfortunately, not enough just to know assembler, to teach him to others, we must also and be able to teach. And, as shown practice, these two qualities are somehow trying to avoid each other. At this stage we are still failed to find a person suitably qualified in both of the above manifestations, but hope, as we know, dies the latter, and perhaps you have can read in our magazine a full course of "A" to "RESET INTERRUPTION ". In the meantime, are continuing the search, we decided to publish some feature articles covering the most frequently occurring in "initiating and enhance" the problem. In the next issues we ZF going to address the following directions: - Optimization of programs for speed and time; - Faster graphics; - Wretchedness of the TR-DOS, and how this fight; - 3D-vector and 3Danimatsiya. Changes to this list possible, even necessary, and will be produced, mainly based on your letters. Sitting at home in myagom chair with a bottle of beer, the author can not guess what do people want - bread? spectacles? 3D-joystick? or too beer? Wherefore write, call, come and express their thoughts about the need for one or a theme (it is better to write). CHAPTER ONE. "Tell me, what program you wrote, and I'll tell you who you are. " Duty is the author repeatedly faced with the following situation: there is a newfound genius, and looking at the world down, it presents itself to the world the creation, which is comparable to his genius author. But at the first testing are clarified some details: shaking the cursor at the top of the screen, twitching sprites program speed is not uniform ... And all this only If a new masterpiece in general deign to work not only on machine of its creator, but also at would be at half mass-produced computers. Global causes of this unfortunate case is usually two: a) present the programmer does not adhere to any standards and regulations, or the only correct said his car; b) this individual is related to category of very good teachers. But, as with the second paragraph This summary is almost impossible to fight, we will focus on first, namely talk about standards. Each sinkleristu from the cradle should be aware that such masked interrupt and what they need. If for kakimlibo reason you missed this significant period of life or Your childhood was held on the keyboard IBM PC, then maybe you is not without interest to learn some details about this insidious phenomenon. Masked interrupt signal (hereinafter INT) is generated Simultaneity with the arrival of personnel clock having frequency 50 hertz (50 times per second). By the arrival of the same human clock starts construction of the video, but considering the hardware features of both your computer and the monitor screen, construct a larger size than actually observed. In the standard computer build time eight horizontal pixels takes 4 stroke engine, one a horizontal line - 224 cycles, while the number of lines on screen - 312. Thus we can calculate the number of clock cycles that the processor can execute during construction of the entire screen - this number is about 70.000 cycles. It is also worth noting that this includes the time quenching INT, but it is not as significant a factor, in addition to his understanding of the need to understand in computer architecture and not on amateur level. The prose of life is that this is a purely theoretical meaning and practice to bear in mind that the RAM usually works brake ROM and it makes adjustments in performance. Observant reader will have guessed that the video controller ZX displays the screen much faster than it can build program, because the elementary team LDI takes 16 clock cycles, and construction of eight bits of the screen - 4 tact. So, if you start to rebuild the screen simultaneously with the arrival of INT'a and trying to capture the entire screen, in the middle of this noble classes videocontroller you catch and surpass, and the rest screen will be shown only in the next cycle interruption. As far as the author of this manuscript, a large part of the new generation of programmers all of the above have not yet realized, and continues to rivet the trembling and blinking cursor sprites. How to combat these phenomena and dedicated to the next chapter. CHAPTER AVERAGE. "Nothing works for so long. " To learn why there trembling cursors consider the whole process in detail. Standard algorithm cursor system is usually as follows: 1. remember the buffer contents of the screen to the point where the cursor will be displayed; 2. superimpose on the screen cursor by mask; 3. Examine the keypad, recalculate the coordinates of the cursor; 4. restore contents screen at the cursor in the previous position and go to Item 1. Naturally begs the question timing of all this business with preemption and, consequently, beginning construction of the screen. The optimal output is to use the command HALT between the third and fourth paragraph and the minimum number of procedures, hanging on the interrupt or better yet a complete lack of them or priority allocation at execution time. And then the fun begins. From the beginning of the video screen before the first pixel number of working screen (ie the beginning of a video buffer, located on the addresses # 4000) in a standard machine is built 70 lines curb, which takes 15,680 clock cycles. However, an abundance of mysterious (read-brake) circuit decisions on some computers causes the stick to a few other figures. The author had never seen vehicles braking Scorpio and therefore recommends that you stick critical reading of this machine, namely the 60 lines, which is 13.440 cycles. So, if the procedures are erasing the cursor, copy the buffer and overlay the cursor fit in beyond that figure, the cursor looks very nice and not even has no chance to arrange megadrozhanie in any part of Spectrum screen. Bright example might be a shell ZF and, in particular, MEMORY TEST of the second issue of shadow businesses. If You look carefully, you notice that the two cursors simultaneously processed, the aggregate amount of which is 10 familiarity. Preliminary results all of the above, the author apologizes if you something was unclear because of the inability of the author himself available to present the material in paper. But if you're still reading and you are still wondering I probably will state summary the first part. The main requirement for the program, working with the dynamic graphics is: no matter what side of the screen, this programa or rebuilt, at Whatever it is machine or work, for the absence of flickering images during the construction thereof, video controller does not have to cross the tunable range. In this case, no importance, You overtake him, or he you. Despite the fact that in this chapter has outlined the basics anatomy of the ZX, it should be at least enough to early experiments, which sooner or later will lead you to full consensus with dynamic graphics and border lines. But, as history has shown clearly, the experiment experiment strife, and severity of the knife need to check on someone else's throat. Developing this idea, we quietly crept up to the next chapter of which you may podcherpnete something interesting about the methods debug programs that are critical for time and location in the loop interrupts. CHAPTER almost the last. "I figeyu, Toshiko, bamboo bloomed. " Many programmers often concerned about the issue "but as a long running my new / old / better / in-depth treatment?". If you have not guessed it done any hardware gadgets, and your brains are not predisposed to distort the course of thought, then, most cases, the silence will be your answer. However, as said the classic, all brilliant simple method described below and fully consistent with this thesis. The first thing you should turn off all the turbo mode and the brakes and bring the car in the most close to the standard mode work. Next take a strip of paper 2 cm wide, 97 mm tall with a display of your favorite TV or monitor and nail it to this very screen. After finishing this lesson vysokointelektualnoe, download TASM 4.0 (XL Design) and tamp the following program: ORG # 8000 DI; creation LD HL, # FE00; vector LD A, H; masks LD I, A; emyh INC A; interrupt LD (HL), A; vany INC L JR NZ, $ -2 LD C, H INC H LD (HL), A LD L, A LD (HL), # C9 IM 2 ; The main loop, in other words ; The very essence of LOOP EI LD B, 7 HALT OUT (C), B OOPS DS 13440 / 4,0 OUT (C), 0 XOR A IN A, (C) CPL AND # 1F JP Z, LOOP LD A, # 3F LD I, A IM 1 EI RET It should be noted that the reference TASM 4.0 (XLD) was not accidental. This product is recommended due to the implementation of it the commands such as OUT (C), 0, and DS. The result of this program will strip white color on the black borders, synchronized with the start screen. Next, you should take the felt-tip pen and glued to hold on TV piece of paper a line parallel to the bottom of the white stripe. Next to this feature please "13.440" and if you have not yet understood the essence of the method, then the medicine is here powerless (good joke). The attentive reader will have guessed sense of lines of code that is marked Tagged OOPS. It creates in memory of 13,440 / 4 = 3360 teams NOP, and the implementation of which is actually 13,440 cycles. Thus, after sitting ten minutes around the monitor with a felt pen in his mouth, substituting it line values in thousands of cycles, you will form a scale which will enjoy the rest of adult life. If you prefer, you can make marks on the every thousand cycles, but this Of course, if you have the patience and ink. We now turn to the second Part of this method. To determine where in the cycle interrupt routine is defined, and what time it runs, you need to do three basic things: 1. before the desired sub-program to put a conclusion on border of any color different from the primary color border; 2. at the end of the subroutine to restore the background color border; 3. look at the curb in run time, where is a dedicated semiconductor and, accordance with the scale to calculate its duration. In most cases, particularly if you have a little fancy programming real-time reaction of the experimenter in other words, full ofigevanie and appeal to the Toshiko great, not name. If now you do not understand the essence this method, then direct you to the road to the club Dendy MegaYunior or to the nearest store for PENTIUM-133. That's how, step by step, we come to the final part of today's lecture, which summarizes the basic requirements for the programs and programmers, as well are some useful health tips. ...
Other articles:
Similar articles:
В этот день... 21 November