Path: csiph.com!news.mixmin.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Peter 'Shaggy' Haywood Newsgroups: comp.sys.apple2.programmer Subject: Re: Typo in ProDOS refTechMan Date: Thu, 31 Aug 2023 13:30:34 +1000 Organization: A noiseless patient Spider Lines: 42 Message-ID: References: <20230822221945.4eb8a091@laptop-sigfox> <20230823082311.3dc76fb1@laptop-sigfox> <20230823152214.5e86230e@laptop-sigfox> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8Bit Injection-Info: dont-email.me; posting-host="bf00c0b86fabb293a882336e26d66c6a"; logging-data="3499296"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/RVXEXRuNdkg4VNnvP85PsVDa5e4EdRS0=" User-Agent: KNode/0.10.9 Cancel-Lock: sha1:r2wyTBY/i3OGtWM7pPV/rZ7tP+0= Xref: csiph.com comp.sys.apple2.programmer:6088 Groovy hepcat Michael J. Mahon was jivin' in comp.sys.apple2.programmer on Mon, 28 Aug 2023 04:45 pm. It's a cool scene! Dig it. > Jeff Blakeney wrote: > >> In other words, the SYSCALL is the address of the JSR but it isn't >> the address that gets pushed onto the stack when the JSR is executed. > > Well, the details are: JSR pushes the address of the JSR opcode plus > *two* on the stack, and the RTS pops the address and adds *one* to get > the return PC value. Not quite. What happens is that the first byte of the instruction (the op code) is read and, depending on the particular code, either 0, 1 or 2 operand bytes are read in. In the case of a JSR, 3 bytes are read in total, the op code and a 2 byte address operand. The program counter is updated as each byte is read in. Next, the operation is carried out. For JSR that means the current value of the PC, which now contains the address of the next instruction (or whatever occupies the memory following the JSR, including operand) is pushed on the stack before execution branches to the new location. An RTS instruction just pulls the address off the stack and bungs it into the PC so that execution can take up from there. > This doesn’t change the need to add 3 to the stacked value to skip 3 > bytes of in-line data, but it does mean that the stacked address > points at the high byte of the JSR, not the first byte of the in-lined > data. No, it is the address of the next instruction. You're right about not changing the need to add 3 to the address. It's just that the address is that of the following op code..., which before 3 is added, in this case, isn't an op code but data. -- ----- Dig the NEW and IMPROVED news sig!! ----- -------------- Shaggy was here! --------------- Ain't I'm a dawg!!