Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!cs.utexas.edu!uunet!mcvax!hp4nl!eutrc3!rcbaem From: rcbaem@eutrc3.urc.tue.nl (Ernst Mulder) Newsgroups: comp.sys.mac.programmer Subject: Re: Can anyone anser these Questions? Message-ID: <864@eutrc3.urc.tue.nl> Date: 22 Aug 89 19:10:38 GMT Reply-To: rcbaem@eutrc3.uucp Organization: Eindhoven University of Technology, The Netherlands Lines: 72 Well, anyway. Thank you for trying to answer my previous questions. At this time all problems are solved. I even started a new project. I finished this program, and well, getting the hang of it, I thought why not start a new one? But I'm faced with a new problem: I have a very nice calculator, called a PC-2 (Radio Shack) known as a PC-1500 (Sharp) as well (it's originally a Sharp machine). Since the only calculator resembling an existing one, on the Mac, I know of is a DA version of HP's HP12, I desided to write my own one. The program is finished (took one evening :) except for one (essential) thing: I have to write an interpreter for the PC-2's machine code. The PC-2 is both BASIC and Machine-code programmable, so I'll HAVE to write an interpreter implementing the PC-2's microprocessor. The problems: 1: The interpreter is probably going to be very slow. 2: The PC-2 can access 64K bytes of memory. Therefore I allocated a 64K locked object, with a pointer to it. Let's call this pointer memStart. Then I got a terrible fight with Pascal... The PC-2's processor has 16bit registers. So I have to access bytes in the 64K memory block. An instruction like LDA (P) could be implemented as follows (in pascal): (A is a Byte, P is an integer resembling a register of the PC-2's processor) A := Ptr(LongInt(memStart) + P)^; PROBLEM!! Assume P has the (integer) value -1. (=$FFFF) and say memStart = 0; (LongInt(memStart) + P) then gives -1 instead of $FFFF.. Whatever typecasting I tried, I end up with $FFFF beging extended to the LongInt $FFFFFFFF... I finally found a solution as follows: type register = record case boolean of true: (h:integer; l:integer); false:(hl:LongInt) end; var P:register; When at initialisation time P.hl is set to 0 the following DOES work as expected: P.hl := 0; p.l := 0; p.l := p.l - 1; (p.l is now $FFFF (or -1)) A := Ptr(LongInt(memStart) + p.hl)^; (When memStart had the value 0, then this addition would indeed give the wanted address $FFFF). Some suggestions of mine are: 1: a) Don't try to write this program, it's bound to be slow. b) Write it in assembly instead of in Pascal. (But LSP's code is rather efficient, I found extremely nice trics wandering through disassembled LSP compiled programs..) c) Claim the program runs on 68030 Macs only :) 2: Pascal is a terribly rotten language thanks to it's excellent type restrictions. Write it in Assembly or in C.. Okay, but I don't have an Assembler, nor a C compiler.. Any ideas? Ernst. >