Dear All,
I have hand coded the assembly, compiled and run the binary. Pressing <CTL> <ALT> <7>, resets the machine, goes to the initial screen, but does not clear the RAM, but does
reset system variables.
I cannot quite make out from the scan, these addresses, so I hope I got them right.
WARM_RESTART_AH EQU $01CA
Warm retstart for 'AH' ROM (QDOS v1.02)
WARM_RESTART_JM EQU $01CA
Warm retstart for 'JM' ROM (QDOS v1.03)
WARM_RESTART_JS EQU $01CC
Warm retstart for 'JS' ROM (QDOS v1.10)
WARM_RESTART_JSU EQU $01CE
Warm retstart for 'JSU' ROM (QDOS v1U10)
WARM_RESTART_MG EQU $01CC
Warm retstart for 'MG' ROM (QDOS v1.13)
Code follows, please compile with GST MAC as the assembly uses long labels, older GST Assemblers can cope only with short labels up to 8 char in length.
Code: Select all
* Motorola MC68008 program to provide 'warm reset'
* facility by re-defining the <CTRL>, <ALT>, '7' effect.
* Also, vector chich normally cause the QL to 'crash' are
* re-defined to cause a warm system restart instead.
*
* Assemble, save to Microdrive, reserve memory with
* something like LET a=RESPR(256), load code into memory
* with something like 'LBYTES mdv1_code,a' and activate
* with 'CALL a'.
*
* Alternatively, run program in Listing 2.
*
* COPYRIGHT (c) August 1985, Alan Turnbull, B.Sc.
BASIC_JOB EQU $00 SuperBASIC job ID
MT_TRAPV EQU $07 TRAP #1 key for TRAP re-direction
WARM_RESTART_AH EQU $01CA Warm retstart for 'AH' ROM (QDOS v1.02)
WARM_RESTART_JM EQU $01CA Warm retstart for 'JM' ROM (QDOS v1.03)
WARM_RESTART_JS EQU $01CC Warm retstart for 'JS' ROM (QDOS v1.10)
WARM_RESTART_JSU EQU $01CE Warm retstart for 'JSU' ROM (QDOS v1U10)
WARM_RESTART_MG EQU $01CC Warm retstart for 'MG' ROM (QDOS v1.13)
NEW_DIV_BY_ZERO EQU $005E
NEW_CHK_INSTR EQU $005E
NEW_TRAPV_INSTR EQU $005E
NEW_TRACE_EXCEPT EQU $005E
NEW_TRAP_05 EQU $005E
NEW_TRAP_06 EQU $005E
NEW_TRAP_07 EQU $005E
NEW_TRAP_08 EQU $005E Address of 'RTE' in all ROMs
NEW_TRAP_09 EQU $005E
NEW_TRAP_0A EQU $005E
NEW_TRAP_0B EQU $005E
NEW_TRAP_0C EQU $005E
NEW_TRAP_0D EQU $005E
NEW_TRAP_0E EQU $005E
NEW_TRAP_0F EQU $005E
VIDEO_RAM EQU $20000 Start of video RAM
SV_RAMT EQU $28020 System variable that holds RAM top + 1
SV_STACT EQU $28480 End of fixed system variables
SECTION NMI7
LEA TRAP_TABLE,A1 Point to new TRAP vector table
LEA NEW_ADDR_ERROR,A0
MOVE.L A0,ADDRESS_ERROR-TRAP_TABLE(A1)
LEA NEW_ILL_INSTR,A0
MOVE.L A0,ILLEGAL_INSTR-TRAP_TABLE(A1) Load new vectors
LEA NEW_PRIV_VIOL,A0
MOVE.L A0,PRIVILEGE_VIOL-TRAP_TABLE(A1)
LEA NEW_INT_LEV_7,A0
MOVE.L A0,INT_LEV_7-TRAP_TABLE(A1)
MOVEQ #BASIC_JOB,D1 Signal SuperBASIC job
MOVEQ #MT_TRAPV,D0 Re-define trap table
TRAP #1 Return to SuperBASIC
RTS
TRAP_TABLE
ADDRESS_ERROR DS.L 1
ILLEGAL_INSTR DS.L 1
DC.L NEW_DIV_BY_ZERO
DC.L NEW_CHK_INSTR
DC.L NEW_TRAPV_INSTR
PRIVILEGE_VIOL DS.L 1
DC.L NEW_TRACE_EXCEPT
INT_LEV_7 DS.L 1
DC.L NEW_TRAP_05
DC.L NEW_TRAP_06
DC.L NEW_TRAP_07
DC.L NEW_TRAP_08
DC.L NEW_TRAP_09
DC.L NEW_TRAP_0A
DC.L NEW_TRAP_0B
DC.L NEW_TRAP_0C
DC.L NEW_TRAP_0D
DC.L NEW_TRAP_0E
DC.L NEW_TRAP_0F
* [Effectively the same is as the corresponding routine in ROM]
NEW_ADDR_ERROR ADDQ.L #8,A7 Skip over extra words on stack
RTE Return from this exception
NEW_ILL_INSTR
NEW_PRIV_VIOL
NEW_INT_LEV_7 MOVE.W #$2700,SR Set 'supervisor' mode, mask-out interrupts 1-6 and clear 'user' flags
MOVEA.L SV_RAMT,A5 Signal value for top of RAM needed by warm restart
LEA VIDEO_RAM,A0
MOVE.L #SV_STACT-VIDEO_RAM-1,D0 Number of bytes to top of fixed system variable
AGAIN CLR.B (A0)+ Clear a byte (also provides a delay to stop other lev. 7 interrupts)
DBF D0,AGAIN Repeat until counter exhausted
MOVE.L #WARM_RESTART_JS,A0 Point to warm restart routine in 'JS' ROM
JSR (A0) Do it!
END
You may need, to change this line to correspond to your system ROM version.
MOVE.L #WARM_RESTART_JS,A0
It seems that SuperBASIC listing in the article does not have the right codes in DATA statement, at least they do not correspond to the assembly listing.
I have added DATA statements with correct codes, corrected SuperBASIC listing follows below, it is for JS ROM QL.
Code: Select all
100 REMark SuperBASIC program to implement MC68008 program in Listing 1
110 REMark COPYRIGHT (c) April 1985, Alan Turnbull, B.Sc.
120 :
130 LET reserved_address=RESPR(160)
140 RESTORE
150 LET address=reserved_address
160 REPeat read_and_store_data
170 IF EOF THEN EXIT read_and_store_data
180 READ data_item
190 POKE_W address,data_item
200 LET address=address+2
210 END REPeat read_and_store_data
220 CALL reserved_address
230 STOP
240 :
250 DATA 17402, 42, 16890, 114, 9032, 0, 16890, 110
260 DATA 9032, 4, 16890, 102, 9032, 20, 16890, 94
270 DATA 9032, 28, 29184, 28679, 20033, 20085, 0, 0
280 DATA 0, 0, 0, 94, 0, 94, 0, 94
290 DATA 0, 0, 0, 94, 0, 0, 0, 94
300 DATA 0, 94, 0, 94, 0, 94, 0, 94
310 DATA 0, 94, 0, 94, 0, 94, 0, 94
320 DATA 0, 94, 0, 94, 20623, 20083, 18172, 9984
330 DATA 10873, 2, -32736, 16889, 2, 0, 8252, 0
340 DATA -31617, 16920, 20936, -4, 8316, 0, 460, 20112
Cheers
Tom