get.hexdigit: ld a,(de) ;0d25 sub_0d26h: cp 'F'+1 ;0d26 l0d28h: ccf ;0d28 ret c ;0d29 cp 'A' ;0d2a jr c,l0d32h ;0d2c sub 'A'-10 ;0d2e ret ;0d30 get.decdigit: ld a,(de) ;0d31 l0d32h: cp '9'+1 ;0d32 jr l0d39h ;0d34 get.bindigit: ld a,(de) ;0d36 cp '1'+1 ;0d37 l0d39h: ccf ;0d39 ret c ;0d3a cp '0' ;0d3b ret c ;0d3d sub '0' ;0d3e ret ;0d40 ; Read Intel Hex File from console. CMD.R: ld hl,0 ;169b call get_lastarg_def ;169e get offset from command line push hl ;16a1 ld hl,0 ;16a2 ld (HILOD),hl ;16a5 w_recstart: call i.getchar ;16a8 jr z,l16deh ;16ab cp ':' ;16ad jr nz,w_recstart ;16af ld c,0 ;16b1 init checksum call i.gethexbyte ;16b3 record len ld b,a ;16b6 call i.gethexbyte ;16b7 address high ld h,a ;16ba call i.gethexbyte ;16bb address low ld l,a ;16be call i.gethexbyte ;16bf record type (ignored) ld a,b ;16c2 and a ;16c3 record len == 0? jr z,l16deh ;16c4 l16c6h: call i.gethexbyte ;16c6 pop de ;16c9 offset push de ;16ca push hl ;16cb add hl,de ;16cc call i.storebyte ;16cd pop hl ;16d0 inc hl ;16d1 djnz l16c6h ;16d2 repeat for record len call i.gethexbyte ;16d4 checksum ld a,c ;16d7 and a ;16d8 jp nz,ERROR ;16d9 exit if checksum error jr w_recstart ;16dc next record l16deh: pop hl ;16de call i.gethexbyte ;16df jp l173fh ;16e2 i.gethexbyte: call sub_16f6h ;16e5 rlca ;16e8 rlca ;16e9 rlca ;16ea rlca ;16eb ld d,a ;16ec call sub_16f6h ;16ed add a,d ;16f0 ld d,a ;16f1 add a,c ;16f2 ld c,a ;16f3 ld a,d ;16f4 ret ;16f5 sub_16f6h: call i.getchar ;16f6 jr z,l16ffh ;16f9 call sub_0d26h ;16fb ret nc ;16fe l16ffh: jp ERROR ;16ff i.getchar: call $ci ;1702 cp 01ah ;1705 ret ;1707 i.storebyte: push af ;1708 push de ;1709 ld de,TPA ;170a lowest allowed load address call CP.HL.DE ;170d jp c,ERROR ;1710 ld de,$stcka ;1713 highest allowed load address call CP.HL.DE ;1716 jp nc,ERROR ;1719 ld de,(HILOD) ;171c call CP.HL.DE ;1720 jr c,l1728h ;1723 ld (HILOD),hl ;1725 l1728h: ld de,(MAXLOD) ;1728 call CP.HL.DE ;172c jr c,l1734h ;172f ld (MAXLOD),hl ;1731 l1734h: pop de ;1734 pop af ;1735 comst ;1736 ld (hl),a ;173a store byte comend ret ;173b l173ch: call assert_eol ;173c l173fh: ld hl,MSG_high ;173f call PSTR ;1742 ld hl,(HILOD) ;1745 call out.hl ;1748 ld hl,MSG_max ;174b call PSTR ;174e ld hl,(MAXLOD) ;1751 call out.hl ;1754 jp CRLF ;1757 MSG_high: DC 'High = ' MSG_max: DC ' Max = '