1
0
mirror of https://github.com/pfusik/xasm.git synced 2025-08-12 10:24:58 +00:00

xasm 2.4.-2.

This commit is contained in:
Piotr Fusik
2002-04-07 16:02:26 +02:00
parent f9a11b10e3
commit a7279f7ea6

149
xasm.asm
View File

@@ -12,14 +12,14 @@ ENDIF
CODESEG CODESEG
; comment out to disable ; comment out to disable
SET_WIN_TITLE = 1 ; SET_WIN_TITLE = 1
; compak = 1d00h ; compak = 1d00h
l_icl = 1024 l_icl = 1024
l_org = 4096 l_org = 4096
IFDEF EXE IFDEF EXE
l_lab = 55000 l_lab = 54000
ELSE ELSE
l_lab = 48000 l_lab = 48000
ENDIF ENDIF
@@ -92,9 +92,10 @@ b_swn = 4
m_swn = 10h m_swn = 10h
m_swo = 20h m_swo = 20h
m_swp = 40h m_swp = 40h
m_sws = 80h m_swq = 80h
m_swt = 100h m_sws = 100h
m_swu = 200h m_swt = 200h
m_swu = 400h
;[flist] ;[flist]
m_lsti = 4 m_lsti = 4
@@ -103,6 +104,7 @@ m_lsto = 10h
m_lsts = m_lsto+m_lstl+m_lsti m_lsts = m_lsto+m_lstl+m_lsti
nhand = -1 ;null handle nhand = -1 ;null handle
STDERR = 2
cr equ 13 cr equ 13
eol equ 13,10 eol equ 13,10
eot equ 13,10,'$' eot equ 13,10,'$'
@@ -279,7 +281,7 @@ ENDIF
int 2fh int 2fh
mov [titfin], ' ' mov [titfin], ' '
endif endif
print hello ; print hello
IFDEF EXE IFDEF EXE
mov si, offset tlabel+3 mov si, offset tlabel+3
ELSE ELSE
@@ -310,13 +312,13 @@ parg1: lodsb
mov [fslen], di mov [fslen], di
jmp parg0 jmp parg0
usg: print usgtxt ; usage - instrukcja usg: print hello ; usage - instrukcja
dos 4c03h dos 4c03h
popt1: lodsb popt1: lodsb
and al, 0dfh ; mala litera -> duza and al, 0dfh ; mala litera -> duza
mov di, offset swilet mov di, offset swilet
mov cx, 10 mov cx, 11
repne scasb repne scasb
jne usg ; nie ma takiego switcha jne usg ; nie ma takiego switcha
bts [swits], cx ; sprawdz bit i ustaw bts [swits], cx ; sprawdz bit i ustaw
@@ -341,7 +343,11 @@ popt2: lodsb
pargx: pargx:
cmp [(icl t_icl).nam], 0 ; czy jest nazwa? cmp [(icl t_icl).nam], 0 ; czy jest nazwa?
je usg je usg
mov di, offset lstnam testsw m_swq
jnz nohelo
mov [usgtxt], '$'
print hello
nohelo: mov di, offset lstnam
mov eax, 'TSL' mov eax, 'TSL'
call defnam call defnam
mov di, offset objnam mov di, offset objnam
@@ -407,7 +413,7 @@ ELSE
push cs push cs
ENDIF ENDIF
pop ds pop ds
print envtxt call prenvt
dos 4c02h dos 4c02h
renvx: renvx:
@@ -450,7 +456,8 @@ opfile: call fopen
pop eax pop eax
cmp eax, [objmod] cmp eax, [objmod]
ja main ja main
print oldtxt mov si, offset oldtxt
call prline
dos 4c00h dos 4c00h
main: mov bx, [iclen] main: mov bx, [iclen]
@@ -740,7 +747,9 @@ skiret: ret
; ERROR ; ERROR
errln: call ppline errln: call ppline
erron: call prname erron: call prname
print errtxt mov dx, offset errtxt
mov cx, errtxl
call prerr
pop si pop si
call msgenv call msgenv
dos 4c02h dos 4c02h
@@ -748,41 +757,50 @@ erron: call prname
; WARNING ; WARNING
warln: call ppline warln: call ppline
call prname call prname
print wartxt mov dx, offset wartxt
mov cx, wartxl
call prerr
pop ax pop ax
pop si pop si
push ax push ax
mov [byte exitcod], 1 mov [byte exitcod], 1
msgenv: call prline msgenv: call prline
btr [flags], b_enve btr [flags], b_enve
jnc msgenx jnc skiret
print envtxt prenvt: mov si, offset envtxt
msgenx: ret jmp prline
prname: mov bx, [iclen] prname: mov bx, [iclen]
cmp bx, offset t_icl cmp bx, offset t_icl
jna msgenx jna skiret
mov di, [(icl bx).prev] mov di, [(icl bx).prev]
push di push di
lea dx, [(icl di).nam] lea dx, [(icl di).nam]
mov [byte bx-1], '$' ; mov [byte bx-1], '$'
lea cx, [bx-1]
sub cx, dx
mov [envnam], dx mov [envnam], dx
sub bx, dx sub bx, dx
mov [envlen], bx mov [envlen], bx
print call prerr
mov dl, ' ' mov al, ' '
dos 2 call putchar
mov dl, '(' mov al, '('
dos 2 call putchar
pop bx pop bx
mov eax, [(icl bx).line] mov eax, [(icl bx).line]
call pridec call numdet
mov dl, ')' mov dx, di
dos 2 mov [envnum], di
mov dl, ' ' mov cx, offset dectxt+10
dos 2 sub cx, di
call prerr
mov al, ')'
call putchar
mov al, ' '
call putchar
testsw m_swe testsw m_swe
jz msgenx jz skiret
les di, [dword envofs] les di, [dword envofs]
mov ax, [es:3] mov ax, [es:3]
shl ax, 4 shl ax, 4
@@ -798,7 +816,7 @@ prname: mov bx, [iclen]
stosd stosd
mov si, [envnam] mov si, [envnam]
senv1: movsb senv1: movsb
cmp [byte si], '$' cmp [byte si], 0 ;'$'
jne senv1 jne senv1
xor al, al xor al, al
stosb stosb
@@ -820,13 +838,21 @@ senve: setfl m_enve
ret ret
ppline: mov si, offset line ppline: mov si, offset line
prline: mov dl, [si] prline: mov dx, si
dos 2 xor cx, cx
inc si prli1: inc si
inc cx
cmp [byte si-1], 0dh cmp [byte si-1], 0dh
jne prline jne prli1
mov dl, 0ah mov bx, STDERR
dos 2 dos 40h
mov al, 0ah
putchar:
mov [chbuf], al
mov dx, offset chbuf
mov cx, 1
prerr: mov bx, STDERR
dos 40h
ret ret
miseif: push offset e_meif miseif: push offset e_meif
@@ -898,6 +924,8 @@ lata4: call phword
jb lata1 jb lata1
nlata: call lclose nlata: call lclose
testsw m_swq
jnz zrbyt
mov eax, [lines] mov eax, [lines]
shr eax, 1 shr eax, 1
call pridec call pridec
@@ -987,8 +1015,10 @@ putblk: jpass1 putx ; zapisz blok
xor cx, cx xor cx, cx
file 3ch, e_crobj file 3ch, e_crobj
mov [ohand], ax mov [ohand], ax
testsw m_swq
jnz noobjt
print objtxt print objtxt
pop dx cx noobjt: pop dx cx
putb1: mov bx, [ohand] putb1: mov bx, [ohand]
file 40h, e_wrobj file 40h, e_wrobj
movzx ecx, cx movzx ecx, cx
@@ -1184,8 +1214,10 @@ opnlst: mov dx, offset lstnam
opntab: xor cx, cx opntab: xor cx, cx
file 3ch, e_crlst file 3ch, e_crlst
mov [lhand], ax mov [lhand], ax
testsw m_swq
jnz nolstt
print lsttxt print lsttxt
mov dx, offset hello nolstt: mov dx, offset hello
mov cx, hellen mov cx, hellen
jmp putlad jmp putlad
@@ -1209,6 +1241,7 @@ adex2: mov [byte di-1], '.'
adexr: ret adexr: ret
; Zapisz dziesietnie eax; di-koniec liczby ; Zapisz dziesietnie eax; di-koniec liczby
numdet: mov di, offset dectxt+10
numdec: mov ebx, 10 numdec: mov ebx, 10
numde1: cdq numde1: cdq
div ebx div ebx
@@ -1220,10 +1253,9 @@ numde1: cdq
ret ret
; Wyswietl dziesietnie eax ; Wyswietl dziesietnie eax
pridec: mov di, offset dectxt+10 pridec: call numdet
call numdec
mov dx, di mov dx, di
mov [envnum], di ; mov [envnum], di
print print
ret ret
@@ -1261,8 +1293,8 @@ clfna:
je clfx je clfx
cmp al, 9 cmp al, 9
je clfx je clfx
cmp al, '/' ; cmp al, '/'
je clfx ; je clfx
cmp al, 0dh cmp al, 0dh
jne clf1 jne clf1
clfx: xor al, al clfx: xor al, al
@@ -2831,29 +2863,31 @@ optvec dw optl0,optl1,opth0,opth1,opto0,opto1
cndtxt dd 'DNE','TFI','ILE','SLE','FIE' cndtxt dd 'DNE','TFI','ILE','SLE','FIE'
cndvec dw pofend,0,p_ift,0,p_eli,0,p_els,0,p_eif cndvec dw pofend,0,p_ift,0,p_eli,0,p_els,0,p_eif
swilet db 'UTSPONLIEC' swilet db 'UTSQPONLIEC'
hello db 'X-Assembler 2.4.-3' hello db 'X-Assembler 2.4.-2'
ifdef SET_WIN_TITLE ifdef SET_WIN_TITLE
titfin db 0 titfin db 0
else else
db ' ' db ' '
endif endif
db 'by Fox/Taquart',eot db 'by Fox/Taquart',eol
hellen = $-hello-1 hellen = $-hello
usgtxt db "Syntax: XASM source [options]",eol usgtxt db "Syntax: XASM source [options]",eol
db "/c List code excluded by ift/els/eli",eol db "/c Include false conditionals in listing",eol
db "/e Set environment variables ERRFILE and ERRLINE if error occurs",eol ; db "/d:label=value Define a label",eol
db "/e Set environment variables ERRFILE and ERRLINE",eol
db "/i Don't list included files",eol db "/i Don't list included files",eol
db "/l[:fname] Generate listing",eol db "/l[:filename] Generate listing",eol
db "/n Assemble only if source file is newer than object file",eol db "/n Assemble only if source file is newer than object file",eol
db "/o:fname Write object file as 'fname'",eol db "/o:filename Set object file name",eol
db "/p Print fully qualified file names in listing and error messages",eol db "/p Print fully qualified file names in listing and error messages",eol
db "/q Suppress info messages",eol
db "/s Don't convert spaces to tabs in listing",eol db "/s Don't convert spaces to tabs in listing",eol
db "/t[:fname] List label table",eol db "/t[:filename] List label table",eol
db "/u Warn of unused labels",eot db "/u Warn of unused labels",eot
oldtxt db 'Source file is older than object file - not assembling',eot oldtxt db 'Source file is older than object file - not assembling',cr
envtxt db 'Can''t change environment',eot envtxt db 'Can''t change environment',cr
objtxt db 'Writing object file...',eot objtxt db 'Writing object file...',eot
lsttxt db 'Writing listing file...' lsttxt db 'Writing listing file...'
eoltxt db eot eoltxt db eot
@@ -2864,13 +2898,15 @@ tabtxl = $-tabtxt
lintxt db ' lines of source assembled',eot lintxt db ' lines of source assembled',eot
byttxt db ' bytes written to the object file',eot byttxt db ' bytes written to the object file',eot
dectxt db 10 dup(' '),'$' dectxt db 10 dup(' '),'$'
wartxt db 'WARNING: $' wartxt db 'WARNING: '
wartxl = $-wartxt
w_bugjp db 'Buggy indirect jump',eol w_bugjp db 'Buggy indirect jump',eol
w_bras db 'Branch would be sufficient',eol w_bras db 'Branch would be sufficient',eol
w_ulab db 'Unused label',eol w_ulab db 'Unused label',eol
w_skif db 'Skipping only first instruction',eol w_skif db 'Skipping only first instruction',eol
w_repl db 'Repeating only last instruction',eol w_repl db 'Repeating only last instruction',eol
errtxt db 'ERROR: $' errtxt db 'ERROR: '
errtxl = $-errtxt
e_open db 'Can''t open file',cr e_open db 'Can''t open file',cr
e_read db 'Disk read error',cr e_read db 'Disk read error',cr
e_crobj db 'Can''t write to the object file',cr e_crobj db 'Can''t write to the object file',cr
@@ -2968,6 +3004,7 @@ envseg dw ?
envnam dw ? envnam dw ?
envnum dw ? envnum dw ?
envlen dw ? envlen dw ?
chbuf db ?
var = $ var = $
MACRO bb _name MACRO bb _name