📄 main.asm
字号:
;----------------------------
; CPU : uPD789166
; Clock : 4.00MHz
; System : hvft
; Date : 2005/05/26
;----------------------------
;----------------------------
; Const Table here
;----------------------------
;----------------------------
; Vector table here
;----------------------------
$PROCESSOR(9166)
$NODEBUGA
$KANJICODE SJIS
$TOL_INF 2FH,100H,0,0FFFFH
$DGS FIL_NAM, .file, U, 0FFFEH, 2FH, 67H, 1, 0
$DGS AUX_FIL, main.s
$DGL 0,16
VtTab0 Cseg At 0000h ; VtTab0 Cseg At 0000h
$DGL 0,17
Dw start ; Dw start ;reset adress
;---------------------------
$DGL 0,20
VtTab1 Cseg At 0004h ; VtTab1 Cseg At 0004h
$DGL 0,21
Dw start ; Dw start ;intwdt 0004h-0005h
$DGL 0,22
Dw intp0 ; Dw intp0 ;intp0 0006h-0007h
$DGL 0,23
Dw intp1 ; Dw intp1 ;intp1 0008h-0009h
$DGL 0,24
Dw intp2 ; Dw intp2 ;intp2 000ah-000bh
$DGL 0,25
Dw start ; Dw start ;intp3 000ch-000dh
$DGL 0,26
Dw start ; Dw start ;intsr20 000eh-000fh
$DGL 0,27
Dw start ; Dw start ;intst20 0010h-0011h
$DGL 0,28
Dw start ; Dw start ;intwt 0012h-0013h
$DGL 0,29
Dw intwti ; Dw intwti ;intwti 0014h-0015h
$DGL 0,30
Dw start ; Dw start ;inttm80 0016h-0017h buz
$DGL 0,31
Dw inttm81 ; Dw inttm81 ;inttm81 0018h-0019h remo timer
$DGL 0,32
Dw inttm82 ; Dw inttm82 ;inttm82 001ah-001bh timer
$DGL 0,33
Dw inttm90 ; Dw inttm90 ;inttm90 001ch-001dh fan speed ctrl
;---------------------------
$DGL 0,35
VtTab2 Cseg At 0022h ; VtTab2 Cseg At 0022h
$DGL 0,36
DW start ; DW start ;intad0 00
;Vector table end here
;___________________________________
; RAM Area here
; UserRam dseg At 0fe20h
$DGL 0,44
extrn _main ;extrn _main
;___________________________________
$DGL 0,47
MainPro Cseg At 0080h ; MainPro Cseg At 0080h
$DGL 0,49
start: ;start:
$DGL 0,50
nop ; nop
$DGL 0,51
nop ; nop
$DGL 0,52
nop ; nop
$DGL 0,53
nop ; nop
$DGL 0,54
nop ; nop
$DGL 0,55
di ; di
$DGL 0,56
MOV PCC,#00h ; PCC = #00h ; /* Page85 */
$DGL 0,57
MOVW ax,#0fe20h ; ax = #0fe20h
$DGL 0,58
MOVW sp,ax ; sp = ax
$DGL 0,59
nop ; nop
$DGL 0,60
nop ; nop
$DGL 0,61
MOV a,#0 ; for (a=#0; a<#50; a++)
?L1:
CMP a,#50
BNC $?L2
$DGL 0,62
nop ; nop
INC a
BR ?L1
$DGL 0,63
?L2: ; next
$DGL 0,65
nop ; nop
$DGL 0,66
DI ; DI
$DGL 0,67
MOV PCC,#00h ; PCC = #00h ; /* Page85 */
$DGL 0,68
MOVW ax,#0fe20h ; ax = #0fe20h
$DGL 0,69
MOVW sp,ax ; sp = ax
$DGL 0,71
mov a,0fe20h ; mov a,0fe20h ;the variable data
$DGL 0,72
xor a,0fe21h ; xor a,0fe21h
$DGL 0,73
xor a,0fe22h ; xor a,0fe22h
$DGL 0,74
mov d,a ; mov d,a
;___________________________________
$DGL 0,78
movw hl,#0fd00h ; movw hl,#0fd00h ;clear ram:0fd00h-0fdffh
$DGL 0,79
mov a,#00h ; mov a,#00h
$DGL 0,80
ramclr1: ;ramclr1:
$DGL 0,81
mov [hl],a ; mov [hl],a
$DGL 0,82
inc l ; inc l
$DGL 0,83
bnz $ramclr1 ; bnz $ramclr1
$DGL 0,85
mov a,#00 ; mov a,#00
$DGL 0,86
movw hl,#0fedfh ; movw hl,#0fedfh
$DGL 0,87
ramclr2: ;ramclr2:
$DGL 0,88
mov [hl],a ; mov [hl],a
$DGL 0,89
dec l ; dec l
$DGL 0,90
bnz $ramclr2 ; bnz $ramclr2
$DGL 0,92
extrn _E2RomWork ; extrn _E2RomWork
$DGL 0,93
mov a,d ; mov a,d
$DGL 0,94
mov _E2RomWork,a ; mov _E2RomWork,a ;the E2PRom test data
;___________________________________
$DGL 0,97
loop: ;loop:
$DGL 0,98
nop ; nop
$DGL 0,99
nop ; nop
$DGL 0,100
call !_main ; call !_main
$DGL 0,101
nop ; nop
$DGL 0,102
nop ; nop
$DGL 0,103
BR loop ; goto loop
$DGL 0,104
nop ; nop
$DGL 0,105
nop ; nop
$DGL 0,106
BR loop ; goto loop
;___________________________________
$DGL 0,110
extrn _int_tm90 ;extrn _int_tm90
$DGL 0,111
inttm90: ;inttm90:
$DGL 0,113
push ax ; push ax
$DGL 0,114
push bc ; push bc
$DGL 0,115
push de ; push de
$DGL 0,116
push hl ; push hl
$DGL 0,118
call !_int_tm90 ; call !_int_tm90
$DGL 0,120
pop hl ; pop hl
$DGL 0,121
pop de ; pop de
$DGL 0,122
pop bc ; pop bc
$DGL 0,123
pop ax ; pop ax
$DGL 0,125
reti ; reti
;___________________________________
$DGL 0,128
extrn _int_wti ;extrn _int_wti
$DGL 0,129
intwti: ;intwti:
$DGL 0,130
push ax ; push ax
$DGL 0,131
push bc ; push bc
$DGL 0,132
push de ; push de
$DGL 0,133
push hl ; push hl
$DGL 0,135
call !_int_wti ; call !_int_wti
$DGL 0,137
pop hl ; pop hl
$DGL 0,138
pop de ; pop de
$DGL 0,139
pop bc ; pop bc
$DGL 0,140
pop ax ; pop ax
$DGL 0,143
reti ; reti
;___________________________________
$DGL 0,146
extrn _int_tm81 ;extrn _int_tm81
$DGL 0,147
inttm81: ;inttm81:
$DGL 0,148
push ax ; push ax
$DGL 0,149
push bc ; push bc
$DGL 0,150
push de ; push de
$DGL 0,151
push hl ; push hl
$DGL 0,153
call !_int_tm81 ; call !_int_tm81
$DGL 0,155
pop hl ; pop hl
$DGL 0,156
pop de ; pop de
$DGL 0,157
pop bc ; pop bc
$DGL 0,158
pop ax ; pop ax
$DGL 0,161
reti ; reti
;___________________________________
$DGL 0,164
extrn _int_tm82 ;extrn _int_tm82
$DGL 0,165
inttm82: ;inttm82:
$DGL 0,166
push ax ; push ax
$DGL 0,167
push bc ; push bc
$DGL 0,168
push de ; push de
$DGL 0,169
push hl ; push hl
$DGL 0,171
call !_int_tm82 ; call !_int_tm82
$DGL 0,173
pop hl ; pop hl
$DGL 0,174
pop de ; pop de
$DGL 0,175
pop bc ; pop bc
$DGL 0,176
pop ax ; pop ax
$DGL 0,179
reti ; reti
;___________________________________
$DGL 0,182
extrn _int_p0 ;extrn _int_p0
$DGL 0,183
intp0: ;intp0:
$DGL 0,184
push ax ; push ax
$DGL 0,185
push bc ; push bc
$DGL 0,186
push de ; push de
$DGL 0,187
push hl ; push hl
$DGL 0,189
call !_int_p0 ; call !_int_p0
$DGL 0,191
pop hl ; pop hl
$DGL 0,192
pop de ; pop de
$DGL 0,193
pop bc ; pop bc
$DGL 0,194
pop ax ; pop ax
$DGL 0,196
reti ; reti
;___________________________________
$DGL 0,199
extrn _int_p1 ;extrn _int_p1
$DGL 0,200
intp1: ;intp1:
$DGL 0,201
push ax ; push ax
$DGL 0,202
push bc ; push bc
$DGL 0,203
push de ; push de
$DGL 0,204
push hl ; push hl
$DGL 0,206
call !_int_p1 ; call !_int_p1
$DGL 0,208
pop hl ; pop hl
$DGL 0,209
pop de ; pop de
$DGL 0,210
pop bc ; pop bc
$DGL 0,211
pop ax ; pop ax
$DGL 0,213
reti ; reti
;___________________________________
$DGL 0,216
extrn _int_p2 ;extrn _int_p2
$DGL 0,217
intp2: ;intp2:
$DGL 0,218
push ax ; push ax
$DGL 0,219
push bc ; push bc
$DGL 0,220
push de ; push de
$DGL 0,221
push hl ; push hl
$DGL 0,223
call !_int_p2 ; call !_int_p2
$DGL 0,225
pop hl ; pop hl
$DGL 0,226
pop de ; pop de
$DGL 0,227
pop bc ; pop bc
$DGL 0,228
pop ax ; pop ax
$DGL 0,230
reti ; reti
;___________________________________
;-----------------------------
; 32位/16位乘法
;入口参数:[Gao16bit+1][Gao16bit][Di16bit+1][Di16bit] / [ChuShu16bit+1][ChuShu16bit]
;结果 :[Di16bit+1][Di16bit]
;余数 :[Gao16bit+1][Gao16bit]
;extrn _divcnt
$DGL 0,241
extrn _tempa ;extrn _tempa
$DGL 0,242
extrn _Gao16bit,_Di16bit,_ChuShu16bit ;extrn _Gao16bit,_Di16bit,_ChuShu16bit
$DGL 0,243
extbit _F0 ;extbit _F0
$DGL 0,245
public _div32_16 ;public _div32_16
; [bc][de] / [hl]
$DGL 0,248
_div32_16: ;_div32_16:
$DGL 0,249
movw ax,_Di16bit ; movw ax,_Di16bit
$DGL 0,250
movw de,ax ; movw de,ax
$DGL 0,251
movw ax,_Gao16bit ; movw ax,_Gao16bit
$DGL 0,252
movw bc,ax ; movw bc,ax
$DGL 0,253
movw ax,_ChuShu16bit ; movw ax,_ChuShu16bit
$DGL 0,254
movw hl,ax ; movw hl,ax
; mov _divcnt,#16
$DGL 0,257
mov _tempa,#16 ; mov _tempa,#16
$DGL 0,259
mov a,c ; mov a,c ; [bc] < [hl] ?
$DGL 0,260
sub a,l ; sub a,l
$DGL 0,261
mov a,b ; mov a,b
$DGL 0,262
subc a,h ; subc a,h
$DGL 0,263
bc $divon16 ; bc $divon16
$DGL 0,264
set1 _F0 ; set1 _F0
$DGL 0,265
ret ; ret
$DGL 0,266
divon16: ;divon16:
$DGL 0,267
clr1 cy ; clr1 cy
$DGL 0,268
mov a,e ; mov a,e
$DGL 0,269
rolc a,1 ; rolc a,1
$DGL 0,270
mov e,a ; mov e,a
$DGL 0,272
mov a,d ; mov a,d
$DGL 0,273
rolc a,1 ; rolc a,1
$DGL 0,274
mov d,a ; mov d,a
$DGL 0,276
mov a,c ; mov a,c
$DGL 0,277
rolc a,1 ; rolc a,1
$DGL 0,278
mov c,a ; mov c,a
$DGL 0,280
xch a,b ; xch a,b
$DGL 0,281
rolc a,1 ; rolc a,1
$DGL 0,282
xch a,b ; xch a,b
;mov1 _F0,cy
$DGL 0,286
clr1 _F0 ; clr1 _F0
$DGL 0,287
BNC $?L3 ; if_bit (cy)
$DGL 0,288
set1 _F0 ; set1 _F0
$DGL 0,289
?L3: ; endif
$DGL 0,291
clr1 cy ; clr1 cy
$DGL 0,292
sub a,l ; sub a,l
$DGL 0,293
mov x,a ; mov x,a
$DGL 0,294
mov a,b ; mov a,b
$DGL 0,295
subc a,h ; subc a,h
$DGL 0,296
bt _F0,$divsucc16 ; bt _F0,$divsucc16
$DGL 0,297
bc $ndvd32 ; bc $ndvd32
$DGL 0,298
divsucc16: ;divsucc16:
$DGL 0,299
mov b,a ; mov b,a
$DGL 0,300
mov a,x ; mov a,x
$DGL 0,301
mov c,a ; mov c,a
$DGL 0,302
inc e ; inc e
$DGL 0,303
ndvd32: ;ndvd32:
; dec _divcnt
$DGL 0,305
dec _tempa ; dec _tempa
$DGL 0,307
bnz $divon16 ; bnz $divon16
$DGL 0,308
clr1 _F0 ; clr1 _F0
$DGL 0,311
movw ax,de ; movw ax,de
$DGL 0,312
movw _Di16bit,ax ; movw _Di16bit,ax
$DGL 0,314
movw ax,bc ; movw ax,bc
$DGL 0,315
movw _Gao16bit,ax ; movw _Gao16bit,ax
$DGL 0,317
ret ; ret
;-------------------------------
$DGL 0,319
public _div16_8 ;public _div16_8
;[Gao8bit][Di8bit] / [ChuShu8bit]
;[Di8bit] : result
;[Gao8bit] : remainder
$DGL 0,326
extrn _Gao8bit,_Di8bit,_ChuShu8bit ;extrn _Gao8bit,_Di8bit,_ChuShu8bit
$DGL 0,329
_div16_8: ;_div16_8: ; word / byte
$DGL 0,331
mov b,#8 ; mov b,#8
$DGL 0,332
mov a,_Gao8bit ; mov a,_Gao8bit
$DGL 0,333
sub a,_ChuShu8bit ; sub a,_ChuShu8bit
$DGL 0,335
bc $divon ; bc $divon
$DGL 0,336
set1 _F0 ; set1 _F0
$DGL 0,337
ret ; ret
$DGL 0,338
divon: ;divon:
$DGL 0,340
clr1 cy ; clr1 cy
$DGL 0,341
mov a,_Di8bit ; mov a,_Di8bit
$DGL 0,342
rolc a,1 ; rolc a,1
$DGL 0,343
mov _Di8bit,a ; mov _Di8bit,a
$DGL 0,345
mov a,_Gao8bit ; mov a,_Gao8bit
$DGL 0,346
rolc a,1 ; rolc a,1
$DGL 0,347
mov _Gao8bit,a ; mov _Gao8bit,a
$DGL 0,349
clr1 _F0 ; clr1 _F0
$DGL 0,350
BNC $?L4 ; if_bit (cy)
$DGL 0,351
set1 _F0 ; set1 _F0
$DGL 0,352
?L4: ; endif
$DGL 0,354
clr1 cy ; clr1 cy
$DGL 0,355
sub a,_ChuShu8bit ; sub a,_ChuShu8bit
$DGL 0,357
bt _F0,$divsucc ; bt _F0,$divsucc
$DGL 0,358
bc $ndvd1 ; bc $ndvd1
$DGL 0,359
divsucc: ;divsucc:
$DGL 0,361
mov _Gao8bit,a ; mov _Gao8bit,a
$DGL 0,362
inc _Di8bit ; inc _Di8bit
$DGL 0,363
ndvd1: ;ndvd1:
$DGL 0,364
dbnz b,$divon ; dbnz b,$divon
$DGL 0,366
clr1 _F0 ; clr1 _F0
$DGL 0,368
ret ; ret
;___________________________________
$DGL 0,371
end ; end
; Target chip : uPD789166
; Device file : V1.01
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -