Free Republic
Browse · Search
News/Activism
Topics · Post Article

To: Tennessee_Bob
Well, it's not like anyone else will...

I just downloaded Turbo Pascal 3.0 for CP/M awhile ago to see if it would be usable for a Z80 project I'm working on. If ByteVar is a byte variable, depending upon whether the value in HL is needed, optimal code for "ByteVar:=ByteVar+1;" is either:


LD HL,ByteVar
INC (HL)
or

LD A,(ByteVar)
INC A
LD (ByteVar),A
Unfortunately, Turbo Pascal isn't quite so efficient:

LD HL,(ByteVar)
LD H,0
PUSH HL
LD HL,1
POP DE
ADD HL,DE
LD A,L
LD (ByteVar),A
I think I'll try looking at Turbo Pascal 3.0 for PC's code and see how that is. Many applications were developed on that platform, including the original Tetris.
37 posted on 03/07/2002 10:03:12 PM PST by supercat
[ Post Reply | Private Reply | To 29 | View Replies ]


To: supercat
You also need to look at the cycle count for the different ways of doing it (the first two ways…) to see which is really the most efficient time wise (if you care).
40 posted on 03/08/2002 2:16:12 AM PST by DB
[ Post Reply | Private Reply | To 37 | View Replies ]

Free Republic
Browse · Search
News/Activism
Topics · Post Article


FreeRepublic, LLC, PO BOX 9771, FRESNO, CA 93794
FreeRepublic.com is powered by software copyright 2000-2008 John Robinson