@@ -2,9 +2,12 @@
.define .and
! #bytes in cx
+ ! save di; it might be a register variable
+
.sect .text
.and:
pop bx ! return address
+ mov dx,di
mov di,sp
add di,cx
sar cx,1
@@ -13,4 +16,5 @@
and ax,(di)
stos
loop 1b
+ mov di,dx
jmp bx
@@ -3,32 +3,32 @@
.cii:
- pop di ! return address
+ pop bx ! return address
! pop cx, dest. size
- ! pop bx, src. size
+ ! pop dx, src. size
! ax is first word of source
- cmp bx,1
+ cmp dx,1
jne 2f
cbw
- mov bx,2
+ mov dx,2
2:
- cmp bx,cx
+ cmp dx,cx
je 8f
- cmp bx,2
+ cmp dx,2
je 1f
- cmp bx,4
+ cmp dx,4
jne 9f
cmp cx,2
pop dx
8:
- jmp di
+ jmp bx
1:
cmp cx,4
cwd
push dx
9:
push ax ! push low source
.extern EILLINS
@@ -6,6 +6,8 @@
.cms:
mov dx,sp
+ push si
+ push di
mov si,dx
add dx,cx
mov di,dx
@@ -15,5 +17,7 @@
inc cx
+ pop di
+ pop si
mov sp,dx
@@ -4,23 +4,25 @@
.cmu4:
- xor ax,ax
pop cx
- pop si
- pop di
- cmp di,dx
+ pop ax
+ mov si,sp
+ xchg bx,2(si)
+ cmp bx,dx
ja 1f
jb 2f
- cmp si,cx
+ cmp ax,cx
je 3f
- dec ax
+ mov ax,-1
+ ret
3:
- jmp bx
+ xor ax,ax
- inc ax
-
+ mov ax,1
ret
@@ -4,12 +4,12 @@
.com:
- pop bx ! return address
- mov di,sp
+ mov bx,sp
+ add bx,2
- not (di)
- inc di
+ not (bx)
+ inc bx
@@ -3,14 +3,15 @@
.csa2:
- ! si, descriptor address
- ! bx, index
- mov dx,(si) ! default
- sub bx,2(si)
- cmp bx,4(si)
+ ! bx, descriptor address
+ ! ax, index
+ mov dx,(bx) ! default
+ sub ax,2(bx)
+ cmp ax,4(bx)
- sal bx,1
- mov bx,6(bx)(si)
+ sal ax,1
+ add bx,ax
+ mov bx,6(bx)
test bx,bx
jnz 2f
@@ -3,20 +3,17 @@
.csb2:
- !si, descriptor address
- !dx, index
- lods
- xchg ax,bx ! default
- xchg ax,cx ! number of cases
+ !bx, descriptor address
+ !ax, index
+ mov dx,(bx)
+ mov cx,2(bx)
+ add bx,4
dec cx
jl 2f
- cmp ax,dx
+ cmp ax,(bx)
jne 1b
- xchg ax,bx
+ mov bx,2(bx)
jnz 3f
@@ -7,27 +7,27 @@
.ciu:
.cui:
.cuu:
- ! pop bx, source size
+ ! pop dx, source size
! ax is low word of source
xor dx,dx
push ax ! to help debugging ?
@@ -5,9 +5,13 @@
.dup:
+ mov ax,si
mov si,sp
sub sp,cx
rep movs
+ mov si,ax
@@ -28,7 +28,7 @@
.extern .dvi4
call .dvi4
pop bx
- push cx
+ push dx
push ax
@@ -1,13 +1,15 @@
.sect .text; .sect .rom; .sect .data; .sect .bss
.define .dvi4
-yl=2
-yh=4
-xl=6
-xh=8
+yl=6
+yh=8
+xl=10
+xh=12
.dvi4:
mov si,sp ! copy of sp
mov bx,yl(si)
mov ax,yh(si)
@@ -42,7 +44,10 @@ xh=8
! cx is high order result
! ax is low order result
- ret 8
+ mov dx,cx
+ ret 8 ! result in ax/dx
7:
push dx ! sign of y
.extern .dvu4
call .dvu4
.define .dvu4
.dvu4:
@@ -22,7 +24,10 @@ xh=8
mov di,ax
@@ -4,18 +4,17 @@
.exg:
- mov dx,cx
- mov si,sp
- sub sp,cx
- rep movs
- add di,dx
- mov cx,dx
+ mov sp,di
+ add di,4
+ mov bx,di
+ add bx,cx
- mov sp,si
+1:
+ mov ax,(bx)
+ xchg ax,(di)
+ mov (bx),ax
+ loop 1b
+2:
@@ -3,15 +3,17 @@
.define .iaar
.iaar:
- pop bx
+ pop cx
cmp dx,2
.extern .unknown
jne .unknown
- pop si ! descriptor address
+ pop bx ! descriptor address
pop ax ! index
- pop di ! array base
- sub ax,(si)
- mul 4(si)
- add di,ax
+ pop dx ! array base
+ sub ax,(bx)
+ mul 4(bx)
+ mov bx,dx
+ push cx
@@ -3,14 +3,13 @@
.define .ilar
.ilar:
- pop di ! descriptor address
- pop si ! array base
- push bx
.extern .lar2
jmp .lar2
@@ -5,22 +5,24 @@
! bit # in ax
.inn:
- xor si,si
- mov di,8
- div di
+ mov bx,8
+ div bx
cmp ax,cx
- xchg ax,dx
- xchg ax,si ! ax:=si,si:=dx,does not change carry
jae 1f
- movb dl,bits(si)
- testb (di),dl
+ movb al,(bx)
+ testb al,bits(bx)
jz 1f
+ jmp 2f
+ pop bx
add sp,cx
! ax is result
@@ -5,6 +5,7 @@
.ior:
@@ -13,4 +14,5 @@
or ax,(di)
.define .isar
.isar:
- pop dx
- cmp dx,2
+ cmp ax,2
.extern .sar2
jmp .sar2
@@ -3,22 +3,33 @@
.define .lar2
.lar2:
- ! di, descriptor address
! ax, index
- ! si, base address
- sub ax,(di)
- mov cx,4(di)
+ pop dx ! base address
+ mov si,dx
+ mov cx,4(bx)
imul cx
add si,ax
jnb 1f
xorb ah,ah
lodsb
- sub sp,4(di)
+ pop dx ! saved si
+ mov ax,4(bx)
+ sub sp,ax
+ mov ax,di ! save di
+ mov di,ax
@@ -3,18 +3,26 @@
.define .loi
- ! source address in si
+ ! address in bx
+ ! save si/di. they might be register variables
.loi:
+ mov dx,si
+ mov si,bx
+ mov bx,ax
+ mov ax,cx
- sub sp,dx
+ mov ax,di
@@ -13,15 +13,27 @@
- mov dx,bx
cmp ax,4
- pop ax
- push dx
- jmp .mli4
+ push bx
+ mov cx,bx
+ mov ax,2(bx)
+ mov 2(bx),ax
+ mov ax,6(bx)
+ mov 4(bx),ax
+ mov ax,8(bx)
+ mov 6(bx),ax
+ mov 8(bx),cx
+ pop dx
+ jsr .mli4
+ push ax
.extern EODDZ
.extern .trp
@@ -2,17 +2,24 @@
.define .mli4
- ! x * y with
- ! x.low = si x.high = di
- ! y.low = bx y.high = ax
+yl=2
+yh=4
+ ! x * y
+ ! xl in ax
+ ! xh in dx
.mli4:
- mul si ! xl*yh
- mov cx,ax
- mov ax,di
- mul bx ! xh*yl
- add cx,ax ! xh*yl+xl*yh
- mov ax,si
- mul bx ! xl*yl
+ mov cx,ax
+ mul yh(bx) ! xl*yh
+ mov ax,dx
+ mul yl(bx) ! xh * yl
+ add dx,ax ! xh*yl+xl*yh
+ mul yl(bx) ! xl*yl
- ret
+ ret 4
@@ -2,12 +2,12 @@
.define .rck
- ! descriptor address in si
+ ! descriptor address in bx
! value in ax, must be left there
.rck:
- cmp ax,(si)
- cmp ax,2(si)
+ cmp ax,2(bx)
jg 2f
@@ -27,10 +27,10 @@
.extern .rmi4
call .rmi4
- jmp ax
@@ -2,12 +2,14 @@
.define .rmi4
.rmi4:
@@ -41,6 +43,10 @@ xh=8
! bx is high order result
! dx is low order result
+ mov dx,bx ! result in ax/dx
ret 8
.extern .rmu4
call .rmu4
.define .rmu4
.rmu4:
@@ -25,7 +27,11 @@ xh=8
+ mov dx,bx
@@ -3,21 +3,31 @@
.define .sar2
.sar2:
- ! di, base address
- mov cx,4(si)
+ xchg di,dx ! di = base address, dx is saved di
add di,ax
pop ax
stosb
mov sp,si
@@ -8,27 +8,32 @@
!ifdef create set
- sub di,cx
+ sub sp,cx
+ xor di,di
+ sar cx,1
- cmp sp,di
- ja 1b
+ mov dx,4(di)(bx)
+ add di,2
!endif
- cmp ax,cx
+ cmp ax,di
jae 2f
+ movb dl,bits(di)
- mov si,dx
- orb (di),dl
+ orb 4(di),dl
.extern ESET
mov ax,ESET
jmp .trp
@@ -3,16 +3,24 @@
.define .sti
- ! destination address in di
+ ! save di/si. they might be register variables
.sti:
+ mov dx,di ! save di
+ pop ax ! return address
+ mov di,bx
+ mov bx,si
.xor:
xor ax,(di)