From 825ecc9d1df4b7b39bbbcbc6461d0407dd7d9d22 Mon Sep 17 00:00:00 2001 From: Leo Date: Sat, 30 Mar 2013 08:07:20 +0000 Subject: [PATCH] * Z80/8080 registers BC, DE, HL moved from RAM to AVR CPU registers. 'temp4' removed. * Parameter for 'print_ultoa' (32 bit integer) moved from 'temp4:temp3:temp2:temp' to 'r15:r14:temp2:temp'. * init.asm: Do not set global pullup disable bit ('PUD'). Enable pullup on RXD pin. * Do not disable interrupts on DRAM access. git-svn-id: svn://cu.loc/avr-cpm/avrcpm/trunk@204 57430480-672e-4586-8877-bcf8adbbf3b7 --- avr/Makefile | 10 +- avr/Z80int-jmp.asm | 542 ++++++++++++++++++++++++--------------------- avr/config.inc | 53 ++--- avr/dram-8bit.asm | 8 +- avr/dram-8bit.inc | 8 +- avr/dsk_cpm.asm | 34 +-- avr/dsk_fat16.asm | 30 ++- avr/dsk_fsys.asm | 49 ++-- avr/dsk_mgr.asm | 41 ++-- avr/heap.asm | 46 ++-- avr/i2c.asm | 6 +- avr/init.asm | 16 +- avr/mmc.asm | 11 +- avr/timer.asm | 59 ++--- avr/utils.asm | 38 ++-- avr/virt_ports.asm | 18 +- 16 files changed, 515 insertions(+), 454 deletions(-) diff --git a/avr/Makefile b/avr/Makefile index 7c0328f..b4fdfdc 100644 --- a/avr/Makefile +++ b/avr/Makefile @@ -11,7 +11,8 @@ MCU = atmega328P #DRAM_8BIT = 0 #BAUD = 57600 #BAUD = 115200 -#I2C = 0 +I2C_SUPPORT = 0 +#ADC_SUPPORT = 0 #EM_Z80 = 0 #FAT16_SUPPORT = 0 #MMCBOOTLOADER = 0 @@ -51,8 +52,11 @@ endif ifdef BAUD CDEFS += -DBAUD=$(BAUD) endif -ifdef I2C - CDEFS += -DI2C=$(I2C) +ifdef I2C_SUPPORT + CDEFS += -DI2C_SUPPORT=$(I2C_SUPPORT) +endif +ifdef ADC_SUPPORT + CDEFS += -DADC_SUPPORT=$(ADC_SUPPORT) endif ifdef EM_Z80 CDEFS += -DEM_Z80=$(EM_Z80) diff --git a/avr/Z80int-jmp.asm b/avr/Z80int-jmp.asm index e2f8ea4..675b287 100644 --- a/avr/Z80int-jmp.asm +++ b/avr/Z80int-jmp.asm @@ -24,58 +24,57 @@ ; $Id$ ; +#if EM_Z80 + .dseg z_regs: -z_b: .byte 1 -z_c: .byte 1 -z_d: .byte 1 -z_e: .byte 1 -z_h: .byte 1 -z_l: .byte 1 - - .equ oz_b = 0 - .equ oz_c = 1 - .equ oz_d = 2 - .equ oz_e = 3 - .equ oz_h = 4 - .equ oz_l = 5 - - -#if EM_Z80 -z_b2: .byte 1 -z_c2: .byte 1 -z_d2: .byte 1 -z_e2: .byte 1 -z_h2: .byte 1 -z_l2: .byte 1 -z_f2: .byte 1 -z_a2: .byte 1 - .equ r2ofs = z_b2-z_b - .equ oz_b2 = 6 - .equ oz_c2 = 7 - .equ oz_d2 = 8 - .equ oz_e2 = 9 - .equ oz_h2 = 10 - .equ oz_l2 = 11 - .equ oz_f2 = 12 - .equ oz_a2 = 13 - -z_xh: .byte 1 -z_xl: .byte 1 -z_yh: .byte 1 -z_yl: .byte 1 - -z_i: .byte 1 -z_r: .byte 1 - .equ oz_xh = 14 - .equ oz_xl = 15 - .equ oz_yh = 16 - .equ oz_yl = 17 - .equ oz_i = 18 - .equ oz_r = 19 - -z_istat: .byte 1 - .equ oz_istat = 20 +z_c2: + .equ oz_c2 = z_c2 - z_regs + .byte 1 +z_b2: + .equ oz_b2 = z_b2 - z_regs + .byte 1 +z_e2: + .equ oz_e2 = z_e2 - z_regs + .byte 1 +z_d2: + .equ oz_d2 = z_d2 - z_regs + .byte 1 +z_l2: + .equ oz_l2 = z_l2 - z_regs + .byte 1 +z_h2: + .equ oz_h2 = z_h2 - z_regs + .byte 1 +z_f2: + .equ oz_f2 = z_f2 - z_regs + .byte 1 +z_a2: + .equ oz_a2 = z_a2 - z_regs + .byte 1 + +z_xl: + .equ oz_xl = z_xl - z_regs + .byte 1 +z_xh: + .equ oz_xh = z_xh - z_regs + .byte 1 +z_yl: + .equ oz_yl = z_yl - z_regs + .byte 1 +z_yh: + .equ oz_yh = z_yh - z_regs + .byte 1 +z_i: + .equ oz_i = z_i - z_regs + .byte 1 +z_r: + .equ oz_r = z_r - z_regs + .byte 1 + +z_istat: + .equ oz_istat = z_istat - z_regs + .byte 1 .equ IM_MASK = 0x03 ;Mask IM 0..2 .equ IM0 = 0 @@ -84,7 +83,6 @@ z_istat: .byte 1 .equ IFF1 = 2 ;IFF1 Flag .equ IFF2 = 3 ;IFF2 Flag - #endif .cseg @@ -94,7 +92,6 @@ z80_init: ldiw z_pc,IPLADDR ldiw y,z_regs - cbi flags,trace clr intstat printnewline @@ -124,7 +121,7 @@ noprintpc: ;TODO: hier kommt die Interruptbehandlung rein - cpse intstat,_0 ;Fast path if no trace, int, break, ... + cpse intstat,_0 ;Fast path if no trace, int, break, ... rjmp int_test int_instr: @@ -137,6 +134,8 @@ int_instr: int_test: sbrs intstat,i_trace rjmp int_notrace + sbrs intstat,i_halt + rjmp int_notrace cpi z_pch,DBG_TRACE_BOTTOM brlo int_notrace cpi z_pch,DBG_TRACE_TOP @@ -372,23 +371,25 @@ do_fetch_rst: ; ret .macro m_do_fetch_b - ldd opl,y+oz_b + mov opl,z_b .endm .equ do_fetch_b = 0 +; mov opl,z_b ; ldd opl,y+oz_b ; ret .macro m_do_fetch_c - ldd opl,y+oz_c + mov opl,z_c .endm .equ do_fetch_c = 0 +; mov opl,z_c ; ldd opl,y+oz_c ; ret .macro m_do_fetch_d - ldd opl,y+oz_d + mov opl,z_d .endm .equ do_fetch_d = 0 @@ -396,7 +397,7 @@ do_fetch_rst: ; ret .macro m_do_fetch_e - ldd opl,y+oz_e + mov opl,z_e .endm .equ do_fetch_e = 0 @@ -404,41 +405,50 @@ do_fetch_rst: ; ret .macro m_do_fetch_h - ldd opl,y+oz_h + mov opl,z_h .endm .equ do_fetch_h = 0 -; ldd opl,y+oz_h +; mov opl,z_h ; ret .macro m_do_fetch_l - ldd opl,y+oz_l + mov opl,z_l .endm .equ do_fetch_l = 0 -; ldd opl,y+oz_l +; mov opl,z_l ; ret do_fetch_af: - mov opl,z_flags - mov oph,z_a + movw opl,z_flags ret -do_fetch_bc: - ldd opl,y+oz_c - ldd oph,y+oz_b - ret +.macro m_do_fetch_bc + movw opl,z_c +.endm -do_fetch_de: - ldd opl,y+oz_e - ldd oph,y+oz_d - ret +.equ do_fetch_bc = 0 +; movw opl,z_c +; ret + +.macro m_do_fetch_de + movw opl,z_e +.endm -do_fetch_hl: - ldd opl,y+oz_l - ldd oph,y+oz_h +.equ do_fetch_de = 0 +; ldd opl,y+oz_e +; ldd oph,y+oz_d ret +.macro m_do_fetch_hl + movw opl,z_l +.endm + +.equ do_fetch_hl = 0 +; movw opl,z_l +; ret + .macro m_do_fetch_sp movw opl,z_spl .endm @@ -448,20 +458,19 @@ do_fetch_hl: ; ret do_fetch_mbc: - ldd xh,y+oz_b - ldd xl,y+oz_c + movw x,z_c mem_read_d z_a ret do_fetch_mde: - ldd xh,y+oz_d - ldd xl,y+oz_e + movw x,z_e +; ldd xh,y+oz_d +; ldd xl,y+oz_e mem_read_d z_a ret do_fetch_mhl: - ldd xh,y+oz_h - ldd xl,y+oz_l + movw x,z_l mem_read_d opl ret @@ -499,64 +508,61 @@ do_store_a: ;.endm ;.equ do_store_b = 0 do_store_b: - std y+oz_b,opl + mov z_b,opl ret do_store_c: - std y+oz_c,opl + mov z_c,opl ret do_store_d: - std y+oz_d,opl + mov z_d,opl ret do_store_e: - std y+oz_e,opl + mov z_e,opl ret do_store_h: - std y+oz_h,opl + mov z_h,opl ret do_store_l: - std y+oz_l,opl + mov z_l,opl ret do_store_af: - mov z_a,oph - mov z_flags,opl + movw z_flags,opl ret do_store_bc: - std y+oz_b,oph - std y+oz_c,opl + movw z_c,opl ret do_store_de: - std y+oz_d,oph - std y+oz_e,opl + movw z_e,opl +; std y+oz_d,oph +; std y+oz_e,opl ret do_store_hl: - std y+oz_h,oph - std y+oz_l,opl + movw z_l,opl ret do_store_mbc: - ldd xh,y+oz_b - ldd xl,y+oz_c + movw x,z_c mem_write_s z_a ret do_store_mde: - ldd xh,y+oz_d - ldd xl,y+oz_e + movw x,z_e +; ldd xh,y+oz_d +; ldd xl,y+oz_e mem_write_s z_a ret do_store_mhl: - ldd xh,y+oz_h - ldd xl,y+oz_l + movw x,z_l mem_write_s opl ret @@ -1011,6 +1017,19 @@ dbg_op_ina_2: do_op_inc: #if EM_Z80 +#if 1 + andi z_flags,(1<qq' (except AF)| +#if 1 + +do_op_EXX: + ldd temp ,y+oz_c2 + ldd temp2,y+oz_b2 + std y+oz_c2,z_c + std y+oz_b2,z_b + movw z_c,temp + + ldd temp ,y+oz_e2 + ldd temp2,y+oz_d2 + std y+oz_e2,z_e + std y+oz_d2,z_d + movw z_e,temp + + ldd temp ,y+oz_l2 + ldd temp2,y+oz_h2 + std y+oz_l2,z_l + std y+oz_h2,z_h + movw z_l,temp + ret +#else + do_op_EXX: ldiw z,z_b ldi temp3,6 @@ -1946,6 +2015,8 @@ opexx_loop: brne opexx_loop ret +#endif + #else do_op_djnz: do_op_EXAF: @@ -2037,7 +2108,8 @@ do_op_prefixCB: instr fetch_nop, op_nop, store_nop ;00 ;NOP instr fetch_DIR16, op_nop, store_BC ;01 nn nn ;LD BC,nn instr fetch_nop, op_nop, store_MBC ;02 ;LD (BC),A -instr fetch_BC, op_INC16, store_BC ;03 ;INC BC +;instr fetch_BC, op_INC16, store_BC ;03 ;INC BC +instr fetch_nop, op_INCBC, store_nop ;03 ;INC BC instr fetch_B, op_INC, store_B ;04 ;INC B instr fetch_B, op_DEC, store_B ;05 ;DEC B instr fetch_DIR8, op_nop, store_B ;06 ;LD B,n @@ -2045,7 +2117,8 @@ instr fetch_nop, op_RLCA, store_nop ;07 ;RLCA instr fetch_nop, op_EXAF, store_nop ;08 ;EX AF,AF' instr fetch_BC, op_ADDHL, store_nop ;09 ;ADD HL,BC instr fetch_MBC, op_nop, store_nop ;0A ;LD A,(BC) -instr fetch_BC, op_DEC16, store_BC ;0B ;DEC BC +;instr fetch_BC, op_DEC16, store_BC ;0B ;DEC BC +instr fetch_nop, op_DECBC, store_nop ;0B ;DEC BC instr fetch_C, op_INC, store_C ;0C ;INC C instr fetch_C, op_DEC, store_C ;0D ;DEC C instr fetch_DIR8, op_nop, store_C ;0E nn ;LD C,n @@ -2053,7 +2126,8 @@ instr fetch_nop, op_RRCA, store_nop ;0F ;RRCA instr fetch_DIR8, op_DJNZ, store_nop ;10 oo ;DJNZ o instr fetch_DIR16, op_nop, store_DE ;11 nn nn ;LD DE,nn instr fetch_nop, op_nop, store_MDE ;12 ;LD (DE),A -instr fetch_DE, op_INC16, store_DE ;13 ;INC DE +;instr fetch_DE, op_INC16, store_DE ;13 ;INC DE +instr fetch_nop, op_INCDE, store_nop ;13 ;INC DE instr fetch_D, op_INC, store_D ;14 ;INC D instr fetch_D, op_DEC, store_D ;15 ;DEC D instr fetch_DIR8, op_nop, store_D ;16 nn ;LD D,n @@ -2061,7 +2135,8 @@ instr fetch_nop, op_RLA, store_nop ;17 ;RLA instr fetch_DIR8, op_nop, store_pcrel ;18 oo ;JR o instr fetch_DE, op_ADDHL, store_nop ;19 ;ADD HL,DE instr fetch_MDE, op_nop, store_nop ;1A ;LD A,(DE) -instr fetch_DE, op_DEC16, store_DE ;1B ;DEC DE +;instr fetch_DE, op_DEC16, store_DE ;1B ;DEC DE +instr fetch_nop, op_DECDE, store_nop ;1B ;DEC DE instr fetch_E, op_INC, store_E ;1C ;INC E instr fetch_E, op_DEC, store_E ;1D ;DEC E instr fetch_DIR8, op_nop, store_E ;1E nn ;LD E,n @@ -2069,7 +2144,8 @@ instr fetch_nop, op_RRA, store_nop ;1F ;RRA instr fetch_DIR8, op_IFNZ, store_pcrel ;20 oo ;JR NZ,o instr fetch_DIR16, op_nop, store_HL ;21 nn nn ;LD HL,nn instr fetch_DIR16, op_STHL, store_nop ;22 nn nn ;LD (nn),HL -instr fetch_HL, op_INC16, store_HL ;23 ;INC HL +;instr fetch_HL, op_INC16, store_HL ;23 ;INC HL +instr fetch_nop, op_INCHL, store_nop ;23 ;INC HL instr fetch_H, op_INC, store_H ;24 ;INC H instr fetch_H, op_DEC, store_H ;25 ;DEC H instr fetch_DIR8, op_nop, store_H ;26 nn ;LD H,n @@ -2077,7 +2153,8 @@ instr fetch_A, op_DAA, store_A ;27 ;DAA instr fetch_DIR8, op_IFZ, store_pcrel ;28 oo ;JR Z,o instr fetch_HL, op_ADDHL, store_nop ;29 ;ADD HL,HL instr fetch_DIR16, op_RMEM16, store_HL ;2A nn nn ;LD HL,(nn) -instr fetch_HL, op_DEC16, store_HL ;2B ;DEC HL +;instr fetch_HL, op_DEC16, store_HL ;2B ;DEC HL +instr fetch_nop, op_DECHL, store_nop ;2B ;DEC HL instr fetch_L, op_INC, store_L ;2C ;INC L instr fetch_L, op_DEC, store_L ;2D ;DEC L instr fetch_DIR8, op_nop, store_L ;2E nn ;LD L,n @@ -2939,15 +3016,17 @@ do_op_BIT2: do_op_BIT1: ldi temp,0x02 rjmp opbit - checkspace PC, 8 + + checkspace PC, 7 do_op_BIT0: ldi temp,0x01 opbit: - and temp,opl - in temp,sreg + andi z_flags,~((1< (" - ldd temp,y+oz_c + mov temp,z_c lcall printhex printstring ") " .endif mov temp,opl - ldd temp2,y+oz_c + mov temp2,z_c lcall portWrite ret @@ -3699,11 +3777,9 @@ do_op_out: ; out (c),opl do_op_stbc: ;store bc to mem loc in opl:h movw xl,opl - ldd temp,y+oz_c - mem_write + mem_write_s z_c adiw xl,1 - ldd temp,y+oz_b - mem_write + mem_write_s z_b ret ;---------------------------------------------------------------- @@ -3714,11 +3790,9 @@ do_op_stbc: ;store bc to mem loc in opl:h ; do_op_stde: ;store de to mem loc in opl:h movw xl,opl - ldd temp,y+oz_e - mem_write + mem_write_s z_e adiw xl,1 - ldd temp,y+oz_d - mem_write + mem_write_s z_d ret ;---------------------------------------------------------------- @@ -3741,19 +3815,14 @@ do_op_stsp: ;store sp to mem loc in opl:h ; do_op_ADCHL: - ldd temp,y+oz_l - ldd temp2,y+oz_h - clc - sbrc z_flags,ZFL_C - sec - adc opl,temp - in temp,sreg ; save lower Z - adc oph,temp2 - in temp2,sreg - std y+oz_l,opl - std y+oz_h,oph - and temp,temp2 ; 16bit Z + lsr z_flags ; ZFL_C --> Carry ldi z_flags,0 ; clear N + adc z_l,opl + in temp,sreg ; save lower Z + adc z_h,oph + in temp2,sreg + + and temp,temp2 ; 16bit Z bmov z_flags,ZFL_C, temp2,AVR_C bmov z_flags,ZFL_P, temp2,AVR_V bmov z_flags,ZFL_H, temp2,AVR_H @@ -3770,18 +3839,12 @@ do_op_ADCHL: checkspace PC, 24 do_op_sbchl: - ldd temp,y+oz_l - ldd temp2,y+oz_h - cp temp,opl ; set z - clc - sbrc z_flags,ZFL_C - sec - sbc temp,opl - sbc temp2,oph - std y+oz_l,temp - std y+oz_h,temp2 + lsr z_flags ; get Z80 carry + sez ; set z + sbc z_l,opl + sbc z_h,oph in temp,sreg - ldi z_flags,(1< 0 printstring "Read Image Sector:" - push temp4 - push temp3 + push r15 + push r14 push temp2 push temp movw temp,x - movw temp3,y + movw r14,y lcall print_ultoa pop temp pop temp2 - pop temp3 - pop temp4 + pop r14 + pop r15 printnewline .endif diff --git a/avr/dsk_fsys.asm b/avr/dsk_fsys.asm index f2d656b..5df2f1e 100644 --- a/avr/dsk_fsys.asm +++ b/avr/dsk_fsys.asm @@ -171,10 +171,10 @@ dbg_print_biosd: ; ==================================================================== ; Parameters ; -------------------------------------------------------------------- -; Registers : [w] z Pointer to the Partitionentry -; [r] zl Number of Diskentry to Read -; [w] _tmp0 scratch -; [w] _tmp1 " +; Registers : [w] z Pointer to the Partitionentry +; [r] zl Number of Diskentry to Read +; [w] r0 scratch +; [w] r1 " ; -------------------------------------------------------------------- ; Description: ; ==================================================================== @@ -183,8 +183,8 @@ dsk_getpartentry: ldi zh,PARTENTRY_SIZE mul zh,zl ldiw z,hostparttbl - add zl,_tmp0 - adc zh,_tmp1 + add zl,r0 + adc zh,r1 ret ; ==================================================================== @@ -1051,7 +1051,7 @@ dsk_read: andi temp,dskType_MASK ; Isn't it a Disk ? - cpi temp,dskType_None + cpi temp,dskType_None brne PC+2 rjmp dsk_read_err @@ -1104,7 +1104,7 @@ dsk_write: ; It must be a FAT16-Imagefile or CP/M Partition. - rcall dsk_setdrvparam ;todo: do this only if needed (disk change) + rcall dsk_setdrvparam ;TODO: do this only if needed (disk change) andi temp,WRTMSK sts wrtype,temp ;save write type @@ -1141,10 +1141,10 @@ dsk_chkuna: ; disks are the same lds temp,unatrk lds temp2,unatrk+1 - lds temp3,seektrk - lds temp4,seektrk+1 - cp temp,temp3 ;seektrk = unatrk? - cpc temp2,temp4 + lds _tmp0,seektrk + lds _tmp1,seektrk+1 + cp temp,_tmp0 ;seektrk = unatrk? + cpc temp2,_tmp1 brne dsk_alloc ;skip if not ; tracks are the same @@ -1209,16 +1209,15 @@ dsk_rwoper: lds temp,hdrsize ;add image header size add xl,temp ; adc xh,_0 ; - lds temp3,seektrk ; - lds temp4,seektrk+1 ; - lds temp,cpmspt ; - mul temp3,temp ; + lds temp,seektrk ; + lds temp2,seektrk+1 ; + lds temp3,cpmspt ; + mul temp,temp3 ; add xl,r0 ; adc xh,r1 ; - mul temp4,temp ; + mul temp2,temp3 ; add xh,r0 ;yl:xh:xl := sec + trk * SectorsPerTrack adc yl,r1 ; - mov temp,xl andi temp,SECMSK ;mask buffer number push temp ;save for later @@ -1239,12 +1238,20 @@ dsk_sh1: ;copy data to or from buffer ldiw z,hostbuf +#if 1 + pop temp2 ;get buffer number (which part of hostbuf) + clr temp + lsr temp2 ;temp2:temp = temp2 * 128 + ror temp + add zl,temp ;offset in hostbuf + adc zh,temp2 +#else ldi temp,128 pop temp2 ;get buffer number (which part of hostbuf) mul temp2,temp add zl,r0 ;offset in hostbuf adc zh,r1 - +#endif .if DISK_DEBUG > 2 movw temp,r0 printstring "; host buf adr: " @@ -1340,9 +1347,9 @@ dsk_rw_hostbuf: ; same disk, same block? lds _tmp0,hostlba - lds _tmp1,hostlba+1 cp temp,_tmp0 - cpc temp2,_tmp1 + lds _tmp0,hostlba+1 + cpc temp2,_tmp0 breq dsk_match dsk_nomatch: diff --git a/avr/dsk_mgr.asm b/avr/dsk_mgr.asm index db62ed1..9cb1aef 100644 --- a/avr/dsk_mgr.asm +++ b/avr/dsk_mgr.asm @@ -97,10 +97,10 @@ mgr_check_bootsektor: ;Test, if it has a valid MBR lds temp,hostbuf+510 ;MBR signature (0xAA55) at and of sector? - lds temp2,hostbuf+510+1 - ldi temp4,0xAA cpi temp,0x55 - cpc temp2,temp4 + lds temp,hostbuf+510+1 + ldi temp2,0xAA + cpc temp,temp2 breq mgr_search ;No MBR, no partition table ... @@ -125,7 +125,6 @@ mgr_check_bootsektor: ; Search for valid Partitions and ImageFiles mgr_search: ldiw z,hostbuf+510-64 ;Point to first byte of partition table - ldi temp4,4 ;Partition table has 4 entries. mgr_ploop: @@ -145,14 +144,13 @@ mgr_ploop: mgr_nextp: adiw z,16 - dec temp4 + cpi zl,low(hostbuf+510) ;End of partition table reached? brne mgr_ploop #if FAT16_SUPPORT ; Test for FAT16 Partition ldiw z,hostbuf+510-64 ;Point to first byte of partition table - ldi temp4,4 mgr_ploop2: ; Get Partitiontype @@ -174,7 +172,7 @@ mgr_fatfound: mgr_nextp2: adiw zl,16 - dec temp4 + cpi zl,low(hostbuf+510) brne mgr_ploop2 #endif @@ -212,17 +210,15 @@ mgr_prnt_parttbl: ldi xh,'A' pprl: - ldd temp ,z+1 ;Get partition start - ldd temp2,z+2 - ldd temp3,z+3 - ldd temp4,z+4 - printnewline - cp temp,_0 ;If zero ... - cpc temp2,_0 - cpc temp3,_0 - cpc temp4,_0 + ldd temp ,z+1 ;Get partition start + ldd temp2,z+2 + or temp,temp2 + ldd temp2,z+3 + or temp,temp2 + ldd temp2,z+4 + or temp,temp2 ;If zero ... breq mgr_prnop ;... no partition table at 0 ; Partitiontype examining @@ -268,14 +264,15 @@ mgr_prnt_size: ldd temp ,z+5 ;Get partition size ldd temp2,z+6 - ldi temp3,0 - ldi temp4,0 - - lsr temp4 - ror temp3 - ror temp2 + push r15 + push r14 + clr r14 + clr r15 + lsr temp2 ror temp lcall print_ultoa + pop r14 + pop r15 printstring "KB." mgr_goto_next_part: diff --git a/avr/heap.asm b/avr/heap.asm index 0ff38e4..e144369 100644 --- a/avr/heap.asm +++ b/avr/heap.asm @@ -28,25 +28,25 @@ hp_top: .byte 2 .if HEAP_DEBUG hp_print_free: - push temp4 - push temp3 + push r15 + push r14 push temp2 push temp printstring ", bytes free: " - lds temp3,hp_top - lds temp4,hp_top+1 + lds r14,hp_top + lds r15,hp_top+1 ldi temp,0 ldi temp2,0 - sub temp,temp3 - sbc temp2,temp4 - ldi temp3,0 - ldi temp4,0 + sub temp,r14 + sbc temp2,r15 + clr r14 + clr r15 rcall print_ultoa printstring " " pop temp pop temp2 - pop temp3 - pop temp4 + pop r14 + pop r15 ret .endif @@ -80,30 +80,30 @@ hp_dbg1: ; return 0 if not enough space heap_get: - push temp4 - push temp3 + push r15 + push r14 .if HEAP_DEBUG push temp2 push temp printnewline printstring "Heap get: " - ldi temp3,0 - ldi temp4,0 + clr r14 + clr r15 rcall print_ultoa pop temp pop temp2 .endif - lds temp3,hp_top - lds temp4,hp_top+1 - add temp,temp3 - adc temp2,temp4 + lds r14,hp_top + lds r15,hp_top+1 + add temp,r14 + adc temp2,r15 brcs hp_full ; zero flag clear here sts hp_top,temp sts hp_top+1,temp2 - movw temp,temp3 + movw temp,r14 rjmp hp_get_ex hp_full: clr temp @@ -114,11 +114,11 @@ hp_get_ex: printstring "Error: " hp_get_dbg1: rcall hp_print_free - mov temp3,temp ;restore zero flag - or temp3,temp2 + mov r14,temp ;restore zero flag + or r14,temp2 .endif - pop temp3 - pop temp4 + pop r14 + pop r15 ret diff --git a/avr/i2c.asm b/avr/i2c.asm index 0d96ace..9b13191 100644 --- a/avr/i2c.asm +++ b/avr/i2c.asm @@ -1,7 +1,7 @@ ; I2C (TWI) master interface. ; This is part of the Z80-CP/M emulator written by Sprite_tm. ; -; Copyright (C) 2010 Leo C. +; Copyright (C) 2013 Leo C. ; ; This file is part of avrcpm. ; @@ -21,7 +21,7 @@ ; $Id$ ; -#if I2C +#if I2C_SUPPORT /* General TWI Master status codes */ #define TWI_START 0x08 /* START has been transmitted */ @@ -469,7 +469,7 @@ pcf8574_out: ret -#endif /* I2C */ +#endif /* I2C_SUPPORT */ ;------------------------------------------------------------------ ; vim:set ts=8 noet nowrap diff --git a/avr/init.asm b/avr/init.asm index a6a1d41..469001a 100644 --- a/avr/init.asm +++ b/avr/init.asm @@ -60,9 +60,9 @@ cp_l: lpm xh,z+ ; - Setup Ports - ldi temp,(1<