[deutsch] :
[back] :
[main page] |
![]() |
Re NETSCAPE, or other such stuff:
Compiling the assembly sources, which are all prepared for and tested
in Linux-i386/ELF systems, only, requires the patched version 0.98-3.1
(mailme for a tar.gz package)
of "nasm" & "asmutils" 0.09+ -
(latest version).
And, there is a new (9/2000), easy to handle debugger, "ald".
Below mentioned programs/texts are all "experimental software/information" where no warranty at all applies, licensed for non-commercial use, only, and according to the QT License (unless stated or explicitely agreed upon). License is not valid if regardless of whatever reason the licensing terms and conditions are not fully accepted and met.
// zcount ( p1 -- p1 u ) // find length u of <nul> terminated strig at p1. u := 0 if p1 = 0. // in: eax = string address; edi = data-stack ptr // out: eax:= string length, (-4(edi)) := string address zcount: testl eax,eax stosl # dup stg address, push eax into dstack jz 5f # ? zero address pushl edx pushl ecx 2: cmpb $0,(eax) # realign pointer on dword boundaries jz 1f incl eax testl $3,eax jnz 2b 3: movl (eax),edx # 4 bytes per test lea 0xfefefeff(edx),ecx notl edx andl ecx,edx addl $4,eax testl $0x80808080,edx jz 3b # ? not a <nul> byte 4: shrl $8,edx # check first lo byte inc eax jnc 4b # ? bit 7 un-set, not a <nul> posn subl $5,eax # realign pointer to null char 1: popl ecx popl edx subl -4(edi),eax # eax:=length 5: ret
input x, p := 0, a := 0 loop 1 to #bits(x)/2 shift left x into a 2 places shift left p one place if a > 2*p then a:=a-(2*p+1); p:=p+1 end return pno(t much) more expensive than the rsp. bitwise division and, faster than with Newton's algorithm.
// udsqrt ( ud1 -- ud2 j ) // ud2 := +ve sqare root of double |ud1|; j := -1 if ud1 signed < 0. // ud2 is nearest integer the sqare of which is lower or equal |ud1|*(2j-1). // in: eax = hi 32bit; -4(edi) = lo 32bit; edi = data-stack ptr // out: eax:=sign flag; (-4(edi)):= 0; (-8(edi)):= 32bit result udsqrt: pushl ebx pushl eax # save sign cell for "j" stosl # push @tos=eax into dstack pushl ecx # ..regs pushl edx xorl eax,eax # clr @tos, for a & p pushl esi pushl ebp stosl # dup ( ud1.lo ud1.hi 0 0 -- ... ) pushl $31 # bit-count/2 movl -8(edi),esi # x.hi movl -12(edi),ebp # x.lo movl eax,-12(edi) movl eax,-8(edi) # p := TOS(3) movl eax,edx # a := edx.hi:eax.lo 2: movl -8(edi),ebx # p.temp=ecx|ebx movl -12(edi),ecx addl ecx,ecx adcl ebx,ebx # p := 2p movl ecx,-12(edi) # save p, intermediate result movl ebx,-8(edi) addl ecx,ecx adcl ebx,ebx # p := 2p shldl $2,eax,edx # a.hi<-a.lo shldl $2,esi,eax # a.lo<-x.hi a=4*a+[2 m.s.b (x)] shldl $2,ebp,esi # x.hi<-x.lo shll $2,ebp # <- x := 4x subl eax,ecx sbbl edx,ebx # t := t-a jnc 1f # a <= t notl ecx notl ebx # t := -(t-a)-1 = a-(2p+1) movl ecx,eax # a := t movl ebx,edx addl $1,-12(edi) adcl $0,-8(edi) # p':= p+1 1: decl (esp) jns 2b addl $4,esp # drop counter popl ebp popl esi popl edx # ..regs popl ecx subl $4,edi # drop temp popl eax # sign x popl ebx sarl $31,eax # "j" ret
fastly stabilizing continuous product (algorithmus borisi). Done if overflowing or, x^(1/(2^n)) == x^(1/(2^(n-1))).
terminate if x/n == 0 or the factorial of n excedes the representable range (33).
terminate if m == 0 or if an arbitrarily chosen loop limit (e.g. 255) reached.
terminate if x(n) == 0 or, factorial of 2n excedes representable range (n=16).
/* ; word header for a 4th primitive .macro __CODE lex=0,name,label,prev=0,mod=0 __DATASEG__ .long \label .ifndef n0 n0: .long 0 /* ; set linkage base .else .long 10001b /* ; link to previous header .endif 10001: n\label: .byte (10000f-1-.)|(\lex&-32) .ascii "\name" 10000: _NAME = n\label _NTOP =. /* ; always last of all refs, due to 'preprocessing'! __CODESEG__ .endmNote the 'local' label <10001> by which consecutive __CODE blocks link to eachother.
25 .set otto,0 26 .set emil,0 27 0028 00000000 1: .long emil,otto 27 00000000 28 .set otto,.-1b 29 30 .set emil,-1 31 0030 FFFFFFFF 1: .long emil,otto 31 00000000 32 .set otto,.-1b 33 34 0038 00000000 .long otto 35 .end
%define _message_ %imacro _message 0-*.nolist %if %0>0 %xdefine _msg_ %rep %0 %xdefine _msg_ _msg_ %{1} %rotate 1 %endrep %error "_msg_" %endif %endmacrouse <%ifdef _message_> before to determine whether that macro - which my "private" version supplies - is already compiled into "nasm".
#!/bin/sh # hp - Son Mär 18 18:03:22 GMT 2001 # <aumac-nolist> filename appends "_nolist" to %macro lines in filename # $1: infile substitute w. modified file # $1: infile $2:outfile send $1 modified to $2 # infile f=${1} # don't operate on self [ "${f}" == "$(basename ${0})" ]&&exit 0 # outfile; use temp. for in=out # ret immediately if no macro found [ -z "${2}" ]&& { grep "^\%macro\ " ${f} 2> /dev/null||exit 0 o=${f}$$ }|| { o=${2} grep "^\%macro\ " ${f} 2> /dev/null||{ cp ${f} ${o};exit 0; } } # inhbit shell word processing, read line by line IFS= # read infile, find macro & append _nolist, copy line by line to (temp.) outfile cat -v "${f}"|while read 'i' do [ -n "$(echo "${i}"|grep "^\%macro\ "|grep -v "[_\.]nolist")" ]&& echo "${i}_nolist">>${o}|| echo "${i}">>${o} done [ "${o}" == "${f}$$" ]&&mv -f ${o} ${f} # aumac-nolist <eof>
cpuid cmovwhich returns a non-zero flag if it does or, "0" if not.
/usr/src/Asm/nasm/nasm -felf -olib4th.o lib4th.asm 2> lib4th.asm.log cat lib4th.asm.log|grep -v warning && rm lib4th.o || rm lib4th.asm.logwhich removes the resultant binary if the error channel did emit any non-"warning" text.
%macro something 3 %xdefine p1 %{1} %xdefine p2 %{2} %xdefine p3 %{3} %error "arg 1:p1, 2:p2, 3:p3" ... ; macro defn %endmwhich during assembly will display the args.
The patched version will also be capable of some, though still very limited, string handling and messages reporting which contain assembly generated variable values.
I'd search the net for a reliable (Intel style!) alternative, but didn't succeed. If there is any hint, pse. mail me.