UK Vintage Radio Repair and Restoration Powered By Google Custom Search Vintage Radio and TV Service Data

Go Back   UK Vintage Radio Repair and Restoration Discussion Forum > Specific Vintage Equipment > Vintage Computers

Notices

Vintage Computers Any vintage computer systems, calculators, video games etc., but with an emphasis on 1980s and earlier equipment.

Reply
 
Thread Tools
Old 31st Oct 2023, 10:25 am   #41
Phil__G
Heptode
 
Join Date: Mar 2011
Location: North Yorkshire, UK.
Posts: 911
Default Re: SC/MP programming chat.

Thats right, -128 ($80) in a memory-reference instruction means use E as the offset - not in the case of a jump,
Quote:
Originally Posted by Prog & asm manual Section 3.3.3
If the displacement in an indexed or an auto-indexed memory reference instruction equals
-128d (X'80), then the contents of E are substituted for the displacement for the given instruction.
Phil__G is online now   Reply With Quote
Old 31st Oct 2023, 3:59 pm   #42
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 11,084
Default Re: SC/MP programming chat.

Have you got a .asm file which uses the 'wraparound' feature which didn't originally work but was fixed in San's most recent official version, so we can check that I haven't broken that?
SiriusHardware is offline   Reply With Quote
Old 31st Oct 2023, 4:25 pm   #43
Phil__G
Heptode
 
Join Date: Mar 2011
Location: North Yorkshire, UK.
Posts: 911
Default Re: SC/MP programming chat.

I compared the KB+ object code pre & post mod, identical
It uses stack & vars 'below zero' just like like scios does, in fact the registers are at the very same addresses as scios
Phil__G is online now   Reply With Quote
Old 31st Oct 2023, 4:49 pm   #44
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 11,084
Default Re: SC/MP programming chat.

Fair enough.

I think I can see a further single line edit to disable the -128 offset warning when the instruction mnemonic in the line currently being processed is a 'J..'. (Jump instruction of any sort).

I may give it a try later tonight, time allowing.
SiriusHardware is offline   Reply With Quote
Old 31st Oct 2023, 5:15 pm   #45
Phil__G
Heptode
 
Join Date: Mar 2011
Location: North Yorkshire, UK.
Posts: 911
Default Re: SC/MP programming chat.

You mean to get rid of the unwanted line 15 'E' register warning in the post#38 .prn above?
That would be nice, though not essential...
Phil__G is online now   Reply With Quote
Old 31st Oct 2023, 5:58 pm   #46
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 11,084
Default Re: SC/MP programming chat.

Yes, I think I can make that go away when the instruction being parsed is any sort of jump instruction.

If I do that, I take it the warning is still needed in the case of all other relative access instructions because an offset of -128 which happens to come about because the LD / ST / etc instruction is exactly that far away from the target address will be interpreted as 'use E as the offset', and that may not be what the coder intended?
SiriusHardware is offline   Reply With Quote
Old 31st Oct 2023, 6:37 pm   #47
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 11,084
Default Re: SC/MP programming chat.

Here's a preliminary shot at it, with another edit to crscmp.py

All you have to do is add a bit to the third line from bottom of the same code block we modified before. This adds the condition that the instruction currently being parsed must NOT be a jump instruction if the -128 offset warning is to be generated.

Code:
    NoMore()
    if dec.Asm.Pass == 2:
        # Only test range in pass 2
        if offset < -128 or offset > 127:
            # The normal offset is out of range
            if offset2 < -128 or offset2 > 127:
                # We also didn't do a full page wrap
                errors.DoError('range', False)
            else:
                offset = offset2
        if offset == -128 and absolute and dec.Asm.Mnemonic[0].upper() != "J":
            # Offset calculated to -128, are you sure!
            errors.DoWarning(dec.Cross.Name + 'offset', True)
This is the output the modified crscmp.py produces from your jump2.asm test code. No sign of the warning this time.

Code:
Source file: jump2.asm

*** Error: Out of range
      7 LOW1:   JMP     HIGH1 ; too far, should error
0802-90 7E             8 (  11)         JMP     HIGH1 ; this ones ok, should be no error
0804-90 7C             9 (  11)         JMP     HIGH1 ; this ones ok, should be no error
0806-90 7A            10 (  11)         JMP     HIGH1 ; this ones ok, should be no error
087A-90 84            13 (  11)         JMP     LOW1  ; this ones ok, should be no error
087C-90 82            14 (  11)         JMP     LOW1  ; this ones ok, should be no error
087E-90 80            15 (  11)         JMP     LOW1  ; this ones ok, should be no error
*** Error: Out of range
     16         JMP     LOW1  ; too far, should error
*** Error: Out of range
     17 HIGH1:  JMP     LOW1  ; too far, should error
SiriusHardware is offline   Reply With Quote
Old 31st Oct 2023, 9:06 pm   #48
Phil__G
Heptode
 
Join Date: Mar 2011
Location: North Yorkshire, UK.
Posts: 911
Default Re: SC/MP programming chat.

Okay, I get the same good results on the test files, so I tried a substantial source file...
Bear in mind that KB+ is quite a large source with lots of jumping around including page-wrapping to the stack & variables below $0FFF...
Assembling with the "and not a jump" line in the cross file, the listing files and hex files are identical to those produced using Sans emailed cross file.
My present thoughts are that the fix is good and it hasnt broken anything!
Good work G

For anyone not familiar, this isnt the crscmp.py cross-file on Sans SB Projects download page, thats the old one with the wrapping error.
San fixed this and emailed a new cross file to those who queried it, but hasnt updated his Website or distribution.
Sans github has the emailed file, this is the 'official' latest which has the "jump-out-of-range" error. Sirius's mod is to this file.

Last edited by Phil__G; 31st Oct 2023 at 9:19 pm.
Phil__G is online now   Reply With Quote
Old 31st Oct 2023, 9:47 pm   #49
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 11,084
Default Re: SC/MP programming chat.

Thanks for the update. Still no response from San himself, sad to say.
SiriusHardware is offline   Reply With Quote
Old 7th Nov 2023, 12:13 am   #50
Phil__G
Heptode
 
Join Date: Mar 2011
Location: North Yorkshire, UK.
Posts: 911
Default Re: SC/MP programming chat.

Ian (Coolsnaz2) asked for Sirius's modified cross file to be posted, but rather than post it here where it can't be updated, I put it on the http://philg.uk sc/mp page here
It goes in the sbapack folder.
Phil__G is online now   Reply With Quote
Old 7th Nov 2023, 1:14 am   #51
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 11,084
Default Re: SC/MP programming chat.

There is enough info in the preceding posts to allow anyone to make the two single line edits needed to try out these fixes provided they already have San's unreleased latest version of the CRSCMP.PY 'cross' file which is available on Phil's site.

History has shown us that it is a bad idea to attach trial / experimental versions of software or scripts to forum posts which they can't easily be taken down from if someone later finds that something has gone wrong.

If nobody finds any holes in it after a couple of months of active use then it may be OK to put it in a forum post. I just wish we could get hold of San Bergmans to ask him to either implement his own official fixes for the problems mentioned, or have a look at what we have done and green light it.
SiriusHardware is offline   Reply With Quote
Old 26th Nov 2023, 6:36 pm   #52
Phil__G
Heptode
 
Join Date: Mar 2011
Location: North Yorkshire, UK.
Posts: 911
Default Re: SC/MP programming chat.

I've typed-up and been working through the Erik Skovgaard 'Subroutine supervisor' which we discovered in Robert D. Haviland's book "How To Design, Build & Program Your Own Advanced Working Computer System".
Eriks SC/MP code is really clever & compact, and for me (being a bit dim) it took some time to understand all its features. It has some really useful and code-saving tricks but doesnt implement a proper stack as I'd hoped, so theres no nesting - but a great idea to build on. I had the idea to look Erik up, but apparently there are many Erik Skovgaards, one that sounded likely is a radio ham in California - I dont know. I'm going to play around with Eriks idea & see how it goes

In a nutshell, you set P3 to SSUP-1 and leave it there. To use it thereafter you code four bytes: XPPC P3, function_number, address_highbyte, address_lowbyte.
For example, any calls or jumps to anywhere, you code as XPPC P3, 3, addr_hi, addr_low. This means only 4 bytes per 'call' and a great benefit is that the Acc is saved
A 'call' (function 3) remembers the point in your code where the call was made, & 'RET' uses this to effect a return - with the Acc intact
The function RET (function_number 0) ignores addr_hi, addr_low but unless I've misunderstood they need to be there as dummies (the LD @3(P3) steps over func, addr_hi, & addr_low)
The load & stores allow you to use (addr) like you'd use (HL) in a Z80. It even allows indirect addressing where addr_hi, addr_low contain the address of a vector.
Code:
	.cr scmp
	.LF SSUP.PRN
;	.tf SSUP.hex,INT,32
;
P1	=	1
P2	=	2
P3	=	3
;
; Erik Skovgaard subroutine supervisor
; ASSUMES P2=KITBUG STACK ($0FF6)
; CALL XPPC P3 (P3=SSUP-1)
; THE FOLLOWING 3 BYTES CONTAIN
; 1. FUNCTION CODE AT P3+1
; 2. ADDRESS HIGH  AT P3+2
; 3. ADDRESS LOW   AT P3+3
; FUNCTION CODE IS AS FOLLOWS:
;  00=RETURN (ADDR BYTES IGNORED)
;  01=READ (RESULT IN ACC)
;  02=WRITE FROM ACC
;  03=GOSUB/GOTO (FAR JUMP)
; THE FOLLOWING ARE INDIRECT ADDR MODES
; IE P3 POINTS TO THE ADDR TO BE USED
; P3+0 IS HIGH, P3+1 IS LOW ADDR BYTE
;  04=READ INDIRECT
;  05=WRITE INDIRECT
;  06=GOSUB INDIRECT
; THE DEPTH OF NEXTING MAY BE CONTINUED
; BUT ONLY THE FIRST RETURN ADDR IS SAVED
;
; P2-11, -13 AND -14 MUST NOT BE 
; DESTROYED BY THE SUBROUTINE
; P2-12 AND -15 ARE ALSO USED.
; TIMING: 341 FOR GOSUB/GOTO, 153 FOR RET.
; +190 EXTRA MICROCYCLES FOR INDIRECT
;
	.OR $900

RET:	LD	-13(P2)		; (-13)(-14) IS CALLING ADDR HI LO
	XPAH	P3		; RESTORE P3 HI
	LD	-14(P2)		; AND P3 LOW
	XPAL	P3
	LD	@3(P3)		; ADJUST FOR RETURN,
	LD	-11(P2)		; ...STEP OVER PARAMS
	XPPC	P3
	; ENTRY POINT
SSUP:	ST	-11(P2)		; STORE ACC
	LD	1(P3)		; GET FNS WORD
	JZ	RET
	ST	-12(P2)		; STORE FNS WORD
	LD	2(P3)		; SET UP NEW P3
	ST	-13(P2)		; 
	LD	3(P3)		; H=P2-13
	XPAL	P3		; L=P2-14
	ST	-14(P2)		; SAVE OLD P3, IE CALLING ADDR
	LD	-13(P2)
	XPAH	P3
	ST	-13(P2)
STST:	DLD	-12(P2)
	JZ	READ
	DLD	-12(P2)
	JZ	WRITE
	DLD	-12(P2)
	JZ	GOTO
	LD	0(P3)		; GET SECONDARY ADDR
	ST	-15(P2)		; STORE TEMP
	LD	1(P3)
	XPAL	P3
	LD	-15(P2)
	XPAH	P3
	JMP	STST		; TEST AGAIN
READ:	LD	0(P3)
	ST	-11(P2)
	JMP	RET
WRITE:	LD	-11(P2)
	ST	0(P3)
	JMP	RET
GOTO:	LD	@-1(P3)		; ADJUST P3
	LD	-11(P2)		; RESTORE ACC
	XPPC	P3
	JMP	SSUP

	.END

Last edited by Phil__G; 26th Nov 2023 at 6:58 pm.
Phil__G is online now   Reply With Quote
Old 27th Nov 2023, 12:04 am   #53
Mark1960
Octode
 
Join Date: Mar 2020
Location: Kitchener, Ontario, Canada
Posts: 1,195
Default Re: SC/MP programming chat.

There is probably no reason to use 01, 02 etc for the function codes, why not just use XPAL p0 instead of a chain of DLD and JZ? If you use auto index when you load each parameter byte you don’t need to adjust P3 to skip parameters, so you could have varying number of parameters for each function.
Mark1960 is online now   Reply With Quote
Old 27th Nov 2023, 7:38 pm   #54
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 11,084
Default Re: SC/MP programming chat.

Phil, in that version of the CRSCMP.PY file that you have linked to under 'here' in #50, the comment line before the first modified line still refers to the IF acting only in the case of a 'not forward' jump.
For the sake of completeness maybe also edit the comment so it is more accurate.

I mean this bit here:

Code:
    NoMore()
    # if dec.Asm.Pass == 2 and not forward:
    if dec.Asm.Pass == 2:
The comment (which starts with a '#' symbol) should probably now read:

Code:
    NoMore()
    # if dec.Asm.Pass = 2
    if dec.Asm.Pass == 2:
(Which is virtually what the code says anyway).

Last edited by SiriusHardware; 27th Nov 2023 at 7:44 pm.
SiriusHardware is offline   Reply With Quote
Old 27th Nov 2023, 9:41 pm   #55
Phil__G
Heptode
 
Join Date: Mar 2011
Location: North Yorkshire, UK.
Posts: 911
Default Re: SC/MP programming chat.

Done! thanks G

BTW functionally, the amended cross file has been perfectly well behaved
Phil__G is online now   Reply With Quote
Reply

Thread Tools



All times are GMT +1. The time now is 1:45 am.


All information and advice on this forum is subject to the WARNING AND DISCLAIMER located at https://www.vintage-radio.net/rules.html.
Failure to heed this warning may result in death or serious injury to yourself and/or others.


Powered by vBulletin®
Copyright ©2000 - 2023, vBulletin Solutions, Inc.
Copyright ©2002 - 2023, Paul Stenning.