]> cloudbase.mooo.com Git - avrcpm.git/commitdiff
* Rest of 'remainders.asm' split:
authorLeo <erbl259-lmu@yahoo.de>
Fri, 1 Oct 2010 10:12:32 +0000 (10:12 +0000)
committerLeo <erbl259-lmu@yahoo.de>
Fri, 1 Oct 2010 10:12:32 +0000 (10:12 +0000)
  - avr/dram-refresh.asm
  - avr/timer.asm
  - avr/utils.asm

git-svn-id: svn://cu.loc/avr-cpm/trunk@109 57430480-672e-4586-8877-bcf8adbbf3b7

avrcpm/avr/avrcpm.asm
avrcpm/avr/dram-refresh.asm [new file with mode: 0644]
avrcpm/avr/timer.asm [moved from avrcpm/avr/remainders.asm with 54% similarity]
avrcpm/avr/utils.asm [new file with mode: 0644]

index 238c28201f436a6f59434769cd20697b7f4da81b..50ce1f800a5afdea07263cd175cfedad2511a2ff 100644 (file)
        .include "hw-uart.asm"
        .include "dram-4bit.asm"
 #endif
+       .include "dram-refresh.asm"
+       .include "timer.asm"
+       .include "utils.asm"
 ;      .include "heap.asm"
-       .include "remainders.asm"
 
 ; >>>-------------------------------------- Virtual Devices
        .include "virt_ports.asm"               ; Virtual Ports for BIOS
diff --git a/avrcpm/avr/dram-refresh.asm b/avrcpm/avr/dram-refresh.asm
new file mode 100644 (file)
index 0000000..4ed7e19
--- /dev/null
@@ -0,0 +1,54 @@
+;    DRAM refresh
+;
+;    Copyright (C) 2010 Sprite_tm
+;    Copyright (C) 2010 Leo C.
+;
+;    This file is part of avrcpm.
+;
+;    avrcpm is free software: you can redistribute it and/or modify it
+;    under the terms of the GNU General Public License as published by
+;    the Free Software Foundation, either version 3 of the License, or
+;    (at your option) any later version.
+;
+;    avrcpm is distributed in the hope that it will be useful,
+;    but WITHOUT ANY WARRANTY; without even the implied warranty of
+;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;    GNU General Public License for more details.
+;
+;    You should have received a copy of the GNU General Public License
+;    along with avrcpm.  If not, see <http://www.gnu.org/licenses/>.
+;
+;    $Id: remainders.asm 108 2010-10-01 09:34:19Z leo $
+;
+
+
+; ------------------- DRAM Refresh Interrupt --------------------
+
+       .cseg
+       
+       INTERRUPT OC2Aaddr
+
+       sbis    P_RAS,ram_ras   ;2
+       reti
+                               ;       CAS  RAS  
+       cbi     P_CAS,ram_cas   ;2       1|   1|  
+                               ;        1|   1|  
+       cbi     P_RAS,ram_ras   ;2      |0    1|  
+                               ;       |0    1|  
+       nop                     ;1      |0   |0   
+;      nop                     ;1      |0   |0   
+       sbi     P_RAS,ram_ras   ;2      |0   |0   
+                               ;       |0   |0   
+       dram_wait DRAM_WAITSTATES-1 ;   |    |
+;      nop                     ;1      |0   |0   
+       cbi     P_RAS,ram_ras   ;2      |0    1|  
+                               ;       |0    1|  
+       sbi     P_CAS,ram_cas   ;2      |0   |0   
+                               ;       |0   |0   
+       sbi     P_RAS,ram_ras   ;2       1|  |0   
+                               ;        1|   1|  
+       reti                    ;4  --> 21 cycles
+
+
+; vim:set ts=8 noet nowrap
+
similarity index 54%
rename from avrcpm/avr/remainders.asm
rename to avrcpm/avr/timer.asm
index 534b3e13872cd5da1a67404ad86a71b3dfea3443..f03b82de16800d552e62743f9592961ad19b2eb5 100644 (file)
@@ -1,7 +1,5 @@
-;    Various functions: init, (RAM) disk, mmc, timer
-;    This file needs to get split up.
+;    Timer module
 ;
-;    Copyright (C) 2010 Sprite_tm
 ;    Copyright (C) 2010 Leo C.
 ;
 ;    This file is part of avrcpm.
 ;    You should have received a copy of the GNU General Public License
 ;    along with avrcpm.  If not, see <http://www.gnu.org/licenses/>.
 ;
-;    $Id$
+;    $Id: remainders.asm 108 2010-10-01 09:34:19Z leo $
 ;
 
-
-; ------------------- DRAM Refresh Interrupt --------------------
-
-       .cseg
-
-; Refresh interupt; exec 2 cbr cycles
-       
-       INTERRUPT OC2Aaddr
-
-       sbis    P_RAS,ram_ras   ;2
-       reti
-                               ;       CAS  RAS  
-       cbi     P_CAS,ram_cas   ;2       1|   1|  
-                               ;        1|   1|  
-       cbi     P_RAS,ram_ras   ;2      |0    1|  
-                               ;       |0    1|  
-       nop                     ;1      |0   |0   
-;      nop                     ;1      |0   |0   
-       sbi     P_RAS,ram_ras   ;2      |0   |0   
-                               ;       |0   |0   
-       dram_wait DRAM_WAITSTATES-1 ;   |    |
-;      nop                     ;1      |0   |0   
-       cbi     P_RAS,ram_ras   ;2      |0    1|  
-                               ;       |0    1|  
-       sbi     P_CAS,ram_cas   ;2      |0   |0   
-                               ;       |0   |0   
-       sbi     P_RAS,ram_ras   ;2       1|  |0   
-                               ;        1|   1|  
-       reti                    ;4  --> 21 cycles
-
-
-
-
-;Print a unsigned lonng value to the uart
-; temp4:temp3:temp2:temp = value
-
-print_ultoa:
-       push    yh
-       push    yl
-       push    z_flags
-       push    temp4
-       push    temp3
-       push    temp2
-       push    temp
-                               
-       clr     yl              ;yl = stack level
-
-ultoa1:        ldi     z_flags, 32     ;yh = temp4:temp % 10
-       clr     yh              ;temp4:temp /= 10
-ultoa2:        lsl     temp    
-       rol     temp2   
-       rol     temp3   
-       rol     temp4   
-       rol     yh      
-       cpi     yh,10   
-       brcs    ultoa3  
-       subi    yh,10   
-       inc     temp
-ultoa3:        dec     z_flags 
-       brne    ultoa2
-       cpi     yh, 10  ;yh is a numeral digit '0'-'9'
-       subi    yh, -'0'
-       push    yh              ;Stack it
-       inc     yl      
-       cp      temp,_0         ;Repeat until temp4:temp gets zero
-       cpc     temp2,_0
-       cpc     temp3,_0
-       cpc     temp4,_0
-       brne    ultoa1  
-       
-       ldi     temp, '0'
-ultoa5:        cpi     yl,3            ; at least 3 digits (ms)
-       brge    ultoa6
-       push    temp    
-       inc     yl
-       rjmp    ultoa5
-
-ultoa6:        pop     temp            ;Flush stacked digits
-       rcall   uartputc
-       dec     yl      
-       brne    ultoa6  
-
-       pop     temp
-       pop     temp2
-       pop     temp3
-       pop     temp4
-       pop     z_flags
-       pop     yl
-       pop     yh
-       ret
-
-
-;Prints temp2:temp in hex to the uart
-printhexw:
-       push    temp
-       mov     temp,temp2
-       rcall   printhex
-       pop     temp
-       ;fall thru
-
-;Prints temp in hex to the uart
-printhex:
-       swap temp
-       rcall printhexn
-       swap temp       
-       ;fall thru
-
-;Prints the lower nibble
-printhexn:
-       push temp
-       andi temp,0xf
-       cpi temp,0xA
-       brlo printhexn_isno
-       subi temp,-7
-printhexn_isno:
-       subi temp,-'0'
-       rcall uartputc
-       pop temp
-       ret
-
-;Prints the zero-terminated string following the call statement. 
-
-printstr:
-       push    zh
-       push    zl
-       push    yh
-       push    yl
-       push    temp
-       in      yh,sph
-       in      yl,spl
-       ldd     zl,y+7
-       ldd     zh,y+6
-
-       lsl zl
-       rol zh
-printstr_loop:
-       lpm temp,z+
-       cpi temp,0
-       breq printstr_end
-       rcall uartputc
-       cpi temp,13
-       brne printstr_loop
-       ldi temp,10
-       rcall uartputc
-       rjmp printstr_loop
-
-printstr_end:
-       adiw zl,1               ;rounding
-       lsr zh
-       ror zl
-
-       std     y+7,zl
-       std     y+6,zh
-       pop     temp
-       pop     yl
-       pop     yh
-       pop     zl
-       pop     zh
-       ret
-
-       .dseg
-
-
-       .cseg
-       
-       
-
-
-
-       
-; ****************************************************************************
-
-; ------------- system timer 1ms ---------------
-
        .dseg
 
 delay_timer1:
@@ -222,9 +46,11 @@ timer_top:
 .equ clkofs    = cnt_1ms-cntms_out
 .equ timerofs  = cnt_1ms-timer_ms
  
-
        .cseg   
 
+; ------------- system timer 1ms ---------------
+
+
 ; Timer/Counter1 Compare Match B interrupt
        
        INTERRUPT OC1Baddr
@@ -295,7 +121,11 @@ syscl_end:
        pop     zl
        reti
 
+; ----------------------------------------------
+;      delay
+;
 ; wait for temp ms
+;
 
 delay_ms:
        sts     delay_timer1,temp
@@ -305,6 +135,7 @@ dly_loop:
        brne    dly_loop
        ret
 
+; ----------------------------------------------
 ; 
 
 clockget:
@@ -492,74 +323,5 @@ uptime_print:
 
        ret
 
-
-       
-; --------------- Debugging stuff ---------------
-; Print a line with the Z80 main registers
-
-;.if INS_DEBUG
-
-zflags_to_ch:
-       .db     "SZ H PNC",0,0
-       
-printregs:
-       printnewline
-
-       push    zl
-       push    zh
-       ldiw    z,zflags_to_ch*2
-       mov     temp2,z_flags
-pr_zfl_next:
-       lpm     temp,z+
-       tst     temp
-       breq    pr_zfl_end
-       cpi     temp,' '                        ; Test if no flag
-       breq    pr_zfl_noflag
-       sbrs    temp2,7                 ; 
-        ldi    temp,' '                        ; Flag not set
-       rcall   uartputc
-pr_zfl_noflag:
-       rol     temp2
-       rjmp    pr_zfl_next
-pr_zfl_end:
-       pop     zh
-       pop     zl      
-
-       printstring "  A ="
-       mov     temp,z_a
-       rcall   printhex        
-       printstring " BC ="
-       lds     temp2,z_b
-       lds     temp, z_c
-       rcall   printhexw
-       printstring " DE ="
-       lds     temp2,z_d
-       lds     temp, z_e
-       rcall   printhexw
-       printstring " HL ="
-       lds     temp2,z_h
-       lds     temp, z_l
-       rcall   printhexw
-       printstring " SP ="
-       movw    temp, z_spl
-       rcall   printhexw
-       printstring " PC ="
-       movw    temp, z_pcl
-       rcall   printhexw
-       printstring "       "
-       movw    xl,z_pcl
-       mem_read
-       rcall   printhex
-       printstring " "
-       adiw    x,1
-       mem_read
-       rcall   printhex
-       printstring " "
-       adiw    x,1
-       mem_read
-       rcall   printhex
-       printstring " "
-       ret
-;.endif
-
+; vim:set ts=8 noet nowrap
 
diff --git a/avrcpm/avr/utils.asm b/avrcpm/avr/utils.asm
new file mode 100644 (file)
index 0000000..5a6efef
--- /dev/null
@@ -0,0 +1,223 @@
+;    Print and Debug functions
+;
+;    Copyright (C) 2010 Leo C.
+;
+;    This file is part of avrcpm.
+;
+;    avrcpm is free software: you can redistribute it and/or modify it
+;    under the terms of the GNU General Public License as published by
+;    the Free Software Foundation, either version 3 of the License, or
+;    (at your option) any later version.
+;
+;    avrcpm is distributed in the hope that it will be useful,
+;    but WITHOUT ANY WARRANTY; without even the implied warranty of
+;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;    GNU General Public License for more details.
+;
+;    You should have received a copy of the GNU General Public License
+;    along with avrcpm.  If not, see <http://www.gnu.org/licenses/>.
+;
+;    $Id$
+;
+
+
+       .cseg
+
+
+;Print a unsigned lonng value to the uart
+; temp4:temp3:temp2:temp = value
+
+print_ultoa:
+       push    yh
+       push    yl
+       push    z_flags
+       push    temp4
+       push    temp3
+       push    temp2
+       push    temp
+                               
+       clr     yl              ;yl = stack level
+
+ultoa1:        ldi     z_flags, 32     ;yh = temp4:temp % 10
+       clr     yh              ;temp4:temp /= 10
+ultoa2:        lsl     temp    
+       rol     temp2   
+       rol     temp3   
+       rol     temp4   
+       rol     yh      
+       cpi     yh,10   
+       brcs    ultoa3  
+       subi    yh,10   
+       inc     temp
+ultoa3:        dec     z_flags 
+       brne    ultoa2
+       cpi     yh, 10  ;yh is a numeral digit '0'-'9'
+       subi    yh, -'0'
+       push    yh              ;Stack it
+       inc     yl      
+       cp      temp,_0         ;Repeat until temp4:temp gets zero
+       cpc     temp2,_0
+       cpc     temp3,_0
+       cpc     temp4,_0
+       brne    ultoa1  
+       
+       ldi     temp, '0'
+ultoa5:        cpi     yl,3            ; at least 3 digits (ms)
+       brge    ultoa6
+       push    temp    
+       inc     yl
+       rjmp    ultoa5
+
+ultoa6:        pop     temp            ;Flush stacked digits
+       rcall   uartputc
+       dec     yl      
+       brne    ultoa6  
+
+       pop     temp
+       pop     temp2
+       pop     temp3
+       pop     temp4
+       pop     z_flags
+       pop     yl
+       pop     yh
+       ret
+
+
+;Prints temp2:temp in hex to the uart
+printhexw:
+       push    temp
+       mov     temp,temp2
+       rcall   printhex
+       pop     temp
+       ;fall thru
+
+;Prints temp in hex to the uart
+printhex:
+       swap temp
+       rcall printhexn
+       swap temp       
+       ;fall thru
+
+;Prints the lower nibble
+printhexn:
+       push temp
+       andi temp,0xf
+       cpi temp,0xA
+       brlo printhexn_isno
+       subi temp,-7
+printhexn_isno:
+       subi temp,-'0'
+       rcall uartputc
+       pop temp
+       ret
+
+;Prints the zero-terminated string following the call statement. 
+
+printstr:
+       push    zh
+       push    zl
+       push    yh
+       push    yl
+       push    temp
+       in      yh,sph
+       in      yl,spl
+       ldd     zl,y+7
+       ldd     zh,y+6
+
+       lsl zl
+       rol zh
+printstr_loop:
+       lpm temp,z+
+       cpi temp,0
+       breq printstr_end
+       rcall uartputc
+       cpi temp,13
+       brne printstr_loop
+       ldi temp,10
+       rcall uartputc
+       rjmp printstr_loop
+
+printstr_end:
+       adiw zl,1               ;rounding
+       lsr zh
+       ror zl
+
+       std     y+7,zl
+       std     y+6,zh
+       pop     temp
+       pop     yl
+       pop     yh
+       pop     zl
+       pop     zh
+       ret
+       
+; --------------- Debugging stuff ---------------
+; Print a line with the Z80 main registers
+
+;.if INS_DEBUG
+
+zflags_to_ch:
+       .db     "SZ H PNC",0,0
+       
+printregs:
+       printnewline
+
+       push    zl
+       push    zh
+       ldiw    z,zflags_to_ch*2
+       mov     temp2,z_flags
+pr_zfl_next:
+       lpm     temp,z+
+       tst     temp
+       breq    pr_zfl_end
+       cpi     temp,' '                        ; Test if no flag
+       breq    pr_zfl_noflag
+       sbrs    temp2,7                 ; 
+        ldi    temp,' '                        ; Flag not set
+       rcall   uartputc
+pr_zfl_noflag:
+       rol     temp2
+       rjmp    pr_zfl_next
+pr_zfl_end:
+       pop     zh
+       pop     zl      
+
+       printstring "  A ="
+       mov     temp,z_a
+       rcall   printhex        
+       printstring " BC ="
+       lds     temp2,z_b
+       lds     temp, z_c
+       rcall   printhexw
+       printstring " DE ="
+       lds     temp2,z_d
+       lds     temp, z_e
+       rcall   printhexw
+       printstring " HL ="
+       lds     temp2,z_h
+       lds     temp, z_l
+       rcall   printhexw
+       printstring " SP ="
+       movw    temp, z_spl
+       rcall   printhexw
+       printstring " PC ="
+       movw    temp, z_pcl
+       rcall   printhexw
+       printstring "       "
+       movw    xl,z_pcl
+       mem_read
+       rcall   printhex
+       printstring " "
+       adiw    x,1
+       mem_read
+       rcall   printhex
+       printstring " "
+       adiw    x,1
+       mem_read
+       rcall   printhex
+       printstring " "
+       ret
+;.endif
+
+; vim:set ts=8 noet nowrap
+