From 4675c141e70a1bc417c0d2e70c2f7946715aa605 Mon Sep 17 00:00:00 2001 From: Leo Date: Fri, 1 Oct 2010 09:34:19 +0000 Subject: [PATCH] * New macros sbiw and INTERRUPT: - The INTERRUPT macro inserts the right jump instruction (rjmp/jmp) in the interrupt vector table. * new functions: dram_read[w]_pp, dram_write[w]_pp - read/write byte/word with address autoincrement. * Affected files: - avr/macros.inc - avr/hw-uart.asm - avr/sw-uart.asm - avr/remainders.asm - avr/init.asm - avr/dram-8bit.asm - avr/dram-8bit.asm - avr/avrcpm.asm - avr/config.inc git-svn-id: svn://cu.loc/avr-cpm/trunk@108 57430480-672e-4586-8877-bcf8adbbf3b7 --- avrcpm/avr/avrcpm.asm | 7 ++++--- avrcpm/avr/config.inc | 1 + avrcpm/avr/dram-4bit.asm | 30 ++++++++++++++++++++++++++++++ avrcpm/avr/dram-8bit.asm | 31 +++++++++++++++++++++++++++++++ avrcpm/avr/hw-uart.asm | 14 ++++++-------- avrcpm/avr/init.asm | 20 ++++++++------------ avrcpm/avr/macros.inc | 23 +++++++++++++++++++++++ avrcpm/avr/remainders.asm | 23 +++++++++++------------ avrcpm/avr/sw-uart.asm | 14 ++++++-------- 9 files changed, 120 insertions(+), 43 deletions(-) diff --git a/avrcpm/avr/avrcpm.asm b/avrcpm/avr/avrcpm.asm index 4e666c9..238c282 100644 --- a/avrcpm/avr/avrcpm.asm +++ b/avrcpm/avr/avrcpm.asm @@ -57,6 +57,7 @@ .include "hw-uart.asm" .include "dram-4bit.asm" #endif +; .include "heap.asm" .include "remainders.asm" ; >>>-------------------------------------- Virtual Devices @@ -72,9 +73,9 @@ ; <<<-------------------------------------- File System Management ; .include "z80int.asm" ;Old 8080 interpreter. ; .include "8080int.asm" ;New 8080 interpreter. -; .include "8080int-t3.asm" -; .include "8080int-t3-jmp.asm" - .include "8080int-jmp.asm" +; .include "8080int-t3.asm" ;Another 8080 interpreter +; .include "8080int-t3-jmp.asm" ;Can't get enough + .include "8080int-jmp.asm" ; .dseg diff --git a/avrcpm/avr/config.inc b/avrcpm/avr/config.inc index 5818fa4..9a1b933 100644 --- a/avrcpm/avr/config.inc +++ b/avrcpm/avr/config.inc @@ -69,6 +69,7 @@ .equ MEMFILL = 1 .equ STACK_DBG = 0 .equ PRINT_PC = 0 +.equ HEAP_DEBUG = 1 #define MMC_SPI2X 1 /* 0 = SPI CLK/4, 1 = SPI CLK/2 */ diff --git a/avrcpm/avr/dram-4bit.asm b/avrcpm/avr/dram-4bit.asm index e0d088a..d885226 100644 --- a/avrcpm/avr/dram-4bit.asm +++ b/avrcpm/avr/dram-4bit.asm @@ -88,5 +88,35 @@ dram_write: ; sei ret +; ------------------------------------------------------------------- + +dram_readw_pp: + rcall dram_read + adiw x,1 + push temp + rcall dram_read + adiw x,1 + mov temp2,temp + pop temp + ret + +dram_read_pp: + rcall dram_read + adiw x,1 + ret + +; ------------------------------------------------------------------- + +dram_writew_pp: + push temp2 + rcall dram_write + adiw x,1 + pop temp +dram_write_pp: + rcall dram_write + adiw x,1 + ret + +; ------------------------------------------------------------------- ; vim:set ts=8 noet nowrap diff --git a/avrcpm/avr/dram-8bit.asm b/avrcpm/avr/dram-8bit.asm index b335894..466f9bb 100644 --- a/avrcpm/avr/dram-8bit.asm +++ b/avrcpm/avr/dram-8bit.asm @@ -61,4 +61,35 @@ dram_write: sei ret +; ------------------------------------------------------------------- + +dram_readw_pp: + rcall dram_read + adiw x,1 + push temp + rcall dram_read + adiw x,1 + mov temp2,temp + pop temp + ret + +dram_read_pp: + rcall dram_read + adiw x,1 + ret + +; ------------------------------------------------------------------- + +dram_writew_pp: + rcall dram_write + adiw x,1 + mov temp,temp2 +dram_write_pp: + rcall dram_write + adiw x,1 + ret + + +; ------------------------------------------------------------------- +; vim:set ts=8 noet nowrap diff --git a/avrcpm/avr/hw-uart.asm b/avrcpm/avr/hw-uart.asm index e85721d..6fdb6db 100644 --- a/avrcpm/avr/hw-uart.asm +++ b/avrcpm/avr/hw-uart.asm @@ -66,11 +66,10 @@ uart_init: ; Save received character in a circular buffer. Do nothing if buffer overflows. -rxint: - .org URXCaddr - rjmp rxint ; USART receive int. +; USART receive interrupt + + INTERRUPT URXCaddr - .org rxint push temp in temp,sreg push temp @@ -130,11 +129,10 @@ uartgetc: pop zh ret -txint: - .org UDREaddr - rjmp txint ; USART transmit int. +; USART transmit interrupt + + INTERRUPT UDREaddr - .org txint push temp in temp,sreg push temp diff --git a/avrcpm/avr/init.asm b/avrcpm/avr/init.asm index 374bdd2..f38883e 100644 --- a/avrcpm/avr/init.asm +++ b/avrcpm/avr/init.asm @@ -1,5 +1,4 @@ ; Various functions: init, (RAM) disk, mmc, timer -; This file needs to get split up. ; ; Copyright (C) 2010 Sprite_tm ; Copyright (C) 2010 Leo C. @@ -124,7 +123,7 @@ clr_l: .if BOOTWAIT ldi temp,10 - rcall delay_ms + call delay_ms .endif @@ -141,15 +140,14 @@ clr_l: ramtestw: mov temp,xh eor temp,xl - mem_write - adiw xl,1 + rcall dram_write_pp brcc ramtestw printstring "wait..." ldi temp2,8 ramtestwl: ldi temp,255 - rcall delay_ms + call delay_ms dec temp2 brne ramtestwl @@ -194,8 +192,7 @@ ramtestrok: ldiw x,0 ramfillw: ldi temp,MEMFILL_VAL - mem_write - adiw xl,1 + rcall dram_write_pp brcc ramfillw .endif @@ -226,9 +223,9 @@ boot_ipl2: printnewline printstring "Partinit done." - rcall dsk_cboot ;init (de)blocking buffer + rcall dsk_cboot ;init (de)blocking buffer -; Read first sector of first CP/M partition +; Read first sector of first CP/M partition (ipl) lds xl,hostparttbl+1 lds xh,hostparttbl+2 @@ -236,7 +233,7 @@ boot_ipl2: lds yh,hostparttbl+4 rcall mmcReadSect - rcall dsk_cboot ;init (de)blocking buffer +; rcall dsk_cboot ;init (de)blocking buffer ;First sector of disk or first CP/M partition is in hostbuf. @@ -245,8 +242,7 @@ boot_ipl2: ldiw x,IPLADDR iplwriteloop: ld temp,z+ - mem_write - adiw xl,1 + rcall dram_write_pp cpi zl,low(hostbuf+128) brne iplwriteloop cpi zh,high(hostbuf+128) diff --git a/avrcpm/avr/macros.inc b/avrcpm/avr/macros.inc index b109165..d1178b7 100644 --- a/avrcpm/avr/macros.inc +++ b/avrcpm/avr/macros.inc @@ -67,6 +67,14 @@ sbci @0h, high(-@1) .endm +;------------------------------------------------ +; sub 16 bit constant from register pair + +.macro subiw + subi @0l, low(@1) + sbci @0h, high(@1) +.endm + ;------------------------------------------------ ; Move single bit between two registers ; @@ -77,6 +85,21 @@ bld @0,@1 .endm +;------------------------------------------------ +; +; +; +.macro INTERRUPT + .set pos_ = PC + .org @0 ; vector address + .if abs(pos_ - PC) > 2048 + jmp pos_ + .else + rjmp pos_ ; jump to handler + .endif + .org pos_ ; restore PC +.endm + ;------------------------------------------------ ; Print string. ; printstring "String" diff --git a/avrcpm/avr/remainders.asm b/avrcpm/avr/remainders.asm index a1372a6..534b3e1 100644 --- a/avrcpm/avr/remainders.asm +++ b/avrcpm/avr/remainders.asm @@ -26,12 +26,11 @@ ; ------------------- DRAM Refresh Interrupt -------------------- .cseg -; refresh interupt; exec 2 cbr cycles -refrint: ;4 - .org OC2Aaddr - rjmp refrint ; tim2cmpa - .org refrint +; Refresh interupt; exec 2 cbr cycles + + INTERRUPT OC2Aaddr + sbis P_RAS,ram_ras ;2 reti ; CAS RAS @@ -182,16 +181,16 @@ printstr_end: pop zl pop zh ret - - .dseg + + .dseg .cseg - + ; **************************************************************************** @@ -225,11 +224,11 @@ timer_top: .cseg -sysclockint: - .org OC1Baddr ; Timer/Counter1 Compare Match B - rjmp sysclockint ; 1ms system timer - .org sysclockint +; Timer/Counter1 Compare Match B interrupt + + INTERRUPT OC1Baddr + push zl in zl,SREG push zl diff --git a/avrcpm/avr/sw-uart.asm b/avrcpm/avr/sw-uart.asm index 36d814c..5d57485 100644 --- a/avrcpm/avr/sw-uart.asm +++ b/avrcpm/avr/sw-uart.asm @@ -83,11 +83,10 @@ uart_init: ;------------------------------------------------------------------ .cseg -srxint: - .org ICP1addr ; Timer/Counter1 Input Capture - rjmp srxint ; Soft UART: RX - .org srxint +; Timer/Counter1 Input Capture interrupt + + INTERRUPT ICP1addr push temp in temp,sreg @@ -316,11 +315,10 @@ srxi_end: ;---------------------------------------------------------------------- .cseg -stxint: - .org OC1Aaddr ; Timer/Counter1 Compare Match A - rjmp stxint ; Soft UART: TX - .org stxint +; Timer/Counter1 Compare Match A interrupt + + INTERRUPT OC1Aaddr push temp in temp,sreg -- 2.39.2