From e8384f88b1a073f47591b9ca13b73da12a7c59a8 Mon Sep 17 00:00:00 2001 From: Leo Date: Wed, 1 May 2013 18:47:41 +0000 Subject: [PATCH] * cpm/BIOS.MAC - conin/const: Use function 'uartstat' (port 3) instead of 'constat' (port 0). constat will be removed soon. * avr/virt_ports.asm - Mark 'constat' as deprecated. * avr/* - More lds/sts --> ldd/std changes. git-svn-id: svn://cu.loc/avr-cpm/avrcpm/trunk@216 57430480-672e-4586-8877-bcf8adbbf3b7 --- avr/Makefile | 2 +- avr/Z80int-jmp.asm | 24 ++++--- avr/avrcpm.asm | 32 +++++---- avr/config.inc | 26 ++++++- avr/dsk_fat16.asm | 170 ++++++++++++++++++++++++--------------------- avr/dsk_fsys.asm | 32 +++++---- avr/dsk_mgr.asm | 21 +----- avr/init.asm | 62 ++++++++--------- avr/macros.inc | 82 ++++++++++++++++++---- avr/svnrev.inc | 12 ++-- avr/utils.asm | 95 +++++++++++++------------ avr/virt_ports.asm | 34 +++++---- cpm/BIOS.MAC | 73 +++++++++---------- cpm/CFGACPM.LIB | 29 ++++++-- 14 files changed, 404 insertions(+), 290 deletions(-) diff --git a/avr/Makefile b/avr/Makefile index aadcb40..38c5dd6 100644 --- a/avr/Makefile +++ b/avr/Makefile @@ -12,7 +12,7 @@ MCU = atmega328p #BAUD = 57600 #BAUD = 115200 #I2C_SUPPORT = 0 -#ADC_SUPPORT = 0 +ADC_SUPPORT = 0 #EM_Z80 = 0 #FAT16_SUPPORT = 0 #CPMDSK_SUPPORT = 0 diff --git a/avr/Z80int-jmp.asm b/avr/Z80int-jmp.asm index 0ef24d3..7f4ccc5 100644 --- a/avr/Z80int-jmp.asm +++ b/avr/Z80int-jmp.asm @@ -3,7 +3,7 @@ ; ; Copyright (C) 2010 Sprite_tm -; Copyright (C) 2010 Leo C. +; Copyright (C) 2010-2013 Leo C. ; Copyright (C) 2010 Horst S. ; This file is part of avrcpm. @@ -420,9 +420,13 @@ do_fetch_rst: ; mov opl,z_l ; ret -do_fetch_af: +.macro m_do_fetch_af movw opl,z_flags - ret +.endm + +.equ do_fetch_af = 0 +; movw opl,z_flags +; ret .macro m_do_fetch_bc movw opl,z_c @@ -437,9 +441,8 @@ do_fetch_af: .endm .equ do_fetch_de = 0 -; ldd opl,y+oz_e -; ldd oph,y+oz_d - ret +; movw opl,z_e +; ret .macro m_do_fetch_hl movw opl,z_l @@ -3702,9 +3705,12 @@ instr fetch_nop, op_SET7, store2_L ;FD ;SET 7,(Ix+d),L instr fetch_nop, op_SET7, store_nop ;FE ;SET 7,(Ix+d) instr fetch_nop, op_SET7, store2_A ;FF ;SET 7,(Ix+d),A -do_fetch_0: +.macro m_do_fetch_0 ldi opl,0 - ret +.endm +.equ do_fetch_0 = 0 +; ldi opl,0 +; ret ;---------------------------------------------------------------- ;|Mnemonic |SZHPNC|Description |Notes | @@ -4511,9 +4517,7 @@ instr fetch_nop, op_nop, store_nop ;FF ;NOP .org (PC+255) & 0xff00 ; .org opcjmp + 256 -; .org sz53p_table_pos ; .org FLASHEND & 0xff00 -; .org 0x1fff & 0xff00 sz53p_tab: .db 0x44,0x00,0x00,0x04,0x00,0x04,0x04,0x00 diff --git a/avr/avrcpm.asm b/avr/avrcpm.asm index 84559c7..ba3b254 100644 --- a/avr/avrcpm.asm +++ b/avr/avrcpm.asm @@ -57,34 +57,37 @@ .cseg .org 0 - rjmp start ; reset vector + ljmp start ; reset vector .org INT_VECTORS_SIZE - .include "adc.asm" - .include "utils.asm" - .include "init.asm" - .include "dram-refresh.asm" - .include "timer.asm" #if DRAM_8BIT /* Implies software uart */ .include "sw-uart.asm" - .include "i2c.asm" - .include "dram-8bit.asm" #else /* 4 bit RAM, hardware uart */ .include "hw-uart.asm" - .include "dram-4bit.asm" #endif + + .include "utils.asm" + .include "init.asm" + .include "timer.asm" .include "heap.asm" .include "mmc.asm" -; .include "mmc-old.asm" +#if DRAM_8BIT /* Implies software uart */ + .include "dram-8bit.asm" +#else /* 4 bit RAM, hardware uart */ + .include "dram-4bit.asm" +#endif +#if DRAM_8BIT /* Implies software uart */ + .include "i2c.asm" +#endif ; >>>-------------------------------------- File System Management - .include "dsk_fsys.asm" ; Basic Filesystem definitions - .include "dsk_mgr.asm" ; Disk- Manager .include "dsk_cpm.asm" ; CPM- Disk Interaktion .include "dsk_fat16.asm" ; FAT16-DISK Interaktion .include "dsk_ram.asm" ; RAM- Disk Interaktion - .include "virt_ports.asm" ; Virtual Ports for BIOS + .include "dsk_mgr.asm" ; Disk- Manager + .include "dsk_fsys.asm" ; Basic Filesystem definitions + ; <<<-------------------------------------- File System Management ; .include "8080int-orig.asm" ;Old 8080 interpreter. @@ -94,6 +97,9 @@ ; .include "8080int-jmp.asm" ; .include "Z80int-jmp.asm" ; + .include "virt_ports.asm" ; Virtual Ports for BIOS + .include "dram-refresh.asm" + .dseg ramtop: .byte 0 diff --git a/avr/config.inc b/avr/config.inc index fd29616..e7e3ef4 100644 --- a/avr/config.inc +++ b/avr/config.inc @@ -93,6 +93,11 @@ ;----------------------------------------------------------------------- ; Z80/8080 Virtual Ports +#define UARTDR 1 /* UART Data Register */ +#define UARTCSR 3 /* UART Control/Status Register */ +#define UARTRXRDY 0x01 /* RxReady Status Bit Mask */ +#define UARTTXRDY 0x02 /* TxReady Status Bit Mask */ + #define READ_FUNC 7 #define WRITE_FUNC 6 #define BOOT_FUNC 5 @@ -145,8 +150,6 @@ ;----------------------------------------------------------------------- ; -#define PARTID 0x52 /* Partition table id */ - /* http://www.win.tue.nl/~aeb/partitions/partition_types-1.html */ #define IPLADDR 0x2000 /* Bootloader load address */ #define DRAM_WAITSTATES 1 /* Number of additional clock cycles for dram read access */ @@ -166,6 +169,25 @@ #define DBG_TRACE_TOP 0xdc /* Trace is off, below bottom page and above top page. */ #define SRAMFILL_VAL 0x5A /* Fill unused SRAM */ +; define PARTID 0x52 /* Partition table id */ + /* http://www.win.tue.nl/~aeb/partitions/partition_types-1.html */ +; Partition Table Structures + +#define PART_TYPE 4 +#define PART_START 8 +#define PART_SIZE 12 + +/* + * Partition table id + * (see http://www.win.tue.nl/~aeb/partitions/partition_types-1.html) + */ +#define PARTID1_FAT16 0x0E +#define PARTID2_FAT16 0x06 +#define PARTID_CPM 0x52 + + +;----------------------------------------------------------------------- +; #ifndef DRAM_8BIT #define DRAM_8BIT 1 /* 1 = 8bit wide data bus to DRAM (ie two 4-bit Chips)*/ #endif /* 0 = only one 4 bit wide DRAM chip */ diff --git a/avr/dsk_fat16.asm b/avr/dsk_fat16.asm index d248b4e..74d162e 100644 --- a/avr/dsk_fat16.asm +++ b/avr/dsk_fat16.asm @@ -664,10 +664,10 @@ fat_add_noprune: ldd xl,z+1 ldd xh,z+2 + ldiw y,fat_vars rcall fat_gethostsec printstring "Begin of image at: " - movw temp ,y lcall printhexw movw temp ,x lcall printhexw @@ -714,8 +714,6 @@ fat_add_nomore: ; ============================================================================ fat_gethostsec: - ldiw y,fat_vars - ; Get Offset into Data area of Disk clr _tmp0 @@ -746,36 +744,39 @@ fat_c2s_end: adc _tmp0,temp ldd temp,y+o_fat_ptr2dat+3 adc _tmp1,temp - movw y,_tmp0 + movw temp,_tmp0 ret ; ==================================================================== ; Function: Searches a physical Cluster, given the logical Cluster ; ==================================================================== -; Registers: [in] xh,xl logical- Cluster -; [out] yh,yl physical- Cluster +; Registers: [in] xh:xl logical- Cluster +; [out] temp2:temp physical- Cluster ; Variables: ; -------------------------------------------------------------------- ; Description: ; ==================================================================== + fat_find_phsy_clust: + lds zl,hostdsk rcall dsk_getpartentry ; get partition entry -; Get First FAT- Cluster Number of Diskimage - - ldd yl,z+1 - ldd yh,z+2 - .if FAT16_DBG_FAT > 0 printstring "Search log. cluster " movw temp,x lcall printhexw printnewline +.endif +; Get First FAT- Cluster Number of Diskimage + + ldd temp, z+1 + ldd temp2,z+2 + +.if FAT16_DBG_FAT > 0 printstring "Search phys. cluster " - movw temp ,y lcall printhexw printnewline .endif @@ -783,19 +784,13 @@ fat_find_phsy_clust: fat_next_phsy_clust: cp xl,_0 cpc xh,_0 -; breq fat_found_phsy_clust - brne PC+2 - rjmp fat_found_phsy_clust + breq fat_found_phsy_clust ; Get Next Cluster from Fat ; Trick: 512 Bytes Per Sector equals to 256 FAT- entries per Sector -; so given: yl is the Offset within the FAT Sector -; yh is the number off the FAT sector to Read - -; in zh,zl: Pointer to Word within the Sector to read -; in yh..xl: Start sector number (LBA) -; out zh,zl : word thats been read +; so given: temp is the Offset within the FAT Sector +; temp2 is the number off the FAT sector to Read push xl push xh @@ -803,33 +798,34 @@ fat_next_phsy_clust: ; Create FAT Offset Value clr zh - mov zl,yl + mov zl,temp lsl zl rol zh - mov temp,yh .if SRAM_SIZE > 1024 ; Check, if required fat sector allready in buffer - lds temp2,fat_last_fatsect - sts fat_last_fatsect,temp + ldd temp,y+o_fat_last_fatsect + std y+o_fat_last_fatsect,temp2 cp temp,temp2 breq fat_phys_1 ; Not in buffer, get fat sector - lds xl,fat_ptr2fat ;get FAT start - lds xh,fat_ptr2fat+1 - lds yl,fat_ptr2fat+2 - lds yh,fat_ptr2fat+3 - add xl,temp ;add cluster offset within sector + ldd xl, y+o_fat_ptr2fat ;get FAT start + ldd xh, y+o_fat_ptr2fat+1 + ldd _tmp0,y+o_fat_ptr2fat+2 + ldd _tmp1,y+o_fat_ptr2fat+3 + add xl,temp2 ;add cluster offset within sector adc xh,_0 - adc yl,_0 - adc yh,_0 + adc _tmp0,_0 + adc _tmp1,_0 + movw y,_tmp0 .if 0 printnewline printstring "Read FAT sec: " + mov temp,temp2 lcall printhex printstring ", " movw temp,z @@ -839,6 +835,10 @@ fat_next_phsy_clust: push zl push zh ldiw z,fat_buf + +; in zh,zl Pointer to Word within the Sector to read +; in yh..xl Start sector number (LBA) +; out zh,zl word thats been read lcall mmcReadSect pop zh pop zl @@ -847,20 +847,23 @@ fat_phys_1: ldiw y,fat_buf add zl,yl adc zh,yh - ldd yl,z+0 - ldd yh,z+1 + ldd temp, z+0 + ldd temp2,z+1 + ldiw y,fat_vars .else - lds xl,fat_ptr2fat ;get FAT start - lds xh,fat_ptr2fat+1 - lds yl,fat_ptr2fat+2 - lds yh,fat_ptr2fat+3 - add xl,temp ;add cluster offset within sector + ldd xl,y+o_fat_ptr2fat ;get FAT start + ldd xh,y+o_fat_ptr2fat+1 + ldd _tmp0,y+o_fat_ptr2fat+2 + ldd _tmp1,y+o_fat_ptr2fat+3 + movw y,_tmp0 + add xl,temp2 ;add cluster offset within sector adc xh,_0 adc yl,_0 adc yh,_0 lcall mmcReadWord - movw y,z + movw temp,z + ldiw y,fat_vars .endif pop xh pop xl @@ -876,7 +879,6 @@ fat_found_phsy_clust: .if FAT16_DBG_FAT > 0 printstring "Found phys. Cluster at:" - movw temp,y lcall printhexw printnewline .endif @@ -916,24 +918,28 @@ fat_found_phsy_clust: ; sector. this gives the pointer to the sector to be read and or written. ; ============================================================================ - fat_lba_to_phys: ; ################# Get logical Number of Cluster within the imagefile ; printstring "calc log sector" ; Logical Sectornumber in x + + ldiw y,fat_vars + movw temp,x - mov yl,_0 - mov yh,_0 -; Divide logical Sectornumber by size of Cluster in sectors - lds zl,fat_clustersize + mov _tmp0,_0 + mov _tmp1,_0 + +; Divide logical sectornumber by size of cluster in sectors + + ldd zl,y+o_fat_clustersize lsr zl fat_search_clst_lp: tst zl breq fat_found_clst - lsr yh - ror yl + lsr _tmp1 + ror _tmp0 ror xh ror xl @@ -941,85 +947,93 @@ fat_search_clst_lp: rjmp fat_search_clst_lp -fat_found_clst: ; at this point xh and xl are carying the logical cluster number ; printstring "find subsector" ; ################# Get subsector within the logical cluster for later use - mov yl,xl - lds zl,fat_clustersize + +fat_found_clst: + mov _tmp0,xl + ldd zl,y+o_fat_clustersize lsr zl fat_search_clst_lp2: tst zl breq fat_found_subsec - lsl yl + lsl _tmp0 lsr zl rjmp fat_search_clst_lp2 fat_found_subsec: mov zl,temp - sub zl,yl - sts fat_clust_offset,zl + sub zl,_tmp0 + std y+o_fat_clust_offset,zl ; Check against last HOSTDISK searched - lds yl,fat_last_dsk - lds yh,hostdsk - cp yl,yh + lds _tmp0,hostdsk + ldd _tmp1,y+o_fat_last_dsk + std y+o_fat_last_dsk,_tmp0 + cp _tmp0,_tmp1 brne fat_wrong_cache_clst ; Check against last Cluster searched - lds yl,fat_log_clust - lds yh,fat_log_clust+1 + ldd _tmp0,y+o_fat_log_clust + ldd _tmp1,y+o_fat_log_clust+1 - cp yl,xl - cpc yh,xh + cp _tmp0,xl + cpc _tmp1,xh brne fat_wrong_cache_clst ; Last Cluster = searched Cluster -> get Sectornumber from cache - lds xl,fat_clust_ptr - lds xh,fat_clust_ptr+1 - lds yl,fat_clust_ptr+2 - lds yh,fat_clust_ptr+3 + ldd xl, y+o_fat_clust_ptr + ldd xh, y+o_fat_clust_ptr+1 + ldd temp, y+o_fat_clust_ptr+2 + ldd temp2,y+o_fat_clust_ptr+3 rjmp fat_add_offset ; Cluster is not in cache, so we must search for it fat_wrong_cache_clst: - lds yl,hostdsk - sts fat_last_dsk,yl - sts fat_log_clust,xl - sts fat_log_clust+1,xh + std y+o_fat_log_clust,xl + std y+o_fat_log_clust+1,xh ; Map Logical Cluster-Number to "Physical" Cluster Number using the FAT + rcall fat_find_phsy_clust ; Get StartSector of "physical" Cluster - movw x,y + + movw x,temp rcall fat_gethostsec ; Found the physical sector + .if FAT16_DBG_FAT > 0 printstring "Found phys. Sector at:" - movw temp,y + push temp2 + push temp lcall printhexw movw temp,x lcall printhexw printnewline + pop temp + pop temp2 .endif ; Save the found Sector for later use into cache - sts fat_clust_ptr ,xl - sts fat_clust_ptr+1,xh - sts fat_clust_ptr+2,yl - sts fat_clust_ptr+3,yh + + std y+o_fat_clust_ptr ,xl + std y+o_fat_clust_ptr+1,xh + std y+o_fat_clust_ptr+2,temp + std y+o_fat_clust_ptr+3,temp2 ; Add- Subsector to Startsector fat_add_offset: - lds zl,fat_clust_offset + ldd zl,y+o_fat_clust_offset add xl,zl adc xh,_0 - adc yl,_0 - adc yh,_0 + adc temp,_0 + adc temp2,_0 + movw y,temp ; Found the physical sector .if FAT16_DBG_FAT > 0 diff --git a/avr/dsk_fsys.asm b/avr/dsk_fsys.asm index d298019..4f9b226 100644 --- a/avr/dsk_fsys.asm +++ b/avr/dsk_fsys.asm @@ -1,6 +1,7 @@ ; Filesystem functions for the Interaction with BIOS and Disks ; ; Copyright (C) 2010 Frank Zoll +; Copyright (C) 2010,2011,2013 Leo C. ; ; This file is part of avrcpm. ; @@ -758,8 +759,21 @@ dpb_imgd_common: rcall dsk_getpartentry ;get partition entry std z+PTAB_SPT,yl tst yh ;more then 256 sectors per track? - brne dsk_imgprp_err ;todo: support 16 bit sector numbers + breq dpb_imgd_1 ;todo: support 16 bit sector numbers +dsk_imgprp_err: + printnewline + ldi temp,'A' + add temp,temp3 + lcall uartputc + printstring ": Format not supported: Too much sectors per track! " + printnewline + +dpb_imgd_err: + clr temp + ret + +dpb_imgd_1: andi temp2,0x0f swap temp2 std z+PTAB_BSH,temp2 @@ -773,18 +787,6 @@ dpb_imgd_common: ori temp,255 ret -dsk_imgprp_err: - printnewline - ldi temp,'A' - add temp,temp3 - lcall uartputc - printstring ": Format not supported: Too much sectors per track! " - printnewline - -dpb_imgd_err: - clr temp - ret - ; ==================================================================== ; Function: ; ==================================================================== @@ -1423,7 +1425,7 @@ dsk_readhost: breq dsk_hstrd_err ldiw z,hostbuf - rcall mmcReadSect + lcall mmcReadSect tst temp brne dsk_hstrd_err @@ -1498,7 +1500,7 @@ dsk_hstpar_nofat: ; Is it a CP/M Partition ? cpi temp,dskType_CPM brne dsk_hstpar_nocpm - rcall cpm_lba_to_phys + lcall cpm_lba_to_phys rjmp dsk_hstpar_gotit dsk_hstpar_nocpm: #endif diff --git a/avr/dsk_mgr.asm b/avr/dsk_mgr.asm index c9ff9e0..55bca46 100644 --- a/avr/dsk_mgr.asm +++ b/avr/dsk_mgr.asm @@ -2,6 +2,7 @@ ; systems ; ; Copyright (C) 2010 Frank Zoll +; Copyright (C) 2013 Leo C. ; ; This file is part of avrcpm. ; @@ -22,24 +23,6 @@ ; -; -------------------------- Defines for the disk management Structures - -; Partition Table Structures - -#define PART_TYPE 4 -#define PART_START 8 -#define PART_SIZE 12 - -/* - * Partition table id - * (see http://www.win.tue.nl/~aeb/partitions/partition_types-1.html) - */ -#define PARTID1_FAT16 0x0E -#define PARTID2_FAT16 0x06 -#define PARTID_CPM 0x52 - - -; ------------------------------------------------ Start of Code Segment .cseg ; ==================================================================== @@ -143,7 +126,7 @@ mgr_ploop: cpi temp,PARTID_CPM brne mgr_nextp - rcall cpm_add_partition + lcall cpm_add_partition inc temp3 sts ndisks,temp3 adiw y,PARTENTRY_SIZE diff --git a/avr/init.asm b/avr/init.asm index c75227d..41626dd 100644 --- a/avr/init.asm +++ b/avr/init.asm @@ -34,7 +34,8 @@ regval_tab: regval_tab_e: start: - ldi temp,low(RAMEND) ; top of memory + ldi temp,low(RAMEND) ; top of memory; vim:set ts=8 noet nowrap + out SPL,temp ; init stack pointer ldi temp,high(RAMEND) ; top of memory out SPH,temp ; init stack pointer @@ -224,6 +225,24 @@ ramtestrex: halted_loop: rjmp halted_loop ;keep AVR in an endless loop +printxbits: + push temp2 + push temp3 + mov temp2,temp + ldi temp3,8 +prntxb0: + ldi temp,'-' + lsl temp2 + brcc prntxb1 + ldi temp,'X' +prntxb1: + rcall uartPutc + dec temp3 + brne prntxb0 + pop temp3 + pop temp2 + ret + ramtestend: .endif @@ -269,17 +288,20 @@ boot_ipl2: ; Read first sector of first CP/M partition (ipl) + ldiw y,fsys_vars + ; Disk 0 - sts seekdsk,_0 + std y+o_seekdsk,_0 ; Track 0 - sts seektrk,_0 - sts seektrk+1,_0 + std y+o_seektrk, _0 + std y+o_seektrk+1,_0 ; Sector 0 - sts seeksec,_0 + std y+o_seeksec,_0 ; Destination ldiw x,IPLADDR - stsw dmaadr,x + std y+o_dmaadr+0,xl + std y+o_dmaadr+1,xh ldi temp,1< 2048 - jmp pos_ + .set pos_ = PC ;save current position + .org @0 ;vector address + .set dist_ = pos_ - (PC+1) + + .if dist_ <= 2048 + rjmp pos_ + .elif (dist_ - (FLASHEND+1)) > -2048 + .set disp_ = (dist_ - (FLASHEND+1)) & 0xFFF +; rjmp pos_ - (FLASHEND+1) + .dw 0xC000 | disp_ .else - rjmp pos_ ; jump to handler + jmp pos_ ;jump to handler .endif - .org pos_ ; restore PC + + .org pos_ ;restore PC .endm ;------------------------------------------------ ; ; + +#if 1 + +.macro ljmp + .if FLASHEND > 0x0fff + .ifdef @0 + .set dist_ = @0 - (PC+1) + .if dist_ < 0 + .if dist_ >= -2048 + rjmp @0 + .elif dist_ < -(FLASHEND+1-2048) + .dw 0xC000 | (dist_ + (FLASHEND+1)) & 0xFFF + .else + jmp @0 + .endif + .else ; >0 + .if (dist_ < 2048) + rjmp @0 + .elif dist_ > (FLASHEND+1-2048) + .dw 0xC000 | (dist_ - (FLASHEND+1)) & 0xFFF + .else + jmp @0 + .endif + .endif + .else ; not def @0 + jmp @0 + .endif + .else ; <= 0x0fff + rjmp @0 + .endif +.endm + +#else + .macro ljmp .if FLASHEND > 0x0fff .ifdef @0 @@ -134,7 +175,7 @@ rjmp @0 .endif .endm - +#endif ;------------------------------------------------ ; @@ -142,15 +183,28 @@ .macro lcall .if FLASHEND > 0x0fff .ifdef @0 - .if abs(PC - @0) > 2047 - call @0 - .else - rcall @0 + .set dist_ = @0 - (PC+1) + .if dist_ < 0 + .if dist_ >= -2048 + rcall @0 + .elif dist_ < -(FLASHEND+1-2048) + .dw 0xC000 | (dist_ + (FLASHEND+1)) & 0xFFF + .else + call @0 + .endif + .else ; >0 + .if (dist_ < 2048) + rcall @0 + .elif dist_ > (FLASHEND+1-2048) + .dw 0xC000 | (dist_ - (FLASHEND+1)) & 0xFFF + .else + call @0 + .endif .endif - .else + .else ; not def @0 call @0 .endif - .else + .else ; <= 0x0fff rcall @0 .endif .endm diff --git a/avr/svnrev.inc b/avr/svnrev.inc index d78f63b..d9a547f 100644 --- a/avr/svnrev.inc +++ b/avr/svnrev.inc @@ -2,17 +2,17 @@ * (http://www.compuphase.com/svnrev.htm). * You should not modify it manually, as it may be re-generated. * - * $Revision: 214$ - * $Date: 2013-04-20$ + * $Revision: 215$ + * $Date: 2013-04-27$ */ #ifndef SVN_REV_H #define SVN_REV_H -#define SVN_REV 214 -#define SVN_REVSTR "214" -#define SVN_REVDATE "2013-04-20" -#define SVN_REVSTAMP 20130420L +#define SVN_REV 215 +#define SVN_REVSTR "215" +#define SVN_REVDATE "2013-04-27" +#define SVN_REVSTAMP 20130427L #define SVN_REVMODIFIED 0 #endif /* SVN_REV_H */ diff --git a/avr/utils.asm b/avr/utils.asm index d8f8814..5ae5c1d 100644 --- a/avr/utils.asm +++ b/avr/utils.asm @@ -1,6 +1,6 @@ ; Print and Debug functions ; -; Copyright (C) 2010 Leo C. +; Copyright (C) 2010-2013 Leo C. ; ; This file is part of avrcpm. ; @@ -114,53 +114,13 @@ printhexn_isno: ; Prints a single space -dbg_printspace: - ldi temp,' ' - rjmp uartputc - -; Prints 16 bytes pointed to by Z in hex. - -dbg_hexdump_line: ;Address in z - push temp2 +printspace: push temp - printnewline - movw temp,z ;Print address - rcall printhexw - ldi temp2,16 ;16 byte per line - rcall dbg_printspace -dbg_hdl1: - cpi temp2,8 - brne PC+2 - rcall dbg_printspace - - rcall dbg_printspace - ld temp,z+ - rcall printhex - dec temp2 - brne dbg_hdl1 - sbiw z,16 - - rcall dbg_printspace - rcall dbg_printspace - ldi temp2,16 -dbg_hdl2: - ld temp,z+ - cpi temp,' ' - brlo dbg_hdpd - cpi temp,0x7F - brlo dbg_hdp -dbg_hdpd: - ldi temp,'.' -dbg_hdp: + ldi temp,' ' rcall uartputc - dec temp2 - brne dbg_hdl2 - sbiw z,16 - rcall dbg_printspace pop temp - pop temp2 ret - + ;----------------------------------------------------------------------- ;Prints the zero-terminated string following the call statement. @@ -306,6 +266,53 @@ stack_search_found: +;----------------------------------------------------------------------- +; Prints 16 bytes RAM, pointed to by Z in hex. + +#if 0 + +dbg_hexdump_line: ;Address in z + push temp2 + push temp + printnewline + movw temp,z ;Print address + rcall printhexw + ldi temp2,16 ;16 byte per line + rcall printspace +dbg_hdl1: + cpi temp2,8 + brne PC+2 + rcall printspace + + rcall printspace + ld temp,z+ + rcall printhex + dec temp2 + brne dbg_hdl1 + sbiw z,16 + + rcall printspace + rcall printspace + ldi temp2,16 +dbg_hdl2: + ld temp,z+ + cpi temp,' ' + brlo dbg_hdpd + cpi temp,0x7F + brlo dbg_hdp +dbg_hdpd: + ldi temp,'.' +dbg_hdp: + rcall uartputc + dec temp2 + brne dbg_hdl2 + sbiw z,16 + rcall printspace + pop temp + pop temp2 + ret +#endif + ;----------------------------------------------------------------------- ; Print a line with the 8080/Z80 registers diff --git a/avr/virt_ports.asm b/avr/virt_ports.asm index e832d08..660f4e7 100644 --- a/avr/virt_ports.asm +++ b/avr/virt_ports.asm @@ -25,12 +25,14 @@ ; Port Direction Function ;hex dez ;------------------------------------------------------------------------- -;00 0 in - Con status. +;00 0 in - Con status. (deprecated) ; Returns 0xFF if the UART has a byte, 0 otherwise. ;01 1 in/out - Console input, aka UDR. / Console Output ;02 2 out - Console Output (deprecated) -;03 3 in - "UART" status: bit 0 = rx, bit 1 = tx -;04 4 in - "UART" data register, no wait +;03 3 in - "UART" status: bit 0 = rx (UARTRXRDY) +; bit 1 = tx (UARTTXRDY) +;03 3 out - "UART" control (tbd) +;04 4 in/out - "UART" data register, no wait ; ;------------------------ Virtual I2C interface -------------------------- ;05 5 out - Control Port: 1 = Start read operation @@ -87,18 +89,22 @@ .cseg vport_tbl: - .db 00,1 ;Port 0, length 1 + .db 00,1 ;Port 0, length, 1 deprecated .dw conStatus ; in .dw dbgOut ; out - .db 01,1 - .dw uartgetc - .dw uartputc - .db 02,1 ;Port 2 (old console output) - .dw uartgetc ; filler - .dw uartputc ; deprecated - .db 03,1 + + .db UARTDR,1 ;Port UARTDR, length 1 + .dw uartgetc ; in + .dw uartputc ; out + +; .db 02,1 ;Port 2 (old console output) +; .dw uartgetc ; filler +; .dw uartputc ; deprecated + + .db UARTCSR,1 .dw uartstat .dw vport_out_dummy + .db 04,1 .dw uartin .dw uartout @@ -248,15 +254,17 @@ vprw_exit: vport_out_dummy: ret +;--------------------------------------------------------------------- + uartstat: clr temp lds temp2,rxcount cpse temp2,_0 - sbr temp,0x01 + sbr temp,UARTRXRDY lds temp2,txcount cpi temp2,TXBUFSIZE breq uartst_1 - sbr temp,0x02 + sbr temp,UARTTXRDY uartst_1: ret diff --git a/cpm/BIOS.MAC b/cpm/BIOS.MAC index 813e813..e7417d8 100644 --- a/cpm/BIOS.MAC +++ b/cpm/BIOS.MAC @@ -100,20 +100,23 @@ msgnodisk: db cr,lf,0 const: - in a,(0) + in a,(UARTCSR) + and UARTRXRDY + ret z + or 0ffh ret conin: - in a,(0) - cp 0ffh - jp nz,conin + in a,(UARTCSR) + rra + jp nc,conin - in a,(1) + in a,(UARTDR) ret conout: ld a,c - out (1),a + out (UARTDR),a ret list: @@ -361,56 +364,56 @@ getdph: home: - ld a,1 shl HOME_FUNC - out (22),a + ld a,1 shl HOME_FUNC + out (22),a - ld bc,0 ; same as seek to track 0 + ld bc,0 ; same as seek to track 0 settrk: - ld a,c - out (16),a - ld a,b - out (17),a + ld a,c + out (16),a + ld a,b + out (17),a ret setsec: - ld a,c - out (18),a + ld a,c + out (18),a ret setdma: - ld a,c - out (20),a - ld a,b - out (21),a + ld a,c + out (20),a + ld a,b + out (21),a ret read: - ld a,1 shl READ_FUNC - out (22),a - in a,(22) - and 1 + ld a,1 shl READ_FUNC + out (22),a + in a,(22) + and 1 ret write: ld a,c - and 3 ;mask write type + and 3 ;mask write type or 1 shl WRITE_FUNC out (22),a - in a,(22) - and 1 + in a,(22) + and 1 ret sectran: ;translate sector bc using table at de, res into hl - ld h,b - ld l,c - ld a,d - or e - ret z - ex de,hl - add hl,bc - ld l,(hl) - ld h,0 + ld h,b + ld l,c + ld a,d + or e + ret z + ex de,hl + add hl,bc + ld l,(hl) + ld h,0 ret ;------------------------------------------------------------------------ diff --git a/cpm/CFGACPM.LIB b/cpm/CFGACPM.LIB index 7c2f7d0..f664e0e 100644 --- a/cpm/CFGACPM.LIB +++ b/cpm/CFGACPM.LIB @@ -31,15 +31,18 @@ retry equ 3 ;max retries on disk i/o before error ;copy from avr/virt_ports.asm: +; ; Port Direction Function ;hex dez ;------------------------------------------------------------------------- -;00 0 in - Con status. +;00 0 in - Con status. (deprecated) ; Returns 0xFF if the UART has a byte, 0 otherwise. ;01 1 in/out - Console input, aka UDR. / Console Output ;02 2 out - Console Output (deprecated) -;03 3 in - "UART" status: bit 0 = rx, bit 1 = tx -;04 4 in - "UART" data register, no wait +;03 3 in - "UART" status: bit 0 = rx (UARTRXRDY) +; bit 1 = tx (UARTTXRDY) +;03 3 out - "UART" control (tbd) +;04 4 in/out - "UART" data register, no wait ; ;------------------------ Virtual I2C interface -------------------------- ;05 5 out - Control Port: 1 = Start read operation @@ -71,6 +74,13 @@ retry equ 3 ;max retries on disk i/o before error ; 0x00 = ok, 0xff = error (--> Bad Sector) ; ; +;------------------------ ADC Interface ---------------------------------- +;17-19 23,25 in - ADC Channels 6,7 and 8 (Temp-Sensor) +; ADC 6,7 only Devices in 32 pin Case (TQFP/MLF) +; 8 Bit only +; Fixed ADC clock (FCPU/128, 156KHz at 20MHz CPU) +; Vref = VCC +;20,21 in - ADC: Measure VCC ; ;------------------------ Wall Clock and Timers -------------------------- ;40 64-71 in/out - Timer/Clock control. @@ -78,10 +88,19 @@ retry equ 3 ;max retries on disk i/o before error ; ;47-4D clock - BCD format: ss, mm, hh, DD, MM, YYl, YYh ; +;4F debug - start/stop trace, print stack, ... +; ;------------------------ Ports ------------------------------------------ ;80-87 in/out - Port-Expander PCF8574 (max. 8 Chips) ;88-8F in/out - Port-Expander PCF8574A (not implemented yet!) +;----------------------------------------------------------------------- +; Z80/8080 Virtual Ports + +UARTDR equ 1 ;UART Data Register +UARTCSR equ 3 ;UART Control/Status Register +UARTRXRDY equ 01h ;RxReady Status Bit Mask +UARTTXRDY equ 02h ;TxReady Status Bit Mask READ_FUNC equ 7 WRITE_FUNC equ 6 @@ -102,7 +121,3 @@ DEBUGPORT equ 04FH StartTraceCmd equ 1 StopTraceCmd equ 0 - - - - -- 2.39.2