-
Notifications
You must be signed in to change notification settings - Fork 0
/
asmtohex.asm
141 lines (140 loc) · 2.01 KB
/
asmtohex.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include "ti86.inc"
;Source code for ASM to HEX - editable
;Size on calculator: 323 bytes
OutputProgram =$8100
.org _asm_exec_ram
call _clrScrn
call _runindicoff
call _homeup
ld hl,HexStart
ld de,OutputProgram
call _mov9b
call _puts
SearchAgain:
ld hl,$bfff
push hl
SearchLoop:
pop hl
ld a,18
call _RAM_Page_7
ld bc,(_PTEMP_END+1)
or a
push hl
sbc hl,bc
ld b,h
ld c,l
pop hl
cpdr
jp po,SearchAgain
dec hl
dec hl
push hl
ld de,_OP1-1
ld b,10
CopyToOP1Loop:
inc de
dec hl
ld a,(hl)
ld (de),a
djnz CopyToOP1Loop
rst 10h
call _ex_ahl_bde
call _ahl_plus_2_pg3
call _Get_Word_ahl
ld hl,$288e
call _cphlde
jr nz,SearchLoop
ld hl,_OP1+1
ld bc,256*9+1
ld (_curRow),bc
call _putps
call _eraseEOL
Waitkey:
halt
call _getky
cp K_EXIT
jp z,Quit
cp K_RIGHT
jr z,SearchLoop
cp K_ENTER
jr nz,Waitkey
rst 10h
call _ex_ahl_bde
call _Get_Word_ahl
dec de
dec de
ld c,a
ld a,d
cp 31
jr c,NotTooBig
ld bc,256*7+1
ld (_curRow),bc
ld hl,TooBigTxt
pop af
jp _puts
NotTooBig:
ld a,c
ld ix,OutputProgram+9
call _Inc_Ptr_ahl
ConvertLoop:
call _Inc_Ptr_ahl
ld b,a
push hl
call _GetB_AHL
call _RAM_Page_1
call ConvertAToHex
dec de
ld a,d
or e
pop hl
ld a,b
jr nz,ConvertLoop
CreateProgram:
ld hl,OutputName-1
rst 20h
rst 10h
call nc,_delvar
push ix
pop hl
or a
ld de,OutputProgram
sbc hl,de
push hl
call _createprog
call _ex_ahl_bde
call _ahl_plus_2_pg3
call _set_abs_dest_addr
ld hl,$100
ld a,h
call _set_abs_src_addr
xor a
pop hl
call _set_mm_num_bytes
call _mm_ldir
Quit:
pop af
jp _clrScrn
ConvertAToHex:
ld c,a
rrca
rrca
rrca
rrca
call ConvertNibble
ld a,c
ConvertNibble:
and $0f
add a,'0'
cp '9'+1
jr c,ConvertNibbleNow
sub '9'+1-'A'
ConvertNibbleNow:
ld (ix),a
inc ix
ret
OutputName: .db 7,"hexprgm"
HexStart: .db 0,"AsmPrgm",$d6
.db "ASM to HEX- converter"
ProgramTxt: .db "Program:",0
TooBigTxt: .db " is too big! ",0
.end