From: Niklas Ramsberg (niklas.ramsberg_at_swipnet.se)
Date: 2003-01-28 16:46:44
Hej allihopa! On Tue, 28 Jan 2003 09:46:22 +0100 "Mikael Holm" <mikael.holm@se.danskebank.com> wrote: > According to my C128 Programmers Guide (from Compute) there is a > subfunction of the USER-call to execute 8502 code and then return to > CP/M... But as usual with interresting stuff in books, there's no > examples so I'm a bit stuck... Double-Ass by René van Belzen handles both Z80 and 8502 code (in the same source). It uses the C128 Basic editor, so it won't be of interest for you if you want to program from within CP/M but this piece of code from the manual might be of interest: ----------------------------------------------------------------------- Switching between processors --------- ------- ---------- Switching between the 8502 microprocessor and the Z-80 microprocessor is a delicate business, which should be programmed with care. Use the following subroutine to assure crash-free operation. --------------------------------------- 1000 *= $8000 ; start on $8000 (change if necessary) 1010 .LIS N ; no listing 1020 .OBJ M ; object code in memory 1030 : 1040 : ; This part is essential, no errors allowed 1050 : 1060 LDA $FF00 ; MMU bank configuration register 1070 PHA ; save it on stack 1080 SEI ; disable the system interrupt 1090 LDA #$C3 ; store Z-80 opcode - JP 1100 STA $FFEE ; on boot-link address $FFEE .. $FFF0 1110 LDA #<Z80 ; lobyte Z-80 routine, defined below 1120 STA $FFEF 1130 LDA #>Z80 ; hibyte Z-80 routine 1140 STA $FFF0 1150 LDA #$3E ; set the configuration register 1160 STA $FF00 ; with the appropriate value 1170 LDA $D505 ; save the mode configuration register 1180 PHA ; for later 1190 LDA #$B0 ; and set the mode configuration 1200 STA $D505 ; to 'Z-80 active' 1210 : ; when this last instruction is executed 1220 : ; the Z-80 is active and the 8502 is frozen 1230 NOP ; IMPORTANT: give the 8502 time to start 1240 PLA ; now back in good ol' 8502 mode 1250 STA $D505 ; restore old mode configuration 1260 PLA ; and 1270 STA $FF00 ; old memory configuration 1280 CLI ; enable the system interrupt 1290 RTS ; end of essential subroutine 1300 : 1500 : ; Routine for the Z-80 1510 : 1520 Z80 ; Label for the Z-80 routine (s.a. above) 1530 .MOD 1 ; Z-80 opcodes now valid in assembler 1540 LD A, $3F ; change value of configuration register 1550 LD ($FF00), A ; to the appropriate value 1560 : 1570 : ; *** sample program 1580 : ; - clear VIC-II graphic screen 1590 : 1600 LD A, $00 ; Fill byte $00 on the first 1610 LD ($2000), A ; location of graphic screen ($2000) 1620 LD HL, $2000 ; load HL with address value $2000 1630 LD DE, $2001 ; load DE with address value $2001 1640 LD BC, 7999 ; load BC register with 7999 1650 : ; (number of bytes to fill) 1660 LDIR ; execute (HL) -> (DE), 7999 times 1670 : 1680 : ; *** end of sample program 1690 : 1700 : ; Crucial for the switch back 1710 : 1720 JP $FFE0 ; jump to bootlink routine in the Z-80 ROM 1730 : ; i.e. switch 8502 on, and Z-80 off ----------------------------------------------------------------- Double-Ass can be downloaded from my C128 page: http://192.168.0.2/bacon/cbm/c128/applications.html /Niklas Ramsberg Message was sent through the cbm-hackers mailing list
Archive generated by hypermail 2.1.6.