Nicron #33
07 мая 1997
  Бейсик  

Programming - when the calculator is contraindicated in BASIC.

<b>Programming</b> - when the calculator is contraindicated in BASIC.
(C) WLODEK BLACK

Hello friends. I called again to load on your holidays ...
Congratulations to all on Victory!
Continues the theme of the session ...


     WHEN 
BASIC CALCULATOR 

         NOT for 

There are situations when the calculation, with sufficient
complex (as compared with elementary actions like "add"
or "subtract"), done using a calculator BASIC
impractical or impossible (for example, when you can not
call the subroutine from ROM).
Here's how to print on the screen in decimal form in
band # 0000 - # FFFF:

Input: HL = number

DENARY LD DE, 10000; determine the number of times for 10000
    CALL DIGIT
    LD DE, 1000; - "- 1000
    CALL DIGIT
    LD DE, 100; - - 100
    CALL DIGIT
    LD DE, 10; - - 10
    CALL DIGIT
    LD A, L; remaining units
    INC A; adds one
    JR DIGIT2
DIGIT XOR A; zero the counter and simultaneously. reset the 
flag C DIGIT1 SBC HL, DE; subtract the loop until the loan

    INC A; building up counter
    JR NC, DIGIT1; cycle until the loan
    ADD HL, DE; restore balance
DIGIT2 ADD A, 47; we add 47 for obtaining me the code of the 
symbol digit 

    JP PRINT; print figure

Algorithm procedure DENARY simple: consistently determining
how many times, 10000, 1000, etc. contained in the original
number, count all the decimal digits sequentially
the number of bits and print them. INC A team does not affect 
the flag transport, so it can be used after SBC HL, DE. On

DIGIT2 tag is a team of ADD A, 47. Why not 48, because the code
symbol digit = value + 48 digits? The fact that the counter on
A register will always make an extra turn, that is, it
Output from subroutine DIGIT will always be one greater
than "necessary." It is this extra unit, and we compensate by 
adding 47, not 48. But when you print discharge unit, when we 
take number of units directly from the register L, without 
using a subroutine DIGIT, extra edinichki does not occur, and 
we do adds performing INC A.

Print PRINT procedure should not alter HL.

But one of the solutions the opposite problem - getting the 
numbers on his record in the form of numbers. As an example, I 
will procedure "CALC" from the program AUTOHISTORIZER-2. In the 
"History" server, each line looks similar to this here:


4628902 




Other articles:

Entry - the contents of rooms.

BBS - list of stations BBS ZXNet.

Programming - when the calculator is contraindicated in BASIC.

Story - Well, user, wait a minute! (Continued).

Poems - I was an assistant sysop.

Search - search for game programs.

Advertising - advertising and announcements.

Feedback - contact the publisher.


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
Interface - moran: "Why do I play."
Coding - pishim virus invisible to TR-DOS.
Advertising - Advertisements and announcements ...

В этот день...   21 November