Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  login

If it has syntax, it isn't user friendly.


programming / comp.lang.asm.x86 / Re: Comparing to zero [test]

SubjectAuthor
* Comparing to zeroluserdroog
`* Re: Comparing to zeroluserdroog
 +- Re: Comparing to zeroluserdroog
 `* Re: Comparing to zerowolfgang kern
  `- Re: Comparing to zero [test]olcott

1
Subject: Comparing to zero
From: luserdroog
Newsgroups: comp.lang.asm.x86
Organization: A noiseless patient Spider
Date: Thu, 27 Aug 2020 20:06 UTC
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: luser.dr...@nospicedham.gmail.com (luserdroog)
Newsgroups: comp.lang.asm.x86
Subject: Comparing to zero
Date: Thu, 27 Aug 2020 13:06:13 -0700 (PDT)
Organization: A noiseless patient Spider
Lines: 24
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <f1a8a6c9-7074-4afd-a274-fd03c8cc5d27o@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Thu, 27 Aug 2020 20:06:14 +0000
Injection-Info: reader02.eternal-september.org; posting-host="a9aad0faff67f6c7ddb49cc05463f492";
logging-data="27261"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18sKxFjP6YiOj/Vat2nzgbnRh/TinTMA+I="
User-Agent: G2/1.0
Cancel-Lock: sha1:MezBrorGiDMv5enYE7icIYwCxaQ=
View all headers
Hi everyone,

I'm working on primitives for my newly working forth interpreter and I'm
having difficulty with comparisons 0= 0> and 0> . These each take a
number from the stack and push 0 or all-bits-1.

My code for 0= and 0> appear to be producing results, but I get the wrong
result for 0< even though it seems to follow appropriate parallel logic
as 0>. Any ideas? Does this suggest a bug in assembly or in my emulator?

CODE(0=,     zeroeq,    POP(AX),MOVCXI(1,0), CMP(,R,AX,CX), SBB(,R,AX,AX), PUSH(AX))
CODE(0>,     zerogt,    POP(AX),MOVCXI(0,0), CMP(,R,AX,CX), JL,3,MOVCXI(0xff,0xff), PUSH(CX))
CODE(0<,     zerolt,    POP(AX),MOVCXI(0,0), CMP(,R,AX,CX), JG,3,MOVCXI(0xff,0xff), PUSH(CX))

testing:
WORD(run,    run,       c_lit,0, c_zeroeq, c_dot,
                        c_lit,12, c_zerogt, c_dot,
                        c_lit,minus(50), c_zerolt, c_dot,
                        c_lit,79,c_emit, c_lit,75,c_emit, c_lit,5,c_double,c_emit, c_bye)

output:
$ ./a8086
110OK



Subject: Re: Comparing to zero
From: luserdroog
Newsgroups: comp.lang.asm.x86
Organization: A noiseless patient Spider
Date: Fri, 28 Aug 2020 00:48 UTC
References: 1
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: luser.dr...@nospicedham.gmail.com (luserdroog)
Newsgroups: comp.lang.asm.x86
Subject: Re: Comparing to zero
Date: Thu, 27 Aug 2020 17:48:47 -0700 (PDT)
Organization: A noiseless patient Spider
Lines: 62
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <df96a726-3b25-4319-b228-5e73a28caf51o@googlegroups.com>
References: <f1a8a6c9-7074-4afd-a274-fd03c8cc5d27o@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Fri, 28 Aug 2020 00:48:48 +0000
Injection-Info: reader02.eternal-september.org; posting-host="54d7ab3e55e54a4ca4e5153fd71857bd";
logging-data="4327"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+KhqevjXK6zbw4fwDiKaohB32AP6nCXNY="
User-Agent: G2/1.0
Cancel-Lock: sha1:dwjtJj3kMPTOHMPzeBksrpgChHA=
View all headers
On Thursday, August 27, 2020 at 3:12:28 PM UTC-5, luserdroog wrote:
Hi everyone,

I'm working on primitives for my newly working forth interpreter and I'm
having difficulty with comparisons 0= 0> and 0> . These each take a
number from the stack and push 0 or all-bits-1.

My code for 0= and 0> appear to be producing results, but I get the wrong
result for 0< even though it seems to follow appropriate parallel logic
as 0>. Any ideas? Does this suggest a bug in assembly or in my emulator?

CODE(0=,     zeroeq,    POP(AX),MOVCXI(1,0), CMP(,R,AX,CX), SBB(,R,AX,AX), PUSH(AX))
CODE(0>,     zerogt,    POP(AX),MOVCXI(0,0), CMP(,R,AX,CX), JL,3,MOVCXI(0xff,0xff), PUSH(CX))
CODE(0<,     zerolt,    POP(AX),MOVCXI(0,0), CMP(,R,AX,CX), JG,3,MOVCXI(0xff,0xff), PUSH(CX))

testing:
WORD(run,    run,       c_lit,0, c_zeroeq, c_dot,
                        c_lit,12, c_zerogt, c_dot,
                        c_lit,minus(50), c_zerolt, c_dot,
                        c_lit,79,c_emit, c_lit,75,c_emit, c_lit,5,c_double,c_emit, c_bye)

output:
$ ./a8086
110OK

I changed JL to JLE and JG to JGE. Still not right.
Here's a trace through zerogt.

ax:01f6 cx:0001 dx:0030 bx:01f8 sp:0ffe bp:2000 si:05ac di:0000 ip:01f8 fl:0004 NC NO NS NZ
58(130) popax:
ax:000c cx:0001 dx:0030 bx:01f8 sp:1000 bp:2000 si:05ac di:0000 ip:01f9 fl:0004 NC NO NS NZ
b9(271) movcxi: 00(000) 00(000)
ax:000c cx:0000 dx:0030 bx:01f8 sp:1000 bp:2000 si:05ac di:0000 ip:01fc fl:0004 NC NO NS NZ
3b(073) cmpwt: c8(310) x:0 y:12 ->fffffff4
ax:000c cx:0000 dx:0030 bx:01f8 sp:1000 bp:2000 si:05ac di:0000 ip:01fe fl:0891 CA OV SN NZ
7e(176) jle: 03(003) <0>
ax:000c cx:0000 dx:0030 bx:01f8 sp:1000 bp:2000 si:05ac di:0000 ip:0200 fl:0891 CA OV SN NZ
b9(271) movcxi: ff(377) ff(377)
ax:000c cx:ffff dx:0030 bx:01f8 sp:1000 bp:2000 si:05ac di:0000 ip:0203 fl:0891 CA OV SN NZ
51(121) pushcx:
ax:000c cx:ffff dx:0030 bx:01f8 sp:0ffe bp:2000 si:05ac di:0000 ip:0204 fl:0891 CA OV SN NZ


It should be comparing 0 and 12, so it should take 0-12 and set
zf=0 sf=1 and of=1. Then JLE should jump if (sf^of)|zf which is 0.
And it seems to be doing all that. Maybe I'm just using CMP wrong?

The description from the 8086 family manual:

CMP destination,source
CMP (Compare) subtracts the source from the destination, which may be
bytes or words, but does not return the result. The operands are
unchanged, but the flags are updated and can be tested by a subsequent
conditional jump instruction. CMP updates AF, CF, OF, PF, SF and ZF.
The comparison reflected in the flags is that of the destination to
the source. IF a CMP instruction is followed by a JG (jump if greater)
instruction, for example, the jump is taken if the destination operand
is greater than the source operand.

So, in "CMP CX=0,AX=12" CX is the destination. So 0-12. Hmmm.
I still don't get it. But all the pieces seem to be here....



Subject: Re: Comparing to zero
From: luserdroog
Newsgroups: comp.lang.asm.x86
Organization: A noiseless patient Spider
Date: Fri, 28 Aug 2020 06:22 UTC
References: 1 2
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: luser.dr...@nospicedham.gmail.com (luserdroog)
Newsgroups: comp.lang.asm.x86
Subject: Re: Comparing to zero
Date: Thu, 27 Aug 2020 23:22:02 -0700 (PDT)
Organization: A noiseless patient Spider
Lines: 41
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <3ff2fa1e-f40a-445d-937b-66462d03c6cco@googlegroups.com>
References: <f1a8a6c9-7074-4afd-a274-fd03c8cc5d27o@googlegroups.com> <df96a726-3b25-4319-b228-5e73a28caf51o@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Fri, 28 Aug 2020 06:22:03 +0000
Injection-Info: reader02.eternal-september.org; posting-host="54d7ab3e55e54a4ca4e5153fd71857bd";
logging-data="24985"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+QEVrmbme6F+LqNTCEg1N7slAVvhfOIB4="
User-Agent: G2/1.0
Cancel-Lock: sha1:nnJ4OD7UStbjl0RJSNNyxA2en/E=
View all headers
On Thursday, August 27, 2020 at 8:01:51 PM UTC-5, luserdroog wrote:
On Thursday, August 27, 2020 at 3:12:28 PM UTC-5, luserdroog wrote:
Hi everyone,

I'm working on primitives for my newly working forth interpreter and I'm
having difficulty with comparisons 0= 0> and 0> . These each take a
number from the stack and push 0 or all-bits-1.

My code for 0= and 0> appear to be producing results, but I get the wrong
result for 0< even though it seems to follow appropriate parallel logic
as 0>. Any ideas? Does this suggest a bug in assembly or in my emulator?

[snip]

So, in "CMP CX=0,AX=12" CX is the destination. So 0-12. Hmmm.
I still don't get it. But all the pieces seem to be here....

I went to the fig-forth source and adapted that and now it appears
to be working.

CODE(0=,    zeq,       POP(AX), OR(,R,AX,AX), MOVAXI(0xff,0xff), JZ,2,INC_(R,AX), PUSH(AX))
CODE(0<,    zless,     POP(AX), OR(,R,AX,AX), MOVAXI(0xff,0xff), JL,2,INC_(R,AX), PUSH(AX))
CODE(0>,    zmore,     POP(AX), OR(,R,AX,AX), MOVAXI(0xff,0xff), JG,2,INC_(R,AX), PUSH(AX))
....
WORD(run,   run,       c_lit,0, c_zeq, c_dot,
                       c_lit,2, c_zeq, c_dot,
                       c_lit,12,            c_zless, c_dot,
                       c_lit,1+(0xffff^50), c_zless, c_dot,
                       c_lit,12,            c_zmore, c_dot,
                       c_lit,1+(0xffff^50), c_zmore, c_dot,
                       c_ok, c_bye)

$ !m
make a8086 CFLAGS='-g -Og'
cc -g -Og    a8086.c   -o a8086
$ !.
../a8086
100110OK

So the values all make sense now.



Subject: Re: Comparing to zero
From: wolfgang kern
Newsgroups: comp.lang.asm.x86
Organization: KESYS-development
Date: Fri, 28 Aug 2020 06:27 UTC
References: 1 2
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: nowh...@nospicedham.never.at (wolfgang kern)
Newsgroups: comp.lang.asm.x86
Subject: Re: Comparing to zero
Date: Fri, 28 Aug 2020 08:27:54 +0200
Organization: KESYS-development
Lines: 79
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <ria85d$3uv$1@gioia.aioe.org>
References: <f1a8a6c9-7074-4afd-a274-fd03c8cc5d27o@googlegroups.com>
<df96a726-3b25-4319-b228-5e73a28caf51o@googlegroups.com>
Reply-To: nowhere@never.at
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="54d7ab3e55e54a4ca4e5153fd71857bd";
logging-data="25010"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18oLQ4em4NQJrW/Z5ogBvkfD/ijdIz6LXA="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.1.1
Cancel-Lock: sha1:prskbIj1bc97mgYD1uHWSvW/cD4=
View all headers
On 28.08.2020 02:48, luserdroog wrote:
On Thursday, August 27, 2020 at 3:12:28 PM UTC-5, luserdroog wrote:
Hi everyone,

I'm working on primitives for my newly working forth interpreter and I'm
having difficulty with comparisons 0= 0> and 0> . These each take a
number from the stack and push 0 or all-bits-1.

My code for 0= and 0> appear to be producing results, but I get the wrong
result for 0< even though it seems to follow appropriate parallel logic
as 0>. Any ideas? Does this suggest a bug in assembly or in my emulator?

CODE(0=,     zeroeq,    POP(AX),MOVCXI(1,0), CMP(,R,AX,CX), SBB(,R,AX,AX), PUSH(AX))
CODE(0>,     zerogt,    POP(AX),MOVCXI(0,0), CMP(,R,AX,CX), JL,3,MOVCXI(0xff,0xff), PUSH(CX))
CODE(0<,     zerolt,    POP(AX),MOVCXI(0,0), CMP(,R,AX,CX), JG,3,MOVCXI(0xff,0xff), PUSH(CX))

testing:
WORD(run,    run,       c_lit,0, c_zeroeq, c_dot,
                         c_lit,12, c_zerogt, c_dot,
                         c_lit,minus(50), c_zerolt, c_dot,
                         c_lit,79,c_emit, c_lit,75,c_emit, c_lit,5,c_double,c_emit, c_bye)

output:
$ ./a8086
110OK

I changed JL to JLE and JG to JGE. Still not right.
Here's a trace through zerogt.

ax:01f6 cx:0001 dx:0030 bx:01f8 sp:0ffe bp:2000 si:05ac di:0000 ip:01f8 fl:0004 NC NO NS NZ
58(130) popax:
ax:000c cx:0001 dx:0030 bx:01f8 sp:1000 bp:2000 si:05ac di:0000 ip:01f9 fl:0004 NC NO NS NZ
b9(271) movcxi: 00(000) 00(000)
ax:000c cx:0000 dx:0030 bx:01f8 sp:1000 bp:2000 si:05ac di:0000 ip:01fc fl:0004 NC NO NS NZ
3b(073) cmpwt: c8(310) x:0 y:12 ->fffffff4
ax:000c cx:0000 dx:0030 bx:01f8 sp:1000 bp:2000 si:05ac di:0000 ip:01fe fl:0891 CA OV SN NZ
7e(176) jle: 03(003) <0>
ax:000c cx:0000 dx:0030 bx:01f8 sp:1000 bp:2000 si:05ac di:0000 ip:0200 fl:0891 CA OV SN NZ
b9(271) movcxi: ff(377) ff(377)
ax:000c cx:ffff dx:0030 bx:01f8 sp:1000 bp:2000 si:05ac di:0000 ip:0203 fl:0891 CA OV SN NZ
51(121) pushcx:
ax:000c cx:ffff dx:0030 bx:01f8 sp:0ffe bp:2000 si:05ac di:0000 ip:0204 fl:0891 CA OV SN NZ


It should be comparing 0 and 12, so it should take 0-12 and set
zf=0 sf=1 and of=1. Then JLE should jump if (sf^of)|zf which is 0.
And it seems to be doing all that. Maybe I'm just using CMP wrong?

The description from the 8086 family manual:

CMP destination,source
CMP (Compare) subtracts the source from the destination, which may be
bytes or words, but does not return the result. The operands are
unchanged, but the flags are updated and can be tested by a subsequent
conditional jump instruction. CMP updates AF, CF, OF, PF, SF and ZF.
The comparison reflected in the flags is that of the destination to
the source. IF a CMP instruction is followed by a JG (jump if greater)
instruction, for example, the jump is taken if the destination operand
is greater than the source operand.

So, in "CMP CX=0,AX=12" CX is the destination. So 0-12. Hmmm.
I still don't get it. But all the pieces seem to be here....


x86 Conditions:
O,  NO
C,  NC  aka B, NB    aka <, >=
Z,  NZ  aka E, NE    aka =, <>
NA, A   aka BE,NBE   aka <=,>   aka ZorC, aka NCNZ
S,  NS               aka -, +
PE, PO  aka P, NP

L,  NL  aka NGE,GE aka  <0,>=0
NG, G   aka LE,NLE aka <=0, >0

only the last four and S/NS work signed
__
wolfgang



Subject: Re: Comparing to zero [test]
From: olcott
Newsgroups: comp.lang.asm.x86
Organization: A noiseless patient Spider
Date: Sun, 30 Aug 2020 18:45 UTC
References: 1 2 3
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: NoO...@NoWhere.com (olcott)
Newsgroups: comp.lang.asm.x86
Subject: Re: Comparing to zero [test]
Date: Sun, 30 Aug 2020 13:45:50 -0500
Organization: A noiseless patient Spider
Lines: 97
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <zs2dnQYe4sNCbtbCnZ2dnUU7-WednZ2d@giganews.com>
References: <f1a8a6c9-7074-4afd-a274-fd03c8cc5d27o@googlegroups.com>
<df96a726-3b25-4319-b228-5e73a28caf51o@googlegroups.com>
<ria85d$3uv$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="5970141a266d4c6c423ed544a077f490";
logging-data="6470"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+dTeutO12WiahrVqSjuFWCPFwVm/ViL4A="
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101
Thunderbird/68.12.0
Cancel-Lock: sha1:rf2UVxndJtRkPeGQ9vr1FE7I97M=
View all headers
On 8/28/2020 1:27 AM, wolfgang kern wrote:
On 28.08.2020 02:48, luserdroog wrote:
On Thursday, August 27, 2020 at 3:12:28 PM UTC-5, luserdroog wrote:
Hi everyone,

I'm working on primitives for my newly working forth interpreter and I'm
having difficulty with comparisons 0= 0> and 0> . These each take a
number from the stack and push 0 or all-bits-1.

My code for 0= and 0> appear to be producing results, but I get the wrong
result for 0< even though it seems to follow appropriate parallel logic
as 0>. Any ideas? Does this suggest a bug in assembly or in my emulator?

CODE(0=,     zeroeq,    POP(AX),MOVCXI(1,0), CMP(,R,AX,CX), SBB(,R,AX,AX), PUSH(AX))
CODE(0>,     zerogt,    POP(AX),MOVCXI(0,0), CMP(,R,AX,CX), JL,3,MOVCXI(0xff,0xff), PUSH(CX))
CODE(0<,     zerolt,    POP(AX),MOVCXI(0,0), CMP(,R,AX,CX), JG,3,MOVCXI(0xff,0xff), PUSH(CX))

testing:
WORD(run,    run,       c_lit,0, c_zeroeq, c_dot,
                         c_lit,12, c_zerogt, c_dot,
                         c_lit,minus(50), c_zerolt, c_dot,
                         c_lit,79,c_emit, c_lit,75,c_emit, c_lit,5,c_double,c_emit, c_bye)

output:
$ ./a8086
110OK

I changed JL to JLE and JG to JGE. Still not right.
Here's a trace through zerogt.

ax:01f6 cx:0001 dx:0030 bx:01f8 sp:0ffe bp:2000 si:05ac di:0000 ip:01f8 fl:0004 NC NO NS NZ
58(130) popax:
ax:000c cx:0001 dx:0030 bx:01f8 sp:1000 bp:2000 si:05ac di:0000 ip:01f9 fl:0004 NC NO NS NZ
b9(271) movcxi: 00(000) 00(000)
ax:000c cx:0000 dx:0030 bx:01f8 sp:1000 bp:2000 si:05ac di:0000 ip:01fc fl:0004 NC NO NS NZ
3b(073) cmpwt: c8(310) x:0 y:12 ->fffffff4
ax:000c cx:0000 dx:0030 bx:01f8 sp:1000 bp:2000 si:05ac di:0000 ip:01fe fl:0891 CA OV SN NZ
7e(176) jle: 03(003) <0>
ax:000c cx:0000 dx:0030 bx:01f8 sp:1000 bp:2000 si:05ac di:0000 ip:0200 fl:0891 CA OV SN NZ
b9(271) movcxi: ff(377) ff(377)
ax:000c cx:ffff dx:0030 bx:01f8 sp:1000 bp:2000 si:05ac di:0000 ip:0203 fl:0891 CA OV SN NZ
51(121) pushcx:
ax:000c cx:ffff dx:0030 bx:01f8 sp:0ffe bp:2000 si:05ac di:0000 ip:0204 fl:0891 CA OV SN NZ


It should be comparing 0 and 12, so it should take 0-12 and set
zf=0 sf=1 and of=1. Then JLE should jump if (sf^of)|zf which is 0.
And it seems to be doing all that. Maybe I'm just using CMP wrong?

The description from the 8086 family manual:

CMP destination,source
CMP (Compare) subtracts the source from the destination, which may be
bytes or words, but does not return the result. The operands are
unchanged, but the flags are updated and can be tested by a subsequent
conditional jump instruction. CMP updates AF, CF, OF, PF, SF and ZF.
The comparison reflected in the flags is that of the destination to
the source. IF a CMP instruction is followed by a JG (jump if greater)
instruction, for example, the jump is taken if the destination operand
is greater than the source operand.

So, in "CMP CX=0,AX=12" CX is the destination. So 0-12. Hmmm.
I still don't get it. But all the pieces seem to be here....


x86 Conditions:
O,  NO
C,  NC  aka B, NB    aka <, >=
Z,  NZ  aka E, NE    aka =, <>
NA, A   aka BE,NBE   aka <=,>   aka ZorC, aka NCNZ
S,  NS               aka -, +
PE, PO  aka P, NP

L,  NL  aka NGE,GE aka  <0,>=0
NG, G   aka LE,NLE aka <=0, >0

only the last four and S/NS work signed
__
wolfgang


test
--
Copyright 2020 Pete Olcott



1
rocksolid light 0.7.2
clearneti2ptor