Zur Illustrierung einer Atari Portfolio typischen Erweiterung haben wir eine Erweiterung entwickelt die eine LED bei jedem System-Tick aufleuchten lässt. Um dem Benutzer die Funktionsweise transparent darstellen zu können haben wir eine ROM-Extension verwendet.
Dieses Programm illustriert wie eine einfache ROM-Extension entwickelt wird. Es kann entweder als spezifische BIOS, DOS, oder als allgemeine Erweiterung dienen, dem ID-Code bei 0C000:0 entsprechend. Jedes Erweiterungsmodul gibt sich zu erkennen und wo es aufgerufen wurde. Es ist eine gute Ausführung um die Möglichkeiten der ROM-Extensions darzustellen.
Anmerkung: ROM-Extensions dürfen AL niemals mit einem Wert von 0 zurücklassen. Dieser Gebrauch ist Atari und DIP vorbehalten.
;***************************************************************; ; ; ; Module: PDEM.ASM ; ; Copyright: DIP Ltd, 1989 ; ; ; ; DIP Pocket PC Peripheral ROM Extension ; ; ; ;***************************************************************; name XROM assume cs:cseg,ds:dseg DOSX equ 055aaH ;Specific DOS extension cseg segment org 0H ;Extension Vector table xrom_main label near ;Start label for MASM bixt_type dw DOSX ;Identification code bixt_size db 0 ;Num 512 byte blocks in ROM org 3H bixt_gdos label byte ;Specific DOS extension jmp genx_vect ;Specific extension vector org 40H bixt_user label byte ;OEM user text db 'Crt Plant Periph' ;The plan is to allocate some memory, Copy a section ; of code to memory, and then point the Specified ; vector to that code. xrom_proc proc FAR INTR_NUMB equ 1cH ;TIMER TICK genx_vect label near push ax ;Preserve registers push bx ; required to set up push ds ; local stack ;Allocate User RAM. Note that this can ONLY be done ; after DOS initialisation. mov bx,(ALOC_SIZE+0fH)/10H ;Paras to allocate mov ah,48H ;Allocate memory int 21H mov ds,ax ;Set DS to allocated RAM mov stak_save,ss ;Preserve Caller stack mov stak_save+2,sp shl bx,1 ;Convert size to bytes shl bx,1 shl bx,1 shl bx,1 ;Set up User stack. mov ss,ax ;Set up stack at top mov sp,bx ; of allocated memory push cx ;Preserve registers push dx ; YOU MUST ALWAYS PRESERVE push si ; ALL USER REGS push di push bp push es ;Copy the ISR to the allocated area push ds ;Preserve DS push cs ;Set up Source pop ds mov si,offset tick_code push ss ;Set up destination pop es mov di,offset load_base mov cx,CODE_SIZE ;Bytes to copy cld ;Initialise flag rep movsb ;Copy TSR to RAM pop ds ;Restore DS ;Get the specified vector, and set it to the ISR mov ax,3500H+INTR_NUMB ;Get current Int 1CH int 21H mov tick_vect,bx ;Preserve vector mov tick_vect+2,es mov ax,2500H+INTR_NUMB ;Set interrupt vector mov dx,offset load_base int 21H mov ax,1501H ;Generate Confidence BEEP int 61H pop es ;Restore registers pop bp pop di pop si pop dx pop cx mov ss,stak_save ;Restore Caller STACK mov sp,stak_save+2 pop ds ;Restore remaining regs pop bx pop ax ret ;FAR return to caller xrom_proc endp ;Interrupt Service Routine (ISR) PID_CODE equ 64H ;Peripheral PID code LEDS_PORT equ 807fH ;LEDs I/O address tick_code label byte ;TSR code push ax ;Preserve registers push dx push bx push ds push es mov ah,1aH ;Get Peripheral PID int 61H or al,al ;Peripheral installed? jz tick_none ;No, so uninstall cmp ah,PID_CODE ;Correct peripheral? jne tick_none ;No, so uninstall ;Peripheral installed, so toggle LEDs mov dx,LEDS_PORT ;Toggle LED address out dx,al ;AL unimportant jmp short tick_exit ;Exit tick_none: assume cs:dseg ;Force DSEG offset ;Invalid Peripheral, so uninstall TSR mov ax,2500H+INTR_NUMB ;Set interrupt vector mov bx,offset tick_vect ;Get old vector mov ds,cs:[bx+2] mov dx,cs:[bx] int 21H ;Now vector reset, free allocated memory push cs ;Segment of block pop es mov ah,49H ;Free memory int 21H tick_exit: pop es ;Restore registers pop ds pop dx pop bx pop ax jmp dword ptr cs:tick_vect ;Jump to old TSR CODE_SIZE equ $-tick_code ;Size of ISR cseg ends ;Data segment TEMPLATE (No initialised data here!) dseg segment data_sptr label byte ;Start of Data stak_save dw ? ;Caller stack stored here dw ? tick_vect dw ? ;Old vector stored here dw ? load_base label byte ;Start of ISR LOAD_SIZE equ ($-data_sptr)+CODE_SIZE ;Load module size ALOC_SIZE equ LOAD_SIZE+100H ;Load module + Stack dseg ends end xrom_main
;***************************************************************; ; ; ; Module: XROM.ASM ; ; Copyright: DIP Ltd, 1989 ; ; ; ; DIP Pocket PC ROM Extension DEMO program ; ; ; ; ; ; A ROM extension may be run from a Credit Card Memory ; ; or an Extension ROM. ; ; ; ; The Extension code must preserve ALL registers! ; ; ; ; The Pre-BIOS vector MUST return by a FAR JMP to ; ; 0FFFE:0, as no stack is set up at this stage ; ; ; ;***************************************************************; name XROM assume cs:cseg LF equ 0aH ;Line feed CR equ 0dH ;Carriage return BIOX equ 0aa55H ;Specific BIOS extension DOSX equ 055aaH ;Specific DOS extension BIDO equ 05555H ;Complete control cseg segment org 0H ;Extension Vector table xrom_main label near bixt_type dw BIOX ;Identification code bixt_size db 0 ;Num 512 byte blocks in ROM org 3H bixt_gbio label byte ;Specific BIOS extension bixt_gdos label byte ;Specific DOS extension jmp genx_vect ;Specific extension vector org 40H bixt_user label byte ;OEM user text db 'Test ROM (C) DIP' org 50H bixt_preb: jmp preb_vect ;Pre-bios jmp vector org 55H bixt_bext: jmp bext_vect ;Bios-ext jmp vector org 5aH bixt_pdos: jmp pdos_vect ;Pre-dos jmp vector org 5fH bixt_dext: jmp dext_vect ;Dos-ext jmp vector org 64H bixt_ados: jmp ados_vect ;Post-dos jmp vector org 69H bixt_pwdn: jmp pwdn_vect ;Power down jmp vector org 6eH bixt_pwup: jmp pwup_vect ;Power up jmp vector xrom_proc proc FAR ;Determine extension type genx_vect label near push bp ;Preserve BP cmp cs:[0],BIOX ;Specific BIOS extension ? jne not_genb ;No mov bp,offset gbio_text ;Specific BIOS extn text jmp short xrom_disp not_genb: cmp cs:[0],DOSX ;Specific DOS extension ? jne not_gend ;No mov bp,offset gdos_text ;Specific DOS extn text jmp short xrom_disp not_gend: mov bp,offset invl_text ;Invalid text jmp short xrom_disp preb_vect label near jmp dword ptr cs:preb_retn ;Pre-BIOS extension preb_retn dw 0 dw 0fffeH bext_vect label near ;Post-BIOS extension push bp mov bp,offset bext_text jmp short xrom_disp pdos_vect label near ;Pre-DOS extension push bp mov bp,offset pdos_text jmp short xrom_disp dext_vect label near ;DOS extension push bp mov bp,offset dext_text jmp short xrom_disp ados_vect label near ;Post-DOS extension push bp mov bp,offset ados_text jmp short xrom_disp pwdn_vect label near ;Power-Down extension push bp mov bp,offset pwdn_text jmp short xrom_disp pwup_vect label near ;Power-Up extension push bp mov bp,offset pwup_text jmp short xrom_disp xrom_disp label near ;Main display routine push ax ;Preserve registers push bx push cx push dx push es call disp_text ;Display text in BP mov ax,2400H ;Get ROM state int 61H or dl,dl ;Normal ROM ? jnz not_norm ;No, so skip mov bp,offset norm_text ;Get normal ROM text jmp short stat_disp not_norm: dec dl ;Drive A ? jnz not_drva ;No, so skip mov bp,offset drva_text ;Get Drive A text jmp short stat_disp not_drva: dec dl ;Drive B ? jnz not_drvb ;No, so skip mov bp,offset drvb_text ;Get Drive B text jmp short stat_disp not_drvb: dec dl ;Drive B ? jnz not_xrom ;No, so skip mov bp,offset xrom_text ;Get Drive B text jmp short stat_disp not_xrom: mov bp,offset invl_text stat_disp: call disp_text ;Display text in BP mov bp,offset crlf_text ;Finally CR, LF call disp_text pop es ;Restore registers pop dx pop cx pop bx pop ax pop bp ret ;FAR return xrom_proc endp ;***************************************************************; ; ; ; Main Display routine ; ; ; ;***************************************************************; disp_text proc near xor bh,bh ;Page 0 mov ah,3 ;Get cursor position in DX int 10H push cs ;Access text pop es xor ch,ch ;Initialise mov cl,es:[bp] ;Get length inc bp ;Advance to text mov ax,1301H ;Write string int 10H ret disp_text endp gbio_text db gdos_text-$-1 db 'Spec BIOS Extension - ' gdos_text db bext_text-$-1 db 'Spec DOS Extension - ' bext_text db pdos_text-$-1 db 'Com BIOS Extension - ' pdos_text db dext_text-$-1 db 'Pre-DOS Extension - ' dext_text db ados_text-$-1 db 'Com DOS Extension - ' ados_text db pwdn_text-$-1 db 'Post-DOS Extension - ' pwdn_text db pwup_text-$-1 db 'Power Down Extension - ' pwup_text db norm_text-$-1 db 'Power Up Extension - ' norm_text db drva_text-$-1 db 'Normal ROM' drva_text db drvb_text-$-1 db 'CCM Drive A' drvb_text db xrom_text-$-1 db 'CCM Drive B' xrom_text db invl_text-$-1 db 'Extn ROM' invl_text db crlf_text-$-1 db 'Invalid' crlf_text db 2,CR,LF cseg ends end xrom_main