home *** CD-ROM | disk | FTP | other *** search
-
- idnt Atow
-
- section one
-
- 1. This little utility partially converts assembly
- programs to web format.
- --- Greg Lee, July 1, 1986
-
- --Macro definitions for assembler
- --EQU statements for assembler
- --Definitions of library references
-
- 2. Here is where execution starts.
-
- Main
-
- define push -(SP).L
- define pop (SP)+
- define chr D0.B
-
- --Get file name from input line
- --Open input and output files
-
- {
- --Read a line
- tst.l l_length
- beq windup
-
- a1 = ^obuf
- a2.l = input_line
-
- chr = (input_line)+
- chr ? 9
- = « chr = ' ' »
-
- chr ? ' '
- = { { (input_line)+.b ? ' '
- beq }
-
- input_line -= 1
- --Check for equals instruction
- bne ¶
- d2.b = chr
-
- d4.b = (input_line)
- d4.b ? 'q'
- = « input_line += 1 »
-
- d1 = 0
- (input_line).b ? '.'
- = { input_line += 1
- d1.b = (input_line)+
- }
-
- chr = (input_line)+
- chr ? 9
- != [ chr ? ' '
- bne ¶
- ]
- { (input_line)+.b ? ' '
- beq }
-
- a3.l = ^-1(input_line)
-
- [ chr = (input_line)+
- chr ? 10; beq ¶
- chr ? ''''
- = « input_line += 2 »
- chr ? ','
- bne ]
-
- (a1)+.b = 9
- l_length = 5
-
- (input_line).b ? 'D'
- = « (input_line).b = 'd' »
- (input_line).b ? 'A'
- = « (input_line).b = 'a' »
- (input_line).b ? 'S'
- = { 1(input_line).b ? 'P'
- = { (input_line).b = 'a'
- 1(input_line).b = '7'
- }
- }
-
- { chr = (input_line)+
- chr ? 9; beq ¶
- chr ? 10; beq ¶
- chr ? ' '
- = [ -2(input_line).b ? ''''
- bne ¶
- ]
- (a1)+.b = chr
- l_length += 1
- -> }
-
- d4.b ? 'q'
- = { d1.b ? 'l'
- = « clr.b d1 »
- }
-
- tst.b d1
- != { (a1)+.b = '.'
- (a1)+.b = d1
- l_length += 2
- }
-
- (a1)+.b = 9
- d2.b ? 'a'
- = { (a1)+.b = '+'
- l_length += 1
- }
- d2.b ? 's'
- = { (a1)+.b = '-'
- l_length += 1
- }
-
- (a1)+.b = '='
- d2.b ? 'c'
- = « -1(a1).b = '?' »
- (a1)+.b = 9
- d2.b ? 'l'
- = { (a1)+.b = '^'
- l_length += 1
- }
-
- d4.b ? 'q'
- = « clr.b d1 »
-
- { chr = (a3)+
- chr ? ','; beq ¶
- (a1)+.b = chr
- l_length += 1
- chr ? '#'
- = { tst.b d1
- != [ (a3).b ? ''''
- bne ¶
- ]
- a1 -= 1
- l_length -= 1
- }
- -> }
-
- (a1)+.b = 10
- a2 = ^ obuf
-
- }
-
-
- arg`a = ohandle
- arg`b = a2
- call Write
- l_length ? d0
- beq }
-
- print prob
-
- windup · finished output
- chr = infname
- != {
- arg`a = ohandle; call Close
- arg`a = ihandle; call Close
- -> {
- abort1: arg`a = ihandle; call Close
- abort: print nogo
- }
- }
- d0 = 0
-
-
- --Check for equals instruction
- chr = (input_line)+
- chr ? 'm'
- != { chr ? 'l'
- != { chr ? 'c'
- != { chr ? 'a'
- != { chr ? 's'
- bne §
- (input_line)+.b ? 'u'
- bne §
- (input_line)+.b ? 'b'
- -> §
- }
- (input_line)+.b ? 'd'
- bne §
- (input_line)+.b ? 'd'
- -> §
- }
- (input_line)+.b ? 'm'
- bne §
- (input_line)+.b ? 'p'
- -> §
- }
- (input_line)+.b ? 'e'
- bne §
- (input_line)+.b ? 'a'
- -> §
- }
- (input_line)+.b ? 'o'
- bne §
- (input_line)+.b ? 'v'
- bne §
- (input_line)+.b ? 'e'
- = { (input_line).b ? ' '; beq §
- (input_line).b ? 9; beq §
- (input_line).b ? '.'; beq §
- (input_line)+.b ? 'q'
- }
-
-
- ¶ We make two copies of the name given in the command tail.
- The last character of the second copy is changed to 'a', and
- this second copy is used as the name of the output file.
-
- --Get file name from input line
-
- define command_tail A0.L
- define tail_length D0
- define input_name A1.L
- define output_name A2.L
- define fn_char D1.B
-
- input_name = ^infname
- output_name = input_name
- -> next_fname_char
- { fn_char = (command_tail)+
- fn_char ? ' ' + 1; blt ¶
- (input_name)+.b = fn_char
- tail_length -= 1
- next_fname_char
- tst.l tail_length
- bne }
- clr.b (input_name)
-
- exg input_name,output_name
- output_name = ^outfname
- { (output_name)+.b = (input_name)+; = }
- output_name -= 1
-
- -1(output_name).b ? 'a'
- = { -2(output_name).b ? '.'
- = { -1(output_name).b = 'w'
- -> §
- }
- }
-
- (output_name)+.b = '.'; (output_name)+.b = 'n'
- clr.b (output_name)
-
- ¶ AmigaDOS stuff.
-
- --Open input and output files
-
- define arg`a D1.L · first argument to AmigaDOS function
- define arg`b D2.L · second argument
-
- long ohandle
- long chandle
- long ihandle
-
- --Initialize standard input and output
-
- a1 = ^infname
- tst.b (A1)
- beq abort
-
- arg`a = a1
- arg`b = #1005
- call Open; tst.l D0; beq abort
- ihandle = d0
-
- arg`a = #outfname
- arg`b = #1006
- call Open; tst.l D0; beq abort1
- ohandle = d0
-
- ¶ Buffer is refilled whenever we can't find a complete line
- (ending in newline). The count in D3 includes the final newline.
- Thus returning a count of zero can be used as the signal that
- the file is exhausted.
-
- --Read a line
-
- define input_line A0.L
- define l_length D3.L
- define new_line #10
- define chars_remaining D2.B
- define partial_line A1.L
- byte bufchcount
-
- · return input_line pointing to line and l_length length of line
- input_line = bufptr
- push = input_line
- l_length = 0 · no chars in line yet
- · back to here when was necessary to read more from file
- .rdln.cont
- moveq #0,chars_remaining
- chars_remaining = bufchcount
- bmi rdln.keep.info · this means file is exhausted
- beq .rdln.more
-
- chars_remaining.l -= 1
- { chr = (input_line)+
- chr ? new_line
- beq rdln.keep.one
- · chr ? 9
- · = « -1(input_line).b = ' ' »
- l_length.b += 1
- l_length.b ? #ibufLen
- beq rdln.keep.info
- dbra chars_remaining,}
- · ran out of chars -- go get more
- -> .rdln.more
- · have one line -- check not empty
- rdln.keep.one
- l_length.b += 1
- rdln.keep.info
- bufptr.l = input_line
- bufchcount = chars_remaining
- input_line = pop
- -> §
-
- .rdln.more
- · have partial line in buffer with l_length chars in it
- partial_line = pop · beginning of partial line
- · while l_length > 0 move chars back to beginning of buffer
- input_line = ^ibuf
- push = input_line · for ret.
- push = l_length
- l_length.b -= 1
- +{ { (input_line)+.b = (partial_line)+
- dbra l_length,}
- }
- · fill remainder of buffer with 80-(l_length) chars
- l_length = 80
- d0.l = pop
- l_length.b -= d0
- push = d0
-
- partial_line = ^ibuf
- partial_line += d0
- push = partial_line · save where to continue processing line
- arg`a = ihandle
- arg`b = partial_line
- call Read
-
- tst.b D0
- = « st D0 »
- bufchcount = d0
- input_line = pop · continue processing here
- l_length = pop · chars scanned so far
- -> .rdln.cont
-
-
- Display string
- · message to console
- msg
- arg`a = chandle
- l_length = 0
- l_length.b = (a0)+
- arg`b = a0
- call Write
-
- ¶ AmigaDos stuff.
-
- --Initialize standard input and output
- ioinit
- move.l sysBase,A6 · ready call to OpenLibrary
- lea libname,A1
- moveq #0,D0
- call OpenLibrary
- move.l D0,A6
- · obtain file handles for output and input opened by CLI
- call Output
- ohandle = d0
- chandle = d0
- call Input
- ihandle = d0
-
-
-
- ¶
-
- Data sections
-
- section three,bss
-
- olen ds.b 1
- obuf ds.b 80
- ilen ds.b 1
- ibuf ds.b ibufLen
- · now on word boundary
-
- infname ds.b 30
- outfname ds.b 30
-
-
-
- section two,data
-
-
-
- libname dc.b 'dos.library',0
- bufptr dc.l ibuf
- cnop 0,2
-
- bstr nogo,<couldn''t open file>
- bstr prob,<problem with output file>
-
- section one
-
-
- ¶
-
- --EQU statements for assembler
- sysBase equ 4
- ibufLen equ 80
-
- ¶
-
- --Macro definitions for assembler
-
- lref macro
- _LVO\1 equ -6*(\2+4)
- endm
-
- call macro
- jsr _LVO\1(A6)
- endm
-
- print macro
- lea \1,A0
- bsr msg
- endm
-
- bstr macro
- \1 dc.b 1$-*-1
- dc.b '\2',10
- 1$
- endm
-
- ¶ Following to avoid slow linking with amiga.lib
-
- --Definitions of library references
-
- lref OpenLibrary,88
-
- lref Output,6
- lref Input,5
- lref Write,4
- lref Read,3
- lref DeleteFile,8
- lref Open,1
- lref Close,2
- lref IoErr,18
- lref LoadSeg,21
- lref UnLoadSeg,22
- lref IsInteractive,32
-
-
-