Annotation of gforth/ec/shex.fs, revision 1.1
1.1 ! pazsan 1: \ shex.fs Output Routines for Motorola S-Records 16jul97jaw
! 2:
! 3: \ this is a extention to cross.fs to save motorola s-records
! 4: \ the first part is generic to output s-records from and to any
! 5: \ destination
! 6: \ the second part is for the cross compiler
! 7:
! 8: unlock >CROSS
! 9:
! 10: decimal
! 11:
! 12: \ only method to get information
! 13: defer @byte ' c@ IS @byte
! 14:
! 15: \ only method to output
! 16: defer htype ' type IS htype
! 17:
! 18: : hemit pad c! pad 1 htype ;
! 19: : hcr #lf hemit ;
! 20:
! 21: : .## ( c -- ) base @ swap hex s>d <# # # #> htype base ! ;
! 22: \ generic checksum support
! 23:
! 24: variable csum
! 25: : csum+ ( c -- c ) dup csum +! ;
! 26: : .b ( c -- ) csum+ .## ;
! 27: : .w ( w -- ) dup 8 rshift .b 255 and .b ;
! 28: : .csum ( -- ) csum @ 255 xor 255 and .b ;
! 29:
! 30: 2 constant adrlen
! 31: 1 constant csumlen
! 32: 32 constant maxline
! 33:
! 34: : .smem ( destadr adr len type -- )
! 35: 'S hemit hemit 0 csum !
! 36: dup adrlen + csumlen + .b
! 37: rot .w
! 38: bounds ?DO I @byte .b LOOP
! 39: .csum hcr ;
! 40:
! 41: : 3dup >r 2dup r@ -rot r> ;
! 42:
! 43: : .sregion ( destadr adr len -- )
! 44: BEGIN dup
! 45: WHILE 3dup maxline min dup >r
! 46: '1 .smem r@ /string rot r> + -rot
! 47: REPEAT drop 2drop ;
! 48:
! 49: : .startaddr ( adr -- )
! 50: 'S hemit '9 hemit 0 csum !
! 51: adrlen csumlen + .b
! 52: .w .csum hcr ;
! 53:
! 54: \ specific for cross-compiler
! 55:
! 56: 0 value fd
! 57: : (htype) fd write-file throw ;
! 58: ' (htype) IS htype
! 59:
! 60: : tc@ X c@ ;
! 61: ' tc@ IS @byte
! 62:
! 63: variable start-addr
! 64:
! 65: : save-region-shex ( adr len -- )
! 66: bl parse w/o create-file throw to fd
! 67:
! 68: \ PSC1000 trick:
! 69: 'E hemit
! 70: 2dup over swap 200 min .sregion
! 71:
! 72: over swap .sregion
! 73: start-addr @ .startaddr
! 74: fd close-file throw ;
! 75:
! 76: >MINIMAL
! 77:
! 78: : cpu-start start-addr ! ;
! 79: : save-region-shex save-region-shex ;
! 80:
! 81: >CROSS
! 82:
! 83: lock
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>