Adventurer #04
31 июля 1996 |
|
Exchange of experience - "Up ..." : Interrupt; disc feeders.
C accuracy to ... (C), Konstantin Breeders (C) Music D. J. MUSIC Accuracy - courtesy Kings Hello everyone who reads this article. AND This time I will carry some sort of "blizzard" but a little more seriously, a theme. That - interrupts. Or rather, how to measure while the program using interrupts. I personally know three ways of measuring the time of the program (the expression "time" means the number of processor cycles). "Pulling rubber "will not, and will start immediately" to share experiences. "Thus, the crime with. The most accurate and easiest (?) Method is - this method (note: the accuracy measurement results will depend on you and your well-being). Excellent performance, this method allows for small (sub) programs. The essence of this method is as follows: download or MONS (1-4), or MON2, or STS, whom they like (or have someone that is), its place (well, if so) prog Rummy to get noticed on any address memory value set for this address that includes a disassembler program and ... This is where the fun begins (Little tip: if you do not remember how many cycles is one or another team, then take the book with these data, but if this book does not have the memory Your let you down, this method is not you). So, about the most interesting (?). Once was included disassembler, you starts to add up bars all the teams taking into account cycles. The resulting amount - this is is the time it takes your program. Like, the first method to parse (who it is not clear, contact the editors). Come on. The second method is too simple, but in addition, and not very accurate (range + / - 5000 cycles, if not more). In principle, this method is designed for you to determine your prog moved thousands of ticks that way for 70 or not. And if you use this method in conjunction with the method house described in the ZX-FORMAT N3 in the article on Assembler in the head, I do not remember what can be achieve good results. The essence is this: before the start of the procedure of playfulness which you want to know, installing the curb in some color, for example, green or white (or someone that someone like). After performing your program, set a border of black color. But do not forget that this is your program in place Color change border should be hung on the termination or, in extreme cases, this mess should begin with the command HALT! It looks like this: EI BEGIN HALT LD A, 4 OUT (# FE), A CALL PROG XOR A OUT (# FE), A IN A, (# FE) CPL AND # 1F JR Z, BEGIN ........ Band of green on the curb and will shows how much time is spent on your program. If all the green border, then your program is moved over 70,000 cycles. If only polbordyura green then cleaned up in the programm 30000-40000 bars, etc. etc. Ok, now seriously. The article, in fact, and was intended primarily only because of this method, because with him on power can be measured execution time program up to four cycles CPU! Someone, perhaps, the question arises: "Why, up to four, but not before one cycle? I think, first is to answer this question in order to avoid any misunderstanding something. Everything basically comes from the interrupt, as method designed for their use. When the computer generated signal INT, the processor begins to think, that it was time to distract from the performance of the main program, and should do something other, no less useful. This most signal INT (interrupt masked) can enroll at any time, even during performance processor, any team. But as a "person" honest, processor first started to perform end, and then too distracted. And since every team has a certain number of cycles (at least four), then why and not get accurate measurements up to one Nogo tact. Itself begs another question: "Then why four rather than seven, ten or twenty strokes? " In fact, the accuracy of up to four cycles is guaranteed only to programs that ubirayutya in the period between interrupts. Others will simply be broken, but the number of cycles will be slightly larger than the number of cycles between interrupts (only a few cycles). And why four tact you can learn a little farther. DI LD A, # FE LD I, A IM 2 LD HL, INT LD (# FEFF), HL EI HALT .... END DEFS 18000 INT; number of cycles PUSH HL; 11 LD HL, NEXT; 10 DEC (HL); 11 POP HL; 10 EI; 4 RET NZ; 5 LD DE, END POP HL AND A SBC HL, DE LD (DATA), HL IM 1 RET DATA DEFW 0 NEXT DEFB 2 Once this procedure is fulfilled, DATA appears in the cell number of teams NOP, which had run after your program. Multiplying this number four, get the number free of ticks remaining on your program. Now, subtracting from the number of cycles between two interrupts just calculate the number of plus 51 more stroke, get the number of clock cycles occupied by your program. But if the cell is the number of DATA large, it means that your invention does not want to make their case for 70,000 cycles. Note: All steps after the program listing, you must do manually on a calculator, because, perhaps, can get the number is more than possible in native code, ie greater than 65535! Ask - reply And now, little answers to questions arising from the people on this or that free programming. Question: "Why when disables the interrupts of the first kind, or jump on the second interruption, the cell LAST_KEY information does not change?" Answer: "It's very simple! For the first interruption of the procedure hanged poll keypad tours, why then does not change the information in LAST_KEY when disconnecting the first interruption. So, if you like to use this system variable, then let alone the first interruption. But if you want to hang something on their interruption of the second kind, and that the cell you so cute, that there is no desire give it up, then at the end of its procedures for handling interrupts not place command RET, and JP # 0038. And yet, if you using the first interrupt, then no would not touch the register IY! It must always contain the number 23610, if you look, and LAST_KEY everything will be OK. But still, I would advise not to be subverted, and enjoy a superior method. Then you would not care about what which is in IY and any included termination. It looks like this: CALL # 028E CALL # 031E After performing two of these routines, in register A is returned core code keystroke, ie, code is uppercase letters of the alphabet or code numbers. But If the battery is the code # 18 then pressed only key SYMBOL SHIFT. If there is code # 27, then pressed CAPS SHIFT or if A code # 0E, then pressed and CAPS SHIFT, and SYMBOL SHIFT. It is worth paying attention to the case B. If the It is # 18, then pressed some button with SYMBOL SHIFT. And if there (in case B) is the number # 28, then was pressed with CAPS SHIFT. Well From this we can draw the appropriate conclusions. " Question: "In one of the last issues of the journal were published ADVENTURER point includes some procedures ROM. Here, for example, sub-CLEAR is not working from the regime of 128K. The following procedure will do the same, but works fine in all modes: LD BC, # 1303 PUSH BC LD BC, STACK CALL # 1EB7 I would like to receive an explanation for this about, ie why certain procedures ROM refuse to work in a 128K. " Answer: "These bugs are due to the fact that the flash ROM, 48th in BASIC SPECTRUM 128 was Podpravlena because this part of the extensive use of BASIC ROM 128. That's why when you call any procedure from the ROM 48 in BASIC mode 128K, begin to execute additional procedure, which was not originally in 48-m BASIC'e. But in order to avoid such glitches, you need to reset only the value in cell 23625. Now about the above procedure. The fact that the recorded a stack of BC - is the address of the main loop BASIC command processing, and introducing on the stack is not necessarily because at this address anyway it will be then made the transition integral terpretatorom BASIC. But the challenge procedures at # 1EB7 virtually no different from what was written in the second issue of our magazine. The difference is this: if Register BC is the number "zero" and call the procedure at # 1EAF, then number of system variable RAMTOP be stored in the BC and cleaned variables BASIC'a. And if a zero in the BC program to make a call from the address # 1EB7, then it will be made the transition to error "RAMTOP no good" in BASIC! Now, I hope everyone understands why in our magazine was given a point The procedure entry CLEAR at # 1EAF. " Question: Please tell us about memory SPECTRUM 128 " Answer: "I thought this issue long ago figured in the pages of many publications, but it seems that very wrong. Too be briefly touch on this issue. The most important thing is that the additional computer memory is switched to port # 7FFD (32,765). In the 128th included eight page RAM (from 0 to 7) at 16K each. Any of the pages of RAM can be installed with Address # C000 (49152), but it is worth remembering, that the second and fifth pages are fixed addresses # 8000 (32768) and # 4000 (16384) respectively. That is why they can not be used as extra memory. So There are also two pages of ROM containing BASIC BASIC 48 and 128. Any of these pages can only be installed with address # 0000. In SPECTRUM 128 is still one screen. It is located on the seventh page since its inception. And now, the layout bit port # 7FFD (32765): 0-th, 1 st, 2 nd bits of RAM, with their help switches to the additional memory; The third bit is responsible for what the screen at this moment is activated (if bit is cleared, then running bases Noah screen, or including a second equivalent wounds from the seventh page); 4-th bit - is the choice of ROM (bit enabled selected BASIC 48, differently BASIC 128); 5-th bit - when he turned mean you are in SPECTRUM 48, and Paul We used more memory, no can; 6 th and 7 th bits are not used. " At this point I have finished parsing issues although these have accumulated a lot because chtoto I have no strength to continue this scribbling, I'm not a literary figure. And those who have not received an answer, Do not worry, I'll answer your questions either orally or in the next issues of our magazine. Disc Loaders (C) Nicolas Viper From the Editor: This article was prepared as Read more about disk loaders for the magazine "El Dorado". But since this publication ceased its activities, Condor Soft kindly provided the materials for ADVENTURER'a. And I, Nicolas Viper, again with you. Excuse me, what use the magazine for personal goals, but if I ever hear that call me - Nicholas Vampire - offended and go to "Dendy". Well, if you want to know a "Viper", among other things translated as "Adder" - Adder (zool.). More times wildly sorry, but we digress. I hope you have not forgotten my tedious monologue in the second issue of the journal "El Dorado"? You do remember - I promised to tell you how to make music while download (and not just music), like how it is done in the "INSULT", "BATTLE COMMAND", etc. Of course, my presentation suffers from some awkwardness, But if not me then who? Not brilliant if our Nicodim? I must say that the last time I in fact, just told the book Rodionov and Larchenko "ZX-Spectrum 'TRDOS for users and programmers." On my own, I added just a description of some procedures ROM DOS. I did this with one purpose - to prepare you, dear readers, to this article. In general, a program dedicated to TO, similar to the one we saw last time (taken from the "ZX-Review" N4 for 1995). But here is the problem number time: It is necessary to interrupt were all the time allowed, and the procedure of Adre su # 2F1B, accessed by our "Loader" prevents them (and rightly so). Therefore, we replace in the program: ... LD IX, # 2F1B CALL DOS ... at: ... CALL LOA_COM ... Ie instead of ROM DOS calls its procedure, which adds at the end: LOA_COM LD A, E; transform nom. INC A; sector and POSs LD C, # 5F; barking at the port of LD IX, # 2A53; # 5F (reg.sekto CALL DOS; pa) TRY_1; PUSH HL; save on PUSH DE; error ; LD A, # 80, # 80, Thurs Sector LD C, # 1F; write in reg.ko LD IX, # 2A53; cunts CALL DOS; LD C, # 7F; # 7F-reg. Data LD IX, # 3FE5; reading CALL DOS; of {Check for correct reading (CFR)} POP DE \ POP HL} (*) RET / It is easy to see that this procedure - Reworking procedures ROM DOS at # 2F1B. Piece is marked as (*), rather just go down the procedure for the CFR. This raises the most naiofigenneyshaya (Wrapped in!) Problem - control of accurate reading. " Rely in this case on DOS I think not, because there simply does not provide, such as an option when procedure at # 3FE5 (see above), MB interrupted at the beginning, middle or end their work. In short, I want to say what to do That will have to manually, ie, or write to the sector 254-255 bytes, and 1.2 removes the checksums (abbreviated "COP"), or ship them ("COP") in the initial at boot time when you are still using # 3D13, and then the procedure to calculate CFR "COP" (sounds hilarious, is not it?) and compare with the read or table. How to calculate the "COP"? This is easy. The usual method - proksorit all the bytes in each other - the resulting number is the "COP". In general, I absolutely precise recipes Will not give you. If you want, then the next issue I will give full listing of the working procedures, packed and tested by me. In the end, an example of interrupt handler: ORG # FEFE JP IM2_COM ... CALL MUS_INIT; bc DI; this setting LD A, # FD; second interrupt LD I, A; (suddenly you do not LD HL, # FD00; know how it is LD DE, # FD01; do). LD BC, 256 LD (HL), # FE LDIR IM 2 EI ... Here is your (our) loader. ... At the end add: ... IM2_COM LD (STACK), SP PUSH AF ... PUSH ... CALL MUS_PLY; music plays ;LD HL, (STACK); see where INC HL; we return LD A, (HL); schaemsya? CP # 40; JR NC, RETRAM; in RAM LD A, # C3; in ROM LABEL1 LD (CHANGE), A; POP ... ; Code # C3 - JP ... POP AF CHANGE NOP; then put JP DEFW # 3D2F; or RET RETRAM LD A, # C9; code RET JR LABEL1 STACK DEFW 0 From the Editors: The following is the text boot from the magazine "El Dorado" N2, which refers to the author of this article. Inputs: HL - address of the boot DE - track and sector, B - number of sectors. I hope you understand what's what and you does not require the following article to write your cool boot. I would also like to say a few words: Those of you who have filled and tested loader probably noticed that he was terribly slow, even when prohibited by interrupts. It says only one thing - to seek and Go for it! Never be afraid to experiment! Within reasonable limits, of course! *
Other articles:
Similar articles:
В этот день... 21 November