Ken writes:
> While I'll try not to get in to a technical argument about it, off the top
> I would at least gently question if good design will always manage to
> "get around" 16-bit stack limitations.... Seems like there would be
> times where a 16-bit stack would be pretty severely limiting; no
> matter how well you design and write your code....
Actually, I think that you could make the opposite argument. A 16-bit stack
forces you to write good code. You're certainly never bothered with
infinitely regressed procedure calls, at least not for very long :-). All
kidding aside, it does force you to think about what should be on the stack
and what should be better handled by extra data segments or files.
Ken also writes:
> Just one significant limitation of BASIC/V: From the
> manual's on Wirt's web site:
>
> "A variable may also contain a string of characters. This type of
> variable is identified by a variable name consisting of a letter and $,
> or a letter, digit, and $:"...
Clear, concise documentation doesn't have to be in the code itself. In fact,
it rarely is. No better example of that fact exists than in old assembly
language code. I've included below just a snippet of the code we wrote for
the System 2000 Word Processing Terminal we put together 25 years ago.
Even now, without any clear idea of what the rest of the code is doing,
almost anyone should be able to read this code and understand it:
=======================================
1834 ************************
1835 *
1836 * ROUTINE TO DETERMINE AMOUNT
1837 * TO CHANGE SPACE CHARACTER
1838 * SPACING VALUE FOR RJ PRINT
1839 *
1840 * EXIT: C-> NORMAL PRINT
1841 *
1842 ************************
1843 CALSPC PUSH H SAVE THE REGISTERS
1844 PUSH D
1845 PUSH B
1846 XRA A INITIALIZE THE SPACING VARIABLES
1847 MOV B,A INITIALIZE THE SPACE COUNTER
1848 STA SPCDIF
1849 LXI H,PNTBUF GET ABS-CHAR COUNT
1850 MOV C,M ESTABLISH A COUNTER
1851 INX H POINT TO FIRST CHAR
1852 INX H
1853 CALSP1 MOV A,M GET A CHARACTER
1854 CPI SPACE IS IT A SPACE?
1855 JNZ CALSP2 NO--END OF SACRED SPACES
1856 INX H YES--DON'T COUNT THESE
1857 DCR C IS THAT ALL IN BUFFER?
1858 JNZ CALSP1 NO--KEEP CHECKING
1859 JMP CALSP4 YES--SO EXIT
1860 CALSP2 MOV A,M GET A CHARACTER
1861 CPI SPACE IS IT A SPACE?
1862 JNZ CALSP3 NO--SO DON'T COUNT IT
1863 INR B YES--SO COUNT IT
1864 CALSP3 INX H NO--POINT TO NEXT CHARACTER
1865 DCR C FINISHED WITH BUFFER?
1866 JNZ CALSP2 NO--KEEP CHECKING
1867 CALSP4 MOV A,B SAVE THE COUNT IN REG. 'A'
1868 STA NUMSPC NUM OF MODIFIABLE SPACES
1869 ORA A ARE THERE ANY SPACES?
1870 JZ CALSP8 NO--SO DO A NORMAL PRINT
1871 MVI H,0 GET THE NUMBER OF SPACES
1872 MOV L,A AVAILABLE SET UP TO DO
1873 CALL HLCOMP A DIVISION
1874 XCHG AND SAVE IN 'DE' PAIR
1875 LHLD JSTDIF GET SPACES TO BE JUSTIFIED
1876 MOV A,H CHANGE TO HALF SPACES
1877 ORA A CLEAR THE CARRY FLAG
1878 RAR DIVIDE BY TWO
1879 MOV H,A AND SAVE NEW VALUE
1880 MOV A,L GET THE LOW BYTE
1881 RAR DIVIDE BY TWO
1882 MOV L,A AND SAVE
1883 JNC CLSP41 AMOUNT WAS EVEN--DIVISION CORRECT
1884 XRA A AMOUNT WAS ODD--ACCOUNT FOR 1/120TH
1885 INR A
1886 STA SPCDIF IN THE EXTRA SPACES
1887 CLSP41 MVI C,0 ESTABLISH COUNTER FOR DIVISION
1888 CALSP5 DAD D DO A SUBTRACTION
1889 JNC CALSP6 FINISHED DIVIDING?
1890 INR C NO--KEEP SUBTRACTING
1891 MOV A,C CHECK THE COUNT
1892 CPI 20 IS IT TOO LARGE ALREADY?
1893 JNC CALSP8 YES--SO DON'T RJ PRINT THE LINE
1894 JMP CALSP5
1895 CALSP6 LDA NUMSPC GET THE SPACE COUNT
1896 ADD L GET THE REMAINDER
1897 MOV L,A SET THE AMOUNT ASIDE
1898 LDA SPCDIF GET THE EXTRA SPACES
1899 ADD L AND GET THE TOTAL NUMBER OF SPACES
1900 STA SPCDIF AND SAVE AS EXTRA 1/120THS
1901 LDA PFLGS1 COMPRESSING OR EXPANDING?
1902 ANI COMFLG COMPRESSING OR EXPANDING LINE
1903 LDA CHRSPC GET THE NORMAL SPACING VALUE
1904 JNZ CALSP7 COMPRESSING--DECREASE THE SPACING VALUE
1905 ADD C EXPANDING--A= CHRSPC+SPCVAL
1906 CPI 15 IS IT AN ACCEPTABLE SIZE?
1907 JNC CALSP8 NO--TOO LARGE, DEFAULT TO NORMAL PRINT
1908 JMP CALSP9 NO--SO DO A RJ PRINT
1909 CALSP7 SUB C COMPRESSING--A= CHRSPC-SPCVAL
1910 CPI 1 IS IT AN ACCEPTABLE VALUE?
1911 JNC CALSP9 SPACING IS OK--RJ PRINT THE LINE
1912 CALSP8 LDA PFLGS0 GET THE PRINTER STATES
1913 ANI 377Q-RJFLAG SET FOR NORMAL PRINT
1914 STA PFLGS0 AND SAVE THE NEW STATES
1915 CALL RSTMGN RESTORE THE MARGIN SETTING
1916 STC AND SET THE CARRY FOR DEFAULT
1917 JMP CLSP10 EXIT TO CALLING ROUTINE'
1918 CALSP9 ORA A CLEAR THE CARRY FLAG
1919 STA SPCVAL AND SAVE IT
1920 CLSP10 POP B RESTORE THE REGISTERS
1921 POP D
1922 POP H
1923 RET AND RETURN
1924 ************************
========================================
I remain completely impressed with this kind of code. This is a lot of
behavior in 100 bytes, and behavior is all we're trying to generate, not
massive piles of complex code.
Wirt Atmar
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|