Assembling Files
There are three common ways to assemble source files written in
assembly code. Each has a slightly different syntax – if you are–t85 -b myfile.asm myfile.com
getting errors with one, then try another.
1) TASM (on a PC)
2) Microsoft’s M80 assembler (on a CP/M computer)
3) CP/M’s ASM.COM (on a CP/M computer)
************************ TASM ******************************
TSAM is compiled on the PC, and you can create a batch file to save
remembering the syntax. TASM is used to compile the N8VEM eprom code.
Example of TASM submit file (or type it in manually) for Z80 opcodes:
tasm -t80 -b myfile.asm myfile.com
code example
UPCASE:
CP 'a' ;KEEP NUMBERS, CONTROLS
RET C ;AND UPPER CASE
CP 7BH ;SEE IF NOT LOWER CASE
RET NC
AND 5FH ;MAKE UPPER CASE
RET
Or if using 8080 opcodes:
tasm
code example
;
; CONVERT INPUT LINE TO UPPER CASE.
;
GETINP2 LXI H,INBUFF+1
MOV B,M ;(B)=CHARACTER COUNTER.
GETINP3 INX H
MOV A,B ;END OF THE LINE?
ORA A
JZ GETINP4
MOV A,M ;CONVERT TO UPPER CASE.
CALL UPPER
MOV M,A
DCR B ;ADJUST CHARACTER COUNT.
JMP GETINP3
GETINP4 MOV M,A ;ADD TRAILING NULL.
LXI H,INBUFF+2
SHLD INPOINT ;RESET INPUT LINE POINTER.
RET
************* Using Microsoft’s M80 *********************
This uses M80.com, L80.com and works on .MAC files. On the Walnut
Creek archive about half the source files are .MAC and half are .ASM
so both systems are useful.
This program sets the baud rate to 1200
; 1200 baud
; changing from tasm mnemonics - replace all $nn with nnH
; remove . in front of equ
; remove : in equ lines
; must have a CR/LF after END
; use zasm.sub with supersub
; eg supersub zasm myfile (where myfile is called myfile.mac but do
not put the
; mac in the instruction - m80 knows it is
implied)
; zasm.sub is the following two lines
;M80 =$1 /Z/C/L/M
;L80 $1,$1/N/E
; UART 16C450 SERIAL IS ATTACHED TO THE SECOND IO BASE ADDRESS
IO_Y0 EQU 60h
IO_Y1 EQU 68h
IO_Y2 EQU 70h
IO_Y3 EQU 78h
UART0 EQU IO_Y1+0 ; DATA IN/OUT
UART1 EQU IO_Y1+1 ; CHECK RX
UART2 EQU IO_Y1+2 ; INTERRUPTS
UART3 EQU IO_Y1+3 ; LINE CONTROL
UART4 EQU IO_Y1+4 ; MODEM CONTROL
UART5 EQU IO_Y1+5 ; LINE STATUS
UART6 EQU IO_Y1+6 ; MODEM STATUS
UART7 EQU IO_Y1+7 ; SCRATCH REG.
UART1200: LD A,80H
OUT (UART3),A ; SET DLAB FLAG
LD A,96 ; = 1,843,200 / ( 16 x 9600 )
OUT (UART0),A ; Set BAUD rate to 1200
LD A,00H
OUT (UART1),A ;
LD A,03H
OUT (UART3),A ; Set 8 bit data, 1 stopbit
ret ; back to CP/M
end
***************** Using CP/M’s ASM.COM program *****************
This uses ASM.COM and LOAD.COM As with M80, don’t type the extension,
it assumes it is a .asm
ASM can handle Z80 or 8080 opcodes.
An example of a submit file is
ASM $1
LOAD $1
And an example of code:
FCB EQU 5CH
BDOS EQU 05
FPRT EQU 9
FCLOSE EQU 16
DELETE EQU 19
WRITE EQU 21
MAKE EQU 22
SDMA EQU 26
SRCH EQU 17
SRCHX EQU 18
;
DMA EQU 80H ; DMA LOCATION
;
ORG 100H ;CP/M TPA
;
LXI H,0
DAD SP
SHLD OLDSTK ;SAVE OLD STACK POINTER
Comments (0)