OpenCores
URL https://opencores.org/ocsvn/light8080/light8080/trunk

Subversion Repositories light8080

[/] [light8080/] [trunk/] [c/] [HELLO.LST] - Blame information for rev 89

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 65 motilito
AS80 Assembler for i8080-Z180 [1.11].                                Page    1
2
--------------------------------- HELLO.ASM ----------------------------------
3
 
4
-------------------------------- Symbol Table --------------------------------
5
 
6
              Symbol   Value        Decimal
7
 
8 66 motilito
               ccand : $0064            100
9
               ccasl : $00d4            212
10
               ccasr : $00c6            198
11
             ccbcneg : $0157            343
12
               cccmp : $0091            145
13
           cccmpbcde : $0167            359
14
              cccmp1 : $009e            158
15
               cccom : $00e7            231
16
             ccdeneg : $014f            335
17
               ccdiv : $010e            270
18
              ccdiv1 : $0124            292
19
              ccdiv2 : $013b            315
20
              ccdiv3 : $0144            324
21
                cceq : $006b            107
22
             ccgchar : $0042             66
23
                ccge : $0085            133
24
              ccgint : $0048             72
25
                ccgt : $0077            119
26
                ccle : $007e            126
27
                cclt : $008b            139
28
              ccmult : $00ee            238
29
             ccmult1 : $00f3            243
30
                ccne : $0071            113
31
               ccneg : $00e2            226
32
                ccor : $0056             86
33
             ccpchar : $004d             77
34
              ccpint : $0050             80
35
              ccrdel : $015f            351
36
               ccsub : $00db            219
37
               ccsxt : $0043             67
38
              ccucmp : $00bb            187
39
               ccuge : $00a1            161
40
               ccugt : $00ad            173
41
               ccule : $00b4            180
42
               ccult : $00a7            167
43
               ccxor : $005d             93
44
                 cc1 : $03d0            976
45
                cc10 : $02bb            699
46
                cc11 : $0310            784
47
                cc12 : $0322            802
48
                cc13 : $03b1            945
49
                cc14 : $03cf            975
50
                cc15 : $03cc            972
51
                 cc2 : $016c            364
52
                 cc3 : $0181            385
53
                 cc4 : $01ae            430
54
                 cc5 : $01b2            434
55
                 cc6 : $01c4            452
56
                 cc7 : $01f4            500
57
                 cc8 : $0224            548
58
                 cc9 : $0262            610
59
           __getbyte : $018c            396
60
          __int0_isr : $0324            804
61
              __main : $0330            816
62
                __nl : $01b3            435
63
            __outint : $0231            561
64
          __printdec : $01f5            501
65
          __printhex : $028a            650
66 65 motilito
AS80 Assembler for i8080-Z180 [1.11].                                Page    2
67
--------------------------------- HELLO.ASM ----------------------------------
68
 
69 66 motilito
          __printstr : $01c4            452
70
            __rxbyte : $042c           1068
71
          __sendbyte : $016c            364
72
            __tstary : $042d           1069
73 65 motilito
            __8080__ : $0001              1
74
 
75 66 motilito
63 labels used
76 65 motilito
 
77 67 motilito
919 lines read, no errors in pass 1.
78 65 motilito
AS80 Assembler for i8080-Z180 [1.11].                                Page    3
79
--------------------------------- HELLO.ASM ----------------------------------
80
 
81
                        ; <><><>   Small-C  V1.2  DOS--CP/M Cross Compiler   <
82
                        ; <><><><><>   CP/M Large String Space Version   <><><
83
                        ; <><><><><><><><><><>   By Ron Cain   <><><><><><><><
84
                        ;
85
                                code
86
0000 =                          org #0000
87
0000 : 21000c                   ld hl,3072
88
0003 : f9                       ld sp,hl
89 66 motilito
0004 : cd3003                   call __main
90 65 motilito
                        ;//---------------------------------------------------
91
                        ;//     Project:                        light8080 SOC           WiCores Solutions
92
                        ;//
93
                        ;//     File name:                      hello.c                                 (February 04, 2012)
94
                        ;//
95
                        ;//     Writer:                         Moti Litochevski
96
                        ;//
97
                        ;//     Description:
98
                        ;//             This file contains a simple program written in Sm
99
                        ;//             the UART and then switches to echo received bytes
100 66 motilito
                        ;//             This example also include a simple interrupt exam
101
                        ;//             verilog testbench. the testbench
102 65 motilito
                        ;//
103
                        ;//     Revision History:
104
                        ;//
105
                        ;//     Rev                                             
106
                        ;//             
107
                        ;//---------------------------------------------------
108 66 motilito
                        ;// define interrupt vectors
109
                        ;// note that this file must be edited to enable inter
110
                        ;#include intr_vec.h
111
                        ;//---------------------------------------------------
112
                        ;//     Project:                        light8080 SOC           WiCores Solutions
113
                        ;//
114
                        ;//     File name:                      intr_vec.h                      (March 03, 2012)
115
                        ;//
116
                        ;//     Writer:                         Moti Litochevski
117
                        ;//
118
                        ;//     Description:
119
                        ;//             This file contains a simple example of calling in
120
                        ;//             file defines the interrupt vector for external in
121
                        ;//             0x0008. the interrupts vectors addresses are set
122
                        ;//             controller "intr_ctrl.v" file.
123
                        ;//             Code is generated for all 4 supported external in
124
                        ;//             are not called.
125
                        ;//             On execution of an interrupt the CPU will automat
126
                        ;//             enable flag set by the EI instruction. the interr
127
                        ;//             enable the interrupts again after interrupt servi
128
                        ;//             nested interrupts just move the EI instruction to
129
                        ;//             call instruction to the service routine (see comm
130
                        ;//             Note that this code is not optimized in any way.
131
                        ;//             verify the interrupt mechanism of the light8080 C
132
                        ;//
133
                        ;//     Revision History:
134
                        ;//
135
                        ;//     Rev                                             
136
                        ;//             
137
                        ;//---------------------------------------------------
138
                        ;// to support interrupt enable the respective interru
139
                        ;// beginning of the output assembly file. only the in
140
                        ;// should call a valid interrupt service routine name
141
                        ;// C function name should be prefixed by "__".
142
                        ;#asm
143
AS80 Assembler for i8080-Z180 [1.11].                                Page    4
144
--------------------------------- HELLO.ASM ----------------------------------
145
 
146
                        ;Preserve space for interrupt routines
147
                        ;interrupt 0 vector
148
0008 =                          org #0008
149
0008 : f5                       push af
150
0009 : c5                       push bc
151
000a : d5                       push de
152
000b : e5                       push hl
153
                        ;       ei                                      ; to enable nested interrupts uncomment this
154
000c : cd2403                   call __int0_isr
155
000f : e1                       pop hl
156
0010 : d1                       pop de
157
0011 : c1                       pop bc
158
0012 : f1                       pop af
159
0013 : fb                       ei                                      ; interrupt are not enabled during the execut
160
0014 : c9                       ret
161
                        ;interrupt 1 vector
162
0018 =                          org #0018
163
0018 : f5                       push af
164
0019 : c5                       push bc
165
001a : d5                       push de
166
001b : e5                       push hl
167
                        ;       call __int1_isr         ; interrupt not used
168
001c : e1                       pop hl
169
001d : d1                       pop de
170
001e : c1                       pop bc
171
001f : f1                       pop af
172
0020 : fb                       ei
173
0021 : c9                       ret
174
                        ;interrupt 2 vector
175
0028 =                          org #0028
176
0028 : f5                       push af
177
0029 : c5                       push bc
178
002a : d5                       push de
179
002b : e5                       push hl
180
                        ;       call __int2_isr         ; interrupt not used
181
002c : e1                       pop hl
182
002d : d1                       pop de
183
002e : c1                       pop bc
184
002f : f1                       pop af
185
0030 : fb                       ei
186
0031 : c9                       ret
187
                        ;interrupt 3 vector
188
0038 =                          org #0038
189
0038 : f5                       push af
190
0039 : c5                       push bc
191
003a : d5                       push de
192
003b : e5                       push hl
193
                        ;       call __int3_isr         ; interrupt not used
194
003c : e1                       pop hl
195
003d : d1                       pop de
196
003e : c1                       pop bc
197
003f : f1                       pop af
198
0040 : fb                       ei
199
0041 : c9                       ret
200
                        ;//---------------------------------------------------
201
                        ;//                                             Th.. Th.. Th.. Thats all folks !!!
202
                        ;//---------------------------------------------------
203
                        ;// insert c80 assmbly library to the output file
204 65 motilito
                        ;#include ..\tools\c80\c80.lib
205
                        ;#asm
206
                        ;
207
                        ;-----------------------------------------------------
208 66 motilito
AS80 Assembler for i8080-Z180 [1.11].                                Page    5
209
--------------------------------- HELLO.ASM ----------------------------------
210
 
211 65 motilito
                        ;       Small-C  Run-time Librray
212
                        ;
213
                        ;       V4d     As of July 16, 1980 (gtf)
214
                        ;                  Added EXIT() function
215
                        ;-----------------------------------------------------
216
                        ;
217
                        ;Fetch a single byte from the address in HL and sign e
218 66 motilito
0042 :                  ccgchar:
219
0042 : 7e                       ld a,(hl)
220
0043 :                  ccsxt:
221
0043 : 6f                       ld l,a
222
0044 : 07                       rlca
223
0045 : 9f                       sbc     a
224
0046 : 67                       ld      h,a
225
0047 : c9                       ret
226 65 motilito
                        ;Fetch a full 16-bit integer from the address in HL
227 66 motilito
0048 :                  ccgint:
228
0048 : 7e                       ld a,(hl)
229
0049 : 23                       inc     hl
230
004a : 66                       ld      h,(hl)
231
004b : 6f                       ld l,a
232
004c : c9                       ret
233 65 motilito
                        ;Store a single byte from HL at the address in DE
234 66 motilito
004d :                  ccpchar:
235
004d : 7d                       ld      a,l
236
004e : 12                       ld      (de),a
237
004f : c9                       ret
238 65 motilito
                        ;Store a 16-bit integer in HL at the address in DE
239 66 motilito
0050 :                  ccpint:
240
0050 : 7d                       ld      a,l
241
0051 : 12                       ld      (de),a
242
0052 : 13                       inc     de
243
0053 : 7c                       ld      a,h
244
0054 : 12                       ld      (de),a
245
0055 : c9                       ret
246 65 motilito
                        ;Inclusive "or" HL and DE into HL
247 66 motilito
0056 :                  ccor:
248
0056 : 7d                       ld      a,l
249
0057 : b3                       or      e
250
0058 : 6f                       ld l,a
251
0059 : 7c                       ld      a,h
252
005a : b2                       or      d
253
005b : 67                       ld      h,a
254
005c : c9                       ret
255 65 motilito
                        ;Exclusive "or" HL and DE into HL
256 66 motilito
005d :                  ccxor:
257
005d : 7d                       ld      a,l
258
005e : ab                       xor     e
259
005f : 6f                       ld l,a
260
0060 : 7c                       ld      a,h
261
0061 : aa                       xor     d
262
0062 : 67                       ld      h,a
263
0063 : c9                       ret
264 65 motilito
                        ;"And" HL and DE into HL
265 66 motilito
0064 :                  ccand:
266
0064 : 7d                       ld      a,l
267
0065 : a3                       and     e
268
0066 : 6f                       ld l,a
269
0067 : 7c                       ld      a,h
270
0068 : a2                       and     d
271
0069 : 67                       ld      h,a
272
006a : c9                       ret
273
AS80 Assembler for i8080-Z180 [1.11].                                Page    6
274
--------------------------------- HELLO.ASM ----------------------------------
275
 
276 65 motilito
                        ;Test if HL = DE and set HL = 1 if true else 0
277 66 motilito
006b :                  cceq:
278
006b : cd9100                   call cccmp
279
006e : c8                       ret z
280
006f : 2b                       dec     hl
281
0070 : c9                       ret
282 65 motilito
                        ;Test if DE ~= HL
283 66 motilito
0071 :                  ccne:
284
0071 : cd9100                   call cccmp
285
0074 : c0                       ret nz
286
0075 : 2b                       dec     hl
287
0076 : c9                       ret
288 65 motilito
                        ;Test if DE > HL (signed)
289 66 motilito
0077 :                  ccgt:
290
0077 : eb                       ex de,hl
291
0078 : cd9100                   call cccmp
292
007b : d8                       ret c
293
007c : 2b                       dec     hl
294
007d : c9                       ret
295 65 motilito
                        ;Test if DE <= HL (signed)
296 66 motilito
007e :                  ccle:
297
007e : cd9100                   call cccmp
298
0081 : c8                       ret z
299
0082 : d8                       ret c
300
0083 : 2b                       dec hl
301
0084 : c9                       ret
302 65 motilito
                        ;Test if DE >= HL (signed)
303 66 motilito
0085 :                  ccge:
304
0085 : cd9100                   call cccmp
305
0088 : d0                       ret nc
306
0089 : 2b                       dec hl
307
008a : c9                       ret
308 65 motilito
                        ;Test if DE < HL (signed)
309 66 motilito
008b :                  cclt:
310
008b : cd9100                   call cccmp
311
008e : d8                       ret c
312
008f : 2b                       dec hl
313
0090 : c9                       ret
314 65 motilito
                        ; Signed compare of DE and HL
315
                        ; Performs DE - HL and sets the conditions:
316
                        ;       Carry reflects sign of difference (set means DE < HL
317
                        ;       Zero/non-zero set according to equality.
318 66 motilito
0091 :                  cccmp:
319
0091 : 7b                       ld      a,e
320
0092 : 95                       sub     l
321
0093 : 5f                       ld      e,a
322
0094 : 7a                       ld      a,d
323
0095 : 9c                       sbc     h
324
0096 : 210100                   ld      hl,1
325
0099 : fa9e00                   jp      m,cccmp1
326
009c : b3                       or      e       ;"OR" resets carry
327
009d : c9                       ret
328
009e :                  cccmp1:
329
009e : b3                       or      e
330
009f : 37                       scf             ;set carry to signal minus
331
00a0 : c9                       ret
332 65 motilito
                        ;Test if DE >= HL (unsigned)
333 66 motilito
00a1 :                  ccuge:
334
00a1 : cdbb00                   call ccucmp
335
00a4 : d0                       ret nc
336
00a5 : 2b                       dec hl
337
00a6 : c9                       ret
338
AS80 Assembler for i8080-Z180 [1.11].                                Page    7
339
--------------------------------- HELLO.ASM ----------------------------------
340
 
341 65 motilito
                        ;Test if DE < HL (unsigned)
342 66 motilito
00a7 :                  ccult:
343
00a7 : cdbb00                   call ccucmp
344
00aa : d8                       ret c
345
00ab : 2b                       dec hl
346
00ac : c9                       ret
347 65 motilito
                        ;Test if DE > HL (unsigned)
348 66 motilito
00ad :                  ccugt:
349
00ad : eb                       ex de,hl
350
00ae : cdbb00                   call ccucmp
351
00b1 : d8                       ret c
352
00b2 : 2b                       dec hl
353
00b3 : c9                       ret
354 65 motilito
                        ;Test if DE <= HL (unsigned)
355 66 motilito
00b4 :                  ccule:
356
00b4 : cdbb00                   call ccucmp
357
00b7 : c8                       ret z
358
00b8 : d8                       ret c
359
00b9 : 2b                       dec hl
360
00ba : c9                       ret
361 65 motilito
                        ;Routine to perform unsigned compare
362
                        ;carry set if DE < HL
363
                        ;zero/nonzero set accordingly
364 66 motilito
00bb :                  ccucmp:
365
00bb : 7a                       ld      a,d
366
00bc : bc                       cp      h
367
00bd : c2c200                   jp      nz,$+5
368
00c0 : 7b                       ld      a,e
369
00c1 : bd                       cp      l
370
00c2 : 210100                   ld      hl,1
371
00c5 : c9                       ret
372 65 motilito
                        ;Shift DE arithmetically right by HL and return in HL
373 66 motilito
00c6 :                  ccasr:
374
00c6 : eb                       ex      de,hl
375
00c7 : 7c                       ld      a,h
376
00c8 : 17                       rla
377
00c9 : 7c                       ld      a,h
378
00ca : 1f                       rra
379
00cb : 67                       ld      h,a
380
00cc : 7d                       ld      a,l
381
00cd : 1f                       rra
382
00ce : 6f                       ld      l,a
383
00cf : 1d                       dec     e
384
00d0 : c2c700                   jp      nz,ccasr+1
385
00d3 : c9                       ret
386 65 motilito
                        ;Shift DE arithmetically left by HL and return in HL
387 66 motilito
00d4 :                  ccasl:
388
00d4 : eb                       ex      de,hl
389
00d5 : 29                       add     hl,hl
390
00d6 : 1d                       dec     e
391
00d7 : c2d500                   jp      nz,ccasl+1
392
00da : c9                       ret
393 65 motilito
                        ;Subtract HL from DE and return in HL
394 66 motilito
00db :                  ccsub:
395
00db : 7b                       ld      a,e
396
00dc : 95                       sub     l
397
00dd : 6f                       ld l,a
398
00de : 7a                       ld      a,d
399
00df : 9c                       sbc     h
400
00e0 : 67                       ld      h,a
401
00e1 : c9                       ret
402 65 motilito
                        ;Form the two's complement of HL
403 66 motilito
AS80 Assembler for i8080-Z180 [1.11].                                Page    8
404
--------------------------------- HELLO.ASM ----------------------------------
405
 
406
00e2 :                  ccneg:
407
00e2 : cde700                   call cccom
408
00e5 : 23                       inc     hl
409
00e6 : c9                       ret
410 65 motilito
                        ;Form the one's complement of HL
411 66 motilito
00e7 :                  cccom:
412
00e7 : 7c                       ld      a,h
413
00e8 : 2f                       cpl
414
00e9 : 67                       ld      h,a
415
00ea : 7d                       ld      a,l
416
00eb : 2f                       cpl
417
00ec : 6f                       ld l,a
418
00ed : c9                       ret
419 65 motilito
                        ;Multiply DE by HL and return in HL
420 66 motilito
00ee :                  ccmult:
421
00ee : 44                       ld      b,h
422
00ef : 4d                       ld      c,l
423
00f0 : 210000                   ld      hl,0
424
00f3 :                  ccmult1:
425
00f3 : 79                       ld      a,c
426
00f4 : 0f                       rrca
427
00f5 : d2f900                   jp      nc,$+4
428
00f8 : 19                       add     hl,de
429
00f9 : af                       xor     a
430
00fa : 78                       ld      a,b
431
00fb : 1f                       rra
432
00fc : 47                       ld      b,a
433
00fd : 79                       ld      a,c
434
00fe : 1f                       rra
435
00ff : 4f                       ld      c,a
436
0100 : b0                       or      b
437
0101 : c8                       ret z
438
0102 : af                       xor     a
439
0103 : 7b                       ld      a,e
440
0104 : 17                       rla
441
0105 : 5f                       ld      e,a
442
0106 : 7a                       ld      a,d
443
0107 : 17                       rla
444
0108 : 57                       ld      d,a
445
0109 : b3                       or      e
446
010a : c8                       ret z
447
010b : c3f300                   jp      ccmult1
448 65 motilito
                        ;Divide DE by HL and return quotient in HL, remainder
449 66 motilito
010e :                  ccdiv:
450
010e : 44                       ld      b,h
451
010f : 4d                       ld      c,l
452
0110 : 7a                       ld      a,d
453
0111 : a8                       xor     b
454
0112 : f5                       push af
455
0113 : 7a                       ld      a,d
456
0114 : b7                       or      a
457
0115 : fc4f01                   call m,ccdeneg
458
0118 : 78                       ld      a,b
459
0119 : b7                       or      a
460
011a : fc5701                   call m,ccbcneg
461
011d : 3e10                     ld      a,16
462
011f : f5                       push af
463
0120 : eb                       ex      de,hl
464
0121 : 110000                   ld      de,0
465
0124 :                  ccdiv1:
466
0124 : 29                       add hl,hl
467
0125 : cd5f01                   call ccrdel
468
AS80 Assembler for i8080-Z180 [1.11].                                Page    9
469 65 motilito
--------------------------------- HELLO.ASM ----------------------------------
470
 
471 66 motilito
0128 : ca3b01                   jp      z,ccdiv2
472
012b : cd6701                   call cccmpbcde
473
012e : fa3b01                   jp      m,ccdiv2
474
0131 : 7d                       ld      a,l
475
0132 : f601                     or      1
476
0134 : 6f                       ld l,a
477
0135 : 7b                       ld      a,e
478
0136 : 91                       sub     c
479
0137 : 5f                       ld      e,a
480
0138 : 7a                       ld      a,d
481
0139 : 98                       sbc     b
482
013a : 57                       ld      d,a
483
013b :                  ccdiv2:
484
013b : f1                       pop af
485
013c : 3d                       dec     a
486
013d : ca4401                   jp      z,ccdiv3
487
0140 : f5                       push af
488
0141 : c32401                   jp      ccdiv1
489
0144 :                  ccdiv3:
490
0144 : f1                       pop af
491
0145 : f0                       ret     p
492
0146 : cd4f01                   call ccdeneg
493
0149 : eb                       ex de,hl
494
014a : cd4f01                   call ccdeneg
495
014d : eb                       ex de,hl
496
014e : c9                       ret
497
014f :                  ccdeneg:
498
014f : 7a                       ld      a,d
499
0150 : 2f                       cpl
500
0151 : 57                       ld      d,a
501
0152 : 7b                       ld      a,e
502
0153 : 2f                       cpl
503
0154 : 5f                       ld      e,a
504
0155 : 13                       inc     de
505
0156 : c9                       ret
506
0157 :                  ccbcneg:
507
0157 : 78                       ld      a,b
508
0158 : 2f                       cpl
509
0159 : 47                       ld      b,a
510
015a : 79                       ld      a,c
511
015b : 2f                       cpl
512
015c : 4f                       ld      c,a
513
015d : 03                       inc     bc
514
015e : c9                       ret
515
015f :                  ccrdel:
516
015f : 7b                       ld      a,e
517
0160 : 17                       rla
518
0161 : 5f                       ld      e,a
519
0162 : 7a                       ld      a,d
520
0163 : 17                       rla
521
0164 : 57                       ld      d,a
522
0165 : b3                       or      e
523
0166 : c9                       ret
524
0167 :                  cccmpbcde:
525
0167 : 7b                       ld      a,e
526
0168 : 91                       sub     c
527
0169 : 7a                       ld      a,d
528
016a : 98                       sbc     b
529
016b : c9                       ret
530 65 motilito
                        ;// UART IO registers
531
                        ;port (128) UDATA;              // uart data register used for bot
532
                        ;port (129) UBAUDL;             // low byte of baud rate register
533 66 motilito
AS80 Assembler for i8080-Z180 [1.11].                                Page   10
534
--------------------------------- HELLO.ASM ----------------------------------
535
 
536 65 motilito
                        ;port (130) UBAUDH;             // low byte of baud rate register
537
                        ;port (131) USTAT;              // uart status register
538
                        ;// digital IO ports registers
539 66 motilito
                        ;port (132) P1DATA;             // port 1 data register
540
                        ;port (133) P1DIR;              // port 1 direction register contr
541
                        ;port (134) P2DATA;             // port 2 data register
542
                        ;port (135) P2DIR;              // port 2 direction register contr
543
                        ;// interrupt controller register
544
                        ;port (136) INTRENA;            // interrupts enable register
545 65 motilito
                        ;// simulation end register
546
                        ;// writing any value to this port will end the verilo
547
                        ;// test bench.
548
                        ;port (255) SIMEND;
549
                        ;// registers bit fields definition
550
                        ;// uart status register decoding
551
                        ;#define UTXBUSY                1
552
                        ;#define URXFULL                16
553
                        ;// globals
554
                        ;char rxbyte;           // byte received from the uart
555
                        ;int tstary[2] = {1234, 5678};
556
                        ;//---------------------------------------------------
557
                        ;// send a single byte to the UART
558
                        ;sendbyte(by)
559 66 motilito
016c :                  __sendbyte:
560 65 motilito
                        ;char by;
561
                        ;{
562
                        ;       while (USTAT & UTXBUSY);
563 66 motilito
016c :                  cc2:
564
016c : db83                     in a,(131)
565
016e : cd4300                   call ccsxt
566
0171 : e5                       push hl
567
0172 : 210100                   ld hl,1
568
0175 : d1                       pop de
569
0176 : cd6400                   call ccand
570
0179 : 7c                       ld a,h
571
017a : b5                       or l
572
017b : ca8101                   jp z,cc3
573
017e : c36c01                   jp cc2
574
0181 :                  cc3:
575 65 motilito
                        ;       UDATA = by;
576 66 motilito
0181 : 210200                   ld hl,2
577
0184 : 39                       add hl,sp
578
0185 : cd4200                   call ccgchar
579
0188 : 7d                       ld a,l
580
0189 : d380                     out (128),a
581 65 motilito
 
582
                        ;}
583 66 motilito
018b : c9                       ret
584 65 motilito
                        ;// check if a byte was received by the uart
585
                        ;getbyte()
586 66 motilito
018c :                  __getbyte:
587 65 motilito
                        ;{
588
                        ;       if (USTAT & URXFULL) {
589 66 motilito
018c : db83                     in a,(131)
590
018e : cd4300                   call ccsxt
591
0191 : e5                       push hl
592
0192 : 211000                   ld hl,16
593
0195 : d1                       pop de
594
0196 : cd6400                   call ccand
595
0199 : 7c                       ld a,h
596
019a : b5                       or l
597
019b : caae01                   jp z,cc4
598
AS80 Assembler for i8080-Z180 [1.11].                                Page   11
599
--------------------------------- HELLO.ASM ----------------------------------
600
 
601 65 motilito
                        ;               rxbyte = UDATA;
602 66 motilito
019e : db80                     in a,(128)
603
01a0 : cd4300                   call ccsxt
604
01a3 : 7d                       ld a,l
605
01a4 : 322c04                   ld (__rxbyte),a
606 65 motilito
                        ;               return 1;
607 66 motilito
01a7 : 210100                   ld hl,1
608
01aa : c9                       ret
609 65 motilito
                        ;       }
610
                        ;       else
611 66 motilito
01ab : c3b201                   jp cc5
612
01ae :                  cc4:
613 65 motilito
                        ;               return 0;
614 66 motilito
01ae : 210000                   ld hl,0
615
01b1 : c9                       ret
616
01b2 :                  cc5:
617 65 motilito
                        ;}
618 66 motilito
01b2 : c9                       ret
619 65 motilito
                        ;// send new line to the UART
620
                        ;nl()
621 66 motilito
01b3 :                  __nl:
622 65 motilito
                        ;{
623
                        ;       sendbyte(13);
624 66 motilito
01b3 : 210d00                   ld hl,13
625
01b6 : e5                       push hl
626
01b7 : cd6c01                   call __sendbyte
627
01ba : c1                       pop bc
628 65 motilito
                        ;       sendbyte(10);
629 66 motilito
01bb : 210a00                   ld hl,10
630
01be : e5                       push hl
631
01bf : cd6c01                   call __sendbyte
632
01c2 : c1                       pop bc
633 65 motilito
                        ;}
634 66 motilito
01c3 : c9                       ret
635 65 motilito
                        ;// sends a string to the UART
636
                        ;printstr(sptr)
637 66 motilito
01c4 :                  __printstr:
638 65 motilito
                        ;char *sptr;
639
                        ;{
640
                        ;       while (*sptr != 0)
641 66 motilito
01c4 :                  cc6:
642
01c4 : 210200                   ld hl,2
643
01c7 : 39                       add hl,sp
644
01c8 : cd4800                   call ccgint
645
01cb : cd4200                   call ccgchar
646
01ce : e5                       push hl
647
01cf : 210000                   ld hl,0
648
01d2 : d1                       pop de
649
01d3 : cd7100                   call ccne
650
01d6 : 7c                       ld a,h
651
01d7 : b5                       or l
652
01d8 : caf401                   jp z,cc7
653 65 motilito
                        ;               sendbyte(*sptr++);
654 66 motilito
01db : 210200                   ld hl,2
655
01de : 39                       add hl,sp
656
01df : e5                       push hl
657
01e0 : cd4800                   call ccgint
658
01e3 : 23                       inc hl
659
01e4 : d1                       pop de
660
01e5 : cd5000                   call ccpint
661
01e8 : 2b                       dec hl
662
01e9 : cd4200                   call ccgchar
663
AS80 Assembler for i8080-Z180 [1.11].                                Page   12
664
--------------------------------- HELLO.ASM ----------------------------------
665
 
666
01ec : e5                       push hl
667
01ed : cd6c01                   call __sendbyte
668
01f0 : c1                       pop bc
669
01f1 : c3c401                   jp cc6
670
01f4 :                  cc7:
671 65 motilito
                        ;}
672 66 motilito
01f4 : c9                       ret
673 65 motilito
                        ;// sends a decimal value to the UART
674
                        ;printdec(dval)
675 66 motilito
01f5 :                  __printdec:
676 65 motilito
                        ;int dval;
677
                        ;{
678
                        ;       if (dval<0) {
679 66 motilito
01f5 : 210200                   ld hl,2
680
01f8 : 39                       add hl,sp
681
01f9 : cd4800                   call ccgint
682
01fc : e5                       push hl
683
01fd : 210000                   ld hl,0
684
0200 : d1                       pop de
685
0201 : cd8b00                   call cclt
686
0204 : 7c                       ld a,h
687
0205 : b5                       or l
688
0206 : ca2402                   jp z,cc8
689 65 motilito
                        ;               sendbyte('-');
690 66 motilito
0209 : 212d00                   ld hl,45
691
020c : e5                       push hl
692
020d : cd6c01                   call __sendbyte
693
0210 : c1                       pop bc
694 65 motilito
                        ;               dval = -dval;
695 66 motilito
0211 : 210200                   ld hl,2
696
0214 : 39                       add hl,sp
697
0215 : e5                       push hl
698
0216 : 210400                   ld hl,4
699
0219 : 39                       add hl,sp
700
021a : cd4800                   call ccgint
701
021d : cde200                   call ccneg
702
0220 : d1                       pop de
703
0221 : cd5000                   call ccpint
704 65 motilito
                        ;       }
705
                        ;       outint(dval);
706 66 motilito
0224 :                  cc8:
707
0224 : 210200                   ld hl,2
708
0227 : 39                       add hl,sp
709
0228 : cd4800                   call ccgint
710
022b : e5                       push hl
711
022c : cd3102                   call __outint
712
022f : c1                       pop bc
713 65 motilito
                        ;}
714 66 motilito
0230 : c9                       ret
715 65 motilito
                        ;// function copied from c80dos.c
716
                        ;outint(n)
717 66 motilito
0231 :                  __outint:
718 65 motilito
                        ;int n;
719
                        ;{
720
                        ;int q;
721 66 motilito
0231 : c5                       push bc
722 65 motilito
                        ;       q = n/10;
723 66 motilito
0232 : 210000                   ld hl,0
724
0235 : 39                       add hl,sp
725
0236 : e5                       push hl
726
0237 : 210600                   ld hl,6
727
023a : 39                       add hl,sp
728
AS80 Assembler for i8080-Z180 [1.11].                                Page   13
729
--------------------------------- HELLO.ASM ----------------------------------
730
 
731
023b : cd4800                   call ccgint
732
023e : e5                       push hl
733
023f : 210a00                   ld hl,10
734
0242 : d1                       pop de
735
0243 : cd0e01                   call ccdiv
736
0246 : d1                       pop de
737
0247 : cd5000                   call ccpint
738 65 motilito
                        ;       if (q) outint(q);
739 66 motilito
024a : 210000                   ld hl,0
740
024d : 39                       add hl,sp
741
024e : cd4800                   call ccgint
742
0251 : 7c                       ld a,h
743
0252 : b5                       or l
744
0253 : ca6202                   jp z,cc9
745
0256 : 210000                   ld hl,0
746
0259 : 39                       add hl,sp
747
025a : cd4800                   call ccgint
748
025d : e5                       push hl
749
025e : cd3102                   call __outint
750
0261 : c1                       pop bc
751 65 motilito
                        ;       sendbyte('0'+(n-q*10));
752 66 motilito
0262 :                  cc9:
753
0262 : 213000                   ld hl,48
754
0265 : e5                       push hl
755
0266 : 210600                   ld hl,6
756
0269 : 39                       add hl,sp
757
026a : cd4800                   call ccgint
758
026d : e5                       push hl
759
026e : 210400                   ld hl,4
760
0271 : 39                       add hl,sp
761
0272 : cd4800                   call ccgint
762
0275 : e5                       push hl
763
0276 : 210a00                   ld hl,10
764
0279 : d1                       pop de
765
027a : cdee00                   call ccmult
766
027d : d1                       pop de
767
027e : cddb00                   call ccsub
768
0281 : d1                       pop de
769
0282 : 19                       add hl,de
770
0283 : e5                       push hl
771
0284 : cd6c01                   call __sendbyte
772
0287 : c1                       pop bc
773 65 motilito
                        ;}
774 66 motilito
0288 : c1                       pop bc
775
0289 : c9                       ret
776 65 motilito
                        ;// sends a hexadecimal value to the UART
777
                        ;printhex(hval)
778 66 motilito
028a :                  __printhex:
779 65 motilito
                        ;int hval;
780
                        ;{
781
                        ;int q;
782 66 motilito
028a : c5                       push bc
783 65 motilito
                        ;       q = hval/16;
784 66 motilito
028b : 210000                   ld hl,0
785
028e : 39                       add hl,sp
786
028f : e5                       push hl
787
0290 : 210600                   ld hl,6
788
0293 : 39                       add hl,sp
789
0294 : cd4800                   call ccgint
790
0297 : e5                       push hl
791
0298 : 211000                   ld hl,16
792
029b : d1                       pop de
793
AS80 Assembler for i8080-Z180 [1.11].                                Page   14
794
--------------------------------- HELLO.ASM ----------------------------------
795
 
796
029c : cd0e01                   call ccdiv
797
029f : d1                       pop de
798
02a0 : cd5000                   call ccpint
799 65 motilito
                        ;       if (q) printhex(q);
800 66 motilito
02a3 : 210000                   ld hl,0
801
02a6 : 39                       add hl,sp
802
02a7 : cd4800                   call ccgint
803
02aa : 7c                       ld a,h
804
02ab : b5                       or l
805
02ac : cabb02                   jp z,cc10
806
02af : 210000                   ld hl,0
807
02b2 : 39                       add hl,sp
808
02b3 : cd4800                   call ccgint
809
02b6 : e5                       push hl
810
02b7 : cd8a02                   call __printhex
811
02ba : c1                       pop bc
812 65 motilito
                        ;       q = hval-q*16;
813 66 motilito
02bb :                  cc10:
814
02bb : 210000                   ld hl,0
815
02be : 39                       add hl,sp
816
02bf : e5                       push hl
817
02c0 : 210600                   ld hl,6
818
02c3 : 39                       add hl,sp
819
02c4 : cd4800                   call ccgint
820
02c7 : e5                       push hl
821
02c8 : 210400                   ld hl,4
822
02cb : 39                       add hl,sp
823
02cc : cd4800                   call ccgint
824
02cf : e5                       push hl
825
02d0 : 211000                   ld hl,16
826
02d3 : d1                       pop de
827
02d4 : cdee00                   call ccmult
828
02d7 : d1                       pop de
829
02d8 : cddb00                   call ccsub
830
02db : d1                       pop de
831
02dc : cd5000                   call ccpint
832
                        ;       if (q > 9)
833
02df : 210000                   ld hl,0
834
02e2 : 39                       add hl,sp
835
02e3 : cd4800                   call ccgint
836
02e6 : e5                       push hl
837
02e7 : 210900                   ld hl,9
838
02ea : d1                       pop de
839
02eb : cd7700                   call ccgt
840
02ee : 7c                       ld a,h
841
02ef : b5                       or l
842
02f0 : ca1003                   jp z,cc11
843
                        ;               sendbyte('A'+q-10);
844
02f3 : 214100                   ld hl,65
845
02f6 : e5                       push hl
846
02f7 : 210200                   ld hl,2
847
02fa : 39                       add hl,sp
848
02fb : cd4800                   call ccgint
849
02fe : d1                       pop de
850
02ff : 19                       add hl,de
851
0300 : e5                       push hl
852
0301 : 210a00                   ld hl,10
853
0304 : d1                       pop de
854
0305 : cddb00                   call ccsub
855
0308 : e5                       push hl
856
0309 : cd6c01                   call __sendbyte
857
030c : c1                       pop bc
858
AS80 Assembler for i8080-Z180 [1.11].                                Page   15
859 65 motilito
--------------------------------- HELLO.ASM ----------------------------------
860
 
861
                        ;       else
862 66 motilito
030d : c32203                   jp cc12
863
0310 :                  cc11:
864 65 motilito
                        ;               sendbyte('0'+q);
865 66 motilito
0310 : 213000                   ld hl,48
866
0313 : e5                       push hl
867
0314 : 210200                   ld hl,2
868
0317 : 39                       add hl,sp
869
0318 : cd4800                   call ccgint
870
031b : d1                       pop de
871
031c : 19                       add hl,de
872
031d : e5                       push hl
873
031e : cd6c01                   call __sendbyte
874
0321 : c1                       pop bc
875
0322 :                  cc12:
876 65 motilito
                        ;}
877 66 motilito
0322 : c1                       pop bc
878
0323 : c9                       ret
879
                        ;// external interrupt 0 service routine
880
                        ;int0_isr()
881
0324 :                  __int0_isr:
882
                        ;{
883
                        ;       printstr("Interrupt 0 was asserted."); nl();
884
0324 : 21d003                   ld hl,cc1+0
885
0327 : e5                       push hl
886
0328 : cdc401                   call __printstr
887
032b : c1                       pop bc
888
032c : cdb301                   call __nl
889
                        ;}
890
032f : c9                       ret
891 65 motilito
                        ;// program main routine
892
                        ;main()
893 66 motilito
0330 :                  __main:
894 65 motilito
                        ;{
895
                        ;       // configure UART baud rate - set to 9600 for 30MHz
896
                        ;       // BAUD = round(//16) = round(30e6
897 67 motilito
                        ;       // Note: Usage of a minimum divider value of 1 will
898
                        ;       UBAUDL = 195;
899
0330 : 21c300                   ld hl,195
900 66 motilito
0333 : 7d                       ld a,l
901
0334 : d381                     out (129),a
902 65 motilito
 
903
                        ;       UBAUDH = 0;
904 66 motilito
0336 : 210000                   ld hl,0
905
0339 : 7d                       ld a,l
906
033a : d382                     out (130),a
907 65 motilito
 
908 66 motilito
                        ;       // configure both ports to output and digital output
909
                        ;       P1DATA = 0x00;
910
033c : 210000                   ld hl,0
911
033f : 7d                       ld a,l
912
0340 : d384                     out (132),a
913
 
914
                        ;       P1DIR = 0xff;
915
0342 : 21ff00                   ld hl,255
916
0345 : 7d                       ld a,l
917
0346 : d385                     out (133),a
918
 
919
                        ;       P2DATA = 0x00;
920
0348 : 210000                   ld hl,0
921
034b : 7d                       ld a,l
922
034c : d386                     out (134),a
923 67 motilito
AS80 Assembler for i8080-Z180 [1.11].                                Page   16
924
--------------------------------- HELLO.ASM ----------------------------------
925
 
926 66 motilito
 
927
                        ;       P2DIR = 0xff;
928
034e : 21ff00                   ld hl,255
929
0351 : 7d                       ld a,l
930
0352 : d387                     out (135),a
931
 
932
                        ;       // enable interrupt 0 only
933
                        ;       INTRENA = 0x01;
934
0354 : 210100                   ld hl,1
935
0357 : 7d                       ld a,l
936
0358 : d388                     out (136),a
937
 
938
                        ;       // enable CPU interrupt
939
                        ;#asm
940
035a : fb                       ei
941
                        ;       // print message
942 65 motilito
                        ;       printstr("Hello World!!!"); nl();
943 66 motilito
035b : 21ea03                   ld hl,cc1+26
944
035e : e5                       push hl
945
035f : cdc401                   call __printstr
946
0362 : c1                       pop bc
947
0363 : cdb301                   call __nl
948 65 motilito
                        ;       printstr("Dec value: "); printdec(tstary[1]); nl();
949 66 motilito
0366 : 21f903                   ld hl,cc1+41
950
0369 : e5                       push hl
951
036a : cdc401                   call __printstr
952
036d : c1                       pop bc
953
036e : 212d04                   ld hl,__tstary
954
0371 : e5                       push hl
955
0372 : 210100                   ld hl,1
956
0375 : 29                       add hl,hl
957
0376 : d1                       pop de
958
0377 : 19                       add hl,de
959
0378 : cd4800                   call ccgint
960
037b : e5                       push hl
961
037c : cdf501                   call __printdec
962
037f : c1                       pop bc
963
0380 : cdb301                   call __nl
964 65 motilito
                        ;       printstr("Hex value: 0x"); printhex(tstary[0]); nl()
965 66 motilito
0383 : 210504                   ld hl,cc1+53
966
0386 : e5                       push hl
967
0387 : cdc401                   call __printstr
968
038a : c1                       pop bc
969
038b : 212d04                   ld hl,__tstary
970
038e : e5                       push hl
971
038f : 210000                   ld hl,0
972
0392 : 29                       add hl,hl
973
0393 : d1                       pop de
974
0394 : 19                       add hl,de
975
0395 : cd4800                   call ccgint
976
0398 : e5                       push hl
977
0399 : cd8a02                   call __printhex
978
039c : c1                       pop bc
979
039d : cdb301                   call __nl
980
                        ;       // assert bit 0 of port 1 to test external interrupt
981
                        ;       P1DATA = 0x01;
982
03a0 : 210100                   ld hl,1
983
03a3 : 7d                       ld a,l
984
03a4 : d384                     out (132),a
985
 
986
                        ;
987 65 motilito
                        ;       printstr("Echoing received bytes: "); nl();
988 67 motilito
AS80 Assembler for i8080-Z180 [1.11].                                Page   17
989
--------------------------------- HELLO.ASM ----------------------------------
990
 
991 66 motilito
03a6 : 211304                   ld hl,cc1+67
992
03a9 : e5                       push hl
993
03aa : cdc401                   call __printstr
994
03ad : c1                       pop bc
995
03ae : cdb301                   call __nl
996 65 motilito
                        ;       // loop forever
997
                        ;       while (1) {
998 66 motilito
03b1 :                  cc13:
999
03b1 : 210100                   ld hl,1
1000
03b4 : 7c                       ld a,h
1001
03b5 : b5                       or l
1002
03b6 : cacf03                   jp z,cc14
1003 65 motilito
                        ;               // check if a new byte was received
1004
                        ;               if (getbyte())
1005 66 motilito
03b9 : cd8c01                   call __getbyte
1006
03bc : 7c                       ld a,h
1007
03bd : b5                       or l
1008
03be : cacc03                   jp z,cc15
1009 65 motilito
                        ;                       // echo the received byte to the UART
1010
                        ;                       sendbyte(rxbyte);
1011 66 motilito
03c1 : 3a2c04                   ld a,(__rxbyte)
1012
03c4 : cd4300                   call ccsxt
1013
03c7 : e5                       push hl
1014
03c8 : cd6c01                   call __sendbyte
1015
03cb : c1                       pop bc
1016 65 motilito
                        ;       }
1017 66 motilito
03cc :                  cc15:
1018
03cc : c3b103                   jp cc13
1019
03cf :                  cc14:
1020 65 motilito
                        ;}
1021 66 motilito
03cf : c9                       ret
1022 65 motilito
                        ;//---------------------------------------------------
1023
                        ;//                                             Th.. Th.. Th.. Thats all folks !!!
1024
                        ;//---------------------------------------------------
1025 66 motilito
03d0 :                  cc1:
1026
03d0 : 496e7465727275..         db 73,110,116,101,114,114,117,112,116,32
1027
03da : 30207761732061..         db 48,32,119,97,115,32,97,115,115,101
1028
03e4 : 727465642e0048..         db 114,116,101,100,46,0,72,101,108,108
1029
03ee : 6f20576f726c64..         db 111,32,87,111,114,108,100,33,33,33
1030
03f8 : 00446563207661..         db 0,68,101,99,32,118,97,108,117,101
1031
0402 : 3a200048657820..         db 58,32,0,72,101,120,32,118,97,108
1032
040c : 75653a20307800..         db 117,101,58,32,48,120,0,69,99,104
1033
0416 : 6f696e67207265..         db 111,105,110,103,32,114,101,99,101,105
1034
0420 : 76656420627974..         db 118,101,100,32,98,121,116,101,115,58
1035
042a : 2000                     db 32,0
1036
042c :                  __rxbyte:
1037
042c : 00                       ds 1
1038
042d :                  __tstary:
1039
042d : d2042e16                 db -46,4,46,22
1040 65 motilito
 
1041
                        ; --- End of Compilation ---
1042
No errors in pass 2.

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.