Jump to content



1

Rich BASIC2GPL Compiler


30 replies to this topic

#1 RXB OFFLINE  

RXB

    Dragonstomper

  • 539 posts
  • Location:Vancouver, Washington, USA

Posted Wed Oct 26, 2011 6:29 PM

I have started work on a BASIC to GPL Compiler.

It uses the same REA (Editor Assembler) so other then XB and Assembler it is the same module.

Option 2 Assembler is replaced with COMPILER that takes BASIC list files and turns them into GPL Source files.

As they are GPL Source files you can edit the results before you use the GPL Assembler to turn them into OBJECT Code.

A XB version will include a utility to strip XB list files from Mulit statement to Single statement files for the Compiler to better work.

#2 OLD CS1 OFFLINE  

OLD CS1

    Moonsweeper

  • 392 posts
  • IT Samurai
  • Location:Tallahassee, FL

Posted Wed Oct 26, 2011 7:03 PM

Damn. Awesome work, thanks, Rich.

#3 retroclouds OFFLINE  

retroclouds

    Stargunner

  • 1,096 posts
  • Location:Germany

Posted Wed Oct 26, 2011 11:32 PM

Yeah, that's interesting news! I think the compilers around until now all compile to assembly language and none to GPL.
I presume that with your profound background knowledge on both GPL and the (Extended) Basic interpreter you should be able to pull this of and make this a fun project.

:thumbsup: :thumbsup: :thumbsup:

#4 RXB OFFLINE  

RXB

    Dragonstomper

  • 539 posts
  • Location:Vancouver, Washington, USA

Posted Thu Oct 27, 2011 12:02 AM

It should be remarkably easy as BASIC and XB are written in GPL so not like I can not find the subroutine to pull it off.
Th next step from GPL should also be pretty easy to pull off as GPL is written in Assembly.
The last step would be to take the BASIC and make Assembly Compiler that should be remarkably accurate and easy to use.
Any project should be taken in steps to get a better project. The smaller the steps the better the project looks.

#5 Willsy OFFLINE  

Willsy

    Dragonstomper

  • 765 posts
  • Location:Uzbekistan (no, really!)

Posted Thu Oct 27, 2011 2:56 AM

The only difficult thing I can think of is the evaluation of complex expressions:

X=INT(A*RND(B))+COS©/(ATN(Z)*PI+(32*(T-3/RND(F)))

You get the idea. You need to evaluate according to the order of precedence. You need stacks for that. :thumbsup:

#6 RXB OFFLINE  

RXB

    Dragonstomper

  • 539 posts
  • Location:Vancouver, Washington, USA

Posted Thu Oct 27, 2011 3:34 AM

View PostWillsy, on Thu Oct 27, 2011 2:56 AM, said:

The only difficult thing I can think of is the evaluation of complex expressions:

X=INT(A*RND(B))+COS©/(ATN(Z)*PI+(32*(T-3/RND(F)))

You get the idea. You need to evaluate according to the order of precedence. You need stacks for that. :thumbsup:

I am going to include the standard floating point into the package so it is exactly the same as BASIC or XB so you can do this, but the trade off will still be that it slows the program down.

My goal is to do a straight across conversion from XB or BASIC to GPL. Then do the next step to go Assembly.

#7 unhuman OFFLINE  

unhuman

    Dragonstomper

  • 784 posts
  • Location:Vienna, VA

Posted Thu Oct 27, 2011 7:09 AM

Holy craps. So much excitement for me!

#8 Tursi OFFLINE  

Tursi

    Stargunner

  • 1,448 posts
  • Location:SJC

Posted Fri Oct 28, 2011 2:25 PM

Not the first, as part of my MPD project I released an XB to GPL compiler: http://www.harmlessl...om/software/gpl

it was pretty hacky and very limited, I only used it to make writing the configuration code easier, but I had intended to extend the project if it gathered any interest. It didn't, though, so I left it be. ;) It's written in C so runs on a PC to do the conversion. Full source is included.

Dunno if it'll be useful to you to take a peek at it or not, Rich, but you are welcome to borrow from it if anything is valuable to you!

#9 RXB OFFLINE  

RXB

    Dragonstomper

  • 539 posts
  • Location:Vancouver, Washington, USA

Posted Fri Oct 28, 2011 3:32 PM

Thanks Tursi I will take a good look at it.

Rich

#10 RXB OFFLINE  

RXB

    Dragonstomper

  • 539 posts
  • Location:Vancouver, Washington, USA

Posted Sun Oct 30, 2011 7:29 PM

Here is some the source code for XB to GPL Compiler.
Most are debugged but some I still need to work on. They are all Floating Point based just like XB.
Left side is the input after the name, after FPT is the output.
* PI (@FAC) FLP (@FAC)
PI MOVE 8,G@CONPI,@FAC
   RTN
CONPI BYTE >40,3.14,15,92,65,35,90
* MAX (@FAC,@ARG) FLP (@FAC)
MAX GT
    BR MAXO
MAXO MOVE 8,@ARG,@FAC
MAX1 RTN
* MIN (@FAC,@ARG) FLP (@FAC)
MIN GT
    BR MAXO
    RTN
* INTRND FLP
INTRND MOVE 10,G@X2SEED,V@RNDX2
	   RTN
X2SEED BYTE >42,>03,>23,>15,>00
X1SEED BYTE >43,>02,>3E,>2A,>17
* RND (@FAC) FLP
RND MOVE 5,V@RNDX1,@FAC
    CLR @FAC5
    DCLR @FAC6
    XML VPUSH
    MOVE 8,G@RNDA1,@ARG
    XML FMUL
    MOVE 8,G@RNDC1,@ARG
    XML FADD
    XML VPUSH
    MOVE 8,G@RNDEM,@ARG
    XML MFUL
    CALL GRINT
    XML VPUSH
    MOVE 8,G@RNDEP,@ARG
    XML FMUL
    DSUB 8,@VSPTR
    XML SSUB
    MOVE 5,@FAC,V@RNDX1
    XML VPUSH
    MOVE 5,V@RNDX2,@FAC
    CLR  @FAC5
    DCLR @FAC6
    MOVE 8,G@RNDA1,@ARG
    XML FMUL
    DADD 8,@VSPTR
    XML VPUSH
    DSUB 24,@VSPTR
    XML VPOP
    DADD 32,@VSPTR
    MOVE 8,G@RNDA2,@ARG
    XML FMUL
    XML SADD
    MOVE 8,G@RNDA2,@ARG
    XML FADD
    XML SADD
    DSUB 16,@VSPTR
    XML VPUSH
    CALL GRINT
    MOVE 8,G@RNDEP,@ARG
    XML FMUL
    XML SSUB
    MOVE 5,@FAC,V@RNDX2
    MOVE 8,G@RNDEM,@ARG
    XML FMUL
    XML VPUSH
    DADD 8,@VSPTR
    XML VPOP
    XML FMUL
    XML FMUL
    XML SADD
    RTN
RNDA2 BYTE >43,>01,>2B,>59,>52,>00,>00,>00
RNDA1 BYTE >42,>2A,>08,>15,>00,>00,>00,>00
RNDC2 BYTE >43,>02,>0B,>20,>30,>00,>00,>00
RNDC1 BYTE >43,>06,>36,>05,>13,>00,>00,>00
RNDEP BYTE >43,>0A,>00,>00,>00,>00,>00,>00
RNDEM BYTE >3C,>0A,>00,>00,>00,>00,>00,>00
* RANDOM (@FAC) FLP
NRANDMZ DCZ @FAC
	    BS  GA3B6
	    ST  >46,@FAC
	    XML VPUSH
	    MOVE 8,G@RNDEM,@ARG
	    XML FMUL
	    CALL GRINT
	    MOVE 5,@FAC,V@RNDX2
	    MOVE 8,G@RNDEP,@ARG
	    XML FMUL
	    XML SSUB
	    MOVE 5,@FAC,V@RNDX1
	    RTN
GA3B6   DST  @FAC,V@RNDX2
	    DST  @FAC,V@RNDX1
	    RTN
RNDM1   DST  >4201,@FAC
	    CLR  @FAC4
	    CALL RNDMZ
	    DATA RNDX1
	    CALL RNDMZ
	    DATA RNDX2
	    RTN
RNDMZ   FETCH @FAC8
	    FETCH @FAC9
	    RAND  99
	    ST    @RANDOM,@FAC2
	    SRL   2,@FAC2
	    RAND  99
	    ST    @RANDOM,@FAC3
	    SRL   2,@FAC3
	    MOVE  5,@FAC,V*FAC8
	    RTN
* SEG (@STRADD,@STRLEN,@FAC,ARG) (V*SREF)
SEG	 DST   @FAC,@ARG2
	    DST   @ARG2,@TEMP2	 
	    DCH   @STRLEN,@TEMP2
	    BS    SEGZ08
	    DADD  @ARG,@TEMP2
	    DSUB  @STRLEN,@TEMP2
	    DDEC  @TEMP2
	    DCGE  0,@TEMP2
	    BR    SEGZ06
	    DST   @STRLEN,@ARG
	    DSUB  @ARG2,@ARG
	    DINC  @ARG
SEGZ06  DST   @ARG,@BYTES
	    DST   @STRADD,@TEMP5
	    DADD  @ARG2,@TEMP5
	    DDEC  @TEMP5
	    DST   @BYTES,@STRLEN
	    MOVE  @BYTES,*TEMP5,V*SREF * TEMP STRING AREA
	    RTN
SEGZ08  DCLR  @ARG
	    BR    SEGZ06
* LEN (@STRADD) FLP (@FAC)
LEN	 DST   @STRLEN,@FAC
	    XML   CIF
	    RTN
* CHR (@FAC) FLP (@FAC)
CHR	 XML   FLTINT
	    RTN

* ASC (@STRADD,@STRLEN) FLP (@FAC)
ASC	 DCZ   @STRLEN
	    BS    ERRBA * ERROR BAD ARGUMENT
	    ST    @STRADD,@FAC1
	    CLR   @FAC
	    XML   CIF
	    RTN
* STR (@FAC,@STRADD) FLP (@STRADD)
STR	 CLR  @FAC11
	    XML  CNS
	    CEQ  SPACE,*FAC11
	    BR   GA53E
	    INC  @FAC11
	    DEC  @FAC12
GA53E   CLR  @BYTES
	    ST   @FAC12,@BYTES+1
	    DCZ  @BYTES
	    BS   ERRBA * ERROR BAD ARGUMENT
	    MOVE @BYTES,*FAC11,@STRADD 
	    DST  @BYTES,@STRLEN
	    RTN
* VAL (@STRADD,@STRLEN) FLP (@FAC)
VAL	 DCZ  @STRLEN
	    BS   ERRBA * ERROR BAD ARGUMENT
	    CALL VALCD
	    BS   ERRBA * ERROR BAD ARGUMENT
	    RTN
VALCD   DST  @STRADD,@TEMP5	
	    DADD @STRLEN,@TEMP5
	    DST  @STRLEN,@BYTES
	    DINC @BYTES
GA57C   DDEC @TEMP5
	    DDEC @BYTES
	    BS   RTNSET
	    CEQ  SPACE,*TEMP5
	    BS   GA57C
	    DINC @BYTES
	    DST  @FAC4,@TEMP5
	    CLR  @FAC8 * FORCE VDP MODE
	    MOVE @BYTES,*TEMP5,v*SREF * SREF IS A STRING BUFFER IN VDP
	    DADD @SREF,@BYTES
	    DDEC @BYTES
	    ST   SPACE,v*BYTES
	    DST  @SREF,@FAC12
GA5A4  CEQ  SPACE,v*FAC12
	    BR   GA5AE
	    DINC @FAC12
	    BR   GA5A4
GA5AE   CLR  @FAC2
	    CLR  @FAC10
	    XML  CSNUM
	    DCEQ @BYTES,@FAC12
	    BS   WRNNO * WARNING CHECK OVERFLOW
RTNSET  CEQ  @>8300,@>8300
	    RTNC
* POS (@STRADD1,@STRADD2,@FAC) FLP (@FAC)
POS	 DCLR @FPERAD
	    XML  FLTINT
	    CZ   @FAC10
	    BR   ERRBV * ERROR BAD VALUE
	    CGE  0,@FAC
	    BR   ERRBV * ERROR BAD VALUE
	    DCZ  @FAC
	    BS   ERRBV * ERROR BAD VALUE
	    DST  @FAC,@BYTES
	    DDEC @BYTES
	    MOVE 8,@FAC,@ARG
	    DCZ  @FAC7
	    BS   POS12
	    CH   @BYTES+1,@FAC7
	    BR   POS12
	    CZ   @ARG7
	    BS   POS06
	    DADD @BYTES,@FAC4
	    SUB  @BYTES+1,@FAC7
POS02   CHE  @ARG7,@FAC7
	    BR   POS12
	    DST  @FAC4,@FAC
	    DST  @ARG4,@ARG
	    ST   @ARG7,@ARG8
	    CEQ  *FAC,*ARG
	    BR   POS10
	    DINC @FAC
	    DINC @ARG
	    DEC  @ARG8
	    BR   POS04
POS06   INC  @BYTES+1
POS08   DST  @BYTES,@FAC
	    XML  CIF
	    RTN
POS10   INC  @BYTES+1
	    DEC  @FAC7
	    DINC @FAC4
	    BR   POS02
POS12   CLR  @BYTES+1
	    BR   POS08  
	 
* RPT (@STRADD,@STRLEN,@FAC) FLP (V*SREF) TEMP VDP STRING
RPT	 DCLR @FPERAD
	    XML  FLTINT	   
	    CZ   @FAC10
	    BR   ERRBV * ERROR BAD VALUE
	    CGE  0,@FAC
	    BR   ERRBV * ERROR BAD VALUE					 
	    DCZ  @FAC
	    BS   RPT1
	    DCZ  @STRLEN	   
	    BS   RPT1
	    ST   @STRLEN+1,@ARG
	    MUL  @FAC,@ARG
	    CH   255,@ARG
	    BS   ERRBV * ERROR BAD VALUE
	    DST  @SREF,@ARG
RPT0   MOVE @STRLEN,@STRADD,V*ARG * VDP TEMP STRING
	    DADD @STRLEN,@ARG
	    DDEC @FAC
	    BR   RPT0
RPT1   RTN	



#11 retroclouds OFFLINE  

retroclouds

    Stargunner

  • 1,096 posts
  • Location:Germany

Posted Sun Nov 6, 2011 11:37 AM

Rich, I have a quick question regarding the XB to GPL Compiler: Do you scan the source code yourself or do you start with the tokenized version of the Extended Basic program?

#12 RXB OFFLINE  

RXB

    Dragonstomper

  • 539 posts
  • Location:Vancouver, Washington, USA

Posted Sun Nov 6, 2011 1:55 PM

Working on two versions.

First is GPL Editor Assembler that takes DV80 listings of XB programs and turns them into DV 80 GPL Source.
Second is RXB XB program that takes DV 163 Merge format and creates a DV 80 GPL Source.

The XB version is moving much faster. Can do DIM like X(2,3,4) or Z$(3,4)
Can also do REM or ! and OPTION BASE so far. I am presently working on all DATA types statements.

I only see the DEF and OPEN commands as the real tough ones to convert as they have so many options.

#13 RXB OFFLINE  

RXB

    Dragonstomper

  • 539 posts
  • Location:Vancouver, Washington, USA

Posted Mon Nov 7, 2011 6:37 PM

Well ran into first snag. Here are the tokens in XB GPL Source:

*	  EQU  >C6			   spare token
STRINZ EQU  >C7			   QUOTED STRING
UNQSTZ EQU  >C8			   UNQUOTED STRING
NUMZ   EQU  >C8			   ALSO NUMERICAL STRING
LNZ    EQU  >C9			   LINE NUMBER CONSTANT
*	  EQU  >CA			   spare token

What TI should have done is NUMZ (numerical string) should have been >C6 so that the same >C8 would not be used for 3 different types.

#14 RXB OFFLINE  

RXB

    Dragonstomper

  • 539 posts
  • Location:Vancouver, Washington, USA

Posted Wed Nov 23, 2011 5:38 PM

So to maintain speed in running programs my original BASIC to GPL compiler was using Floating Point so you could use commands like this:
100 FOR I=F TO L STEP S
120 NEXT I

This has the advantage to work if S=-9 or S=9, but is much slower as Floating point is really processor intensive on slowing speed.

So I have had to opt for not using Floating Point unless required. Thus:
100 FOR I=F TO L STEP -9
110 NEXT I

This means all steps if a variable must be positive and any negative must be specified as a number. The speed difference is incredible.

The BGPLCOMPILER was started on the 26th so on the 26th of this month I will post a video of the progress after 30 days.

Edited by RXB, Wed Nov 23, 2011 5:39 PM.


#15 moulinaie OFFLINE  

moulinaie

    Chopper Commander

  • 185 posts
  • Location:France, Burgundy

Posted Thu Nov 24, 2011 2:13 AM

View PostRXB, on Wed Nov 23, 2011 5:38 PM, said:

So to maintain speed in running programs my original BASIC to GPL compiler was using Floating Point so you could use commands like this:
100 FOR I=F TO L STEP S
120 NEXT I

This has the advantage to work if S=-9 or S=9, but is much slower as Floating point is really processor intensive on slowing speed.

So I have had to opt for not using Floating Point unless required. Thus:
100 FOR I=F TO L STEP -9
110 NEXT I

This means all steps if a variable must be positive and any negative must be specified as a number. The speed difference is incredible.

The BGPLCOMPILER was started on the 26th so on the 26th of this month I will post a video of the progress after 30 days.

I don't understand why you talk about floating point numbers when an integer is negative. Both +9 and -9 can be represented with a 16 bits integer value. No need to use the 64 bits floating point encoding.

No ?

Guillaume.

#16 RXB OFFLINE  

RXB

    Dragonstomper

  • 539 posts
  • Location:Vancouver, Washington, USA

Posted Thu Nov 24, 2011 4:20 AM

GPL uses integers just like Assembly so here is an example of code from my BASIC to GPL Compiler:

100 FOR I=F TO L STEP -9

In GPL would be
L100 DST @F,@I
L100A BR $+2

110 NEXT I

In GPL would be:
L110 DSUB 9,@I
DCEQ @I,@L
BR L100A

If the example was:
100 FOR I=F TO L STEP S

Then S would be a problem as the Compiler can not determine before hand if the S is negative DSUB or Positive DADD.
The XB interpeter does this on the fly but a Complier has to know one way of the other or it just will not work.
Also the memory address >0000 to >FFFF Hexidecimal or 0 to 65535 so there are not negative address, you are thinking in XB not GPL or Assembly.

Edited by RXB, Thu Nov 24, 2011 4:26 AM.


#17 lucien2 OFFLINE  

lucien2

    Chopper Commander

  • 160 posts
  • Location:Switzerland

Posted Thu Nov 24, 2011 5:07 AM

View PostRXB, on Thu Nov 24, 2011 4:20 AM, said:


Then S would be a problem as the Compiler can not determine before hand if the S is negative DSUB or Positive DADD.
The XB interpeter does this on the fly but a Complier has to know one way of the other or it just will not work.
Also the memory address >0000 to >FFFF Hexidecimal or 0 to 65535 so there are not negative address, you are thinking in XB not GPL or Assembly.

You can add a negative number with DADD, -9 is represented as >FFF7 with the format used: http://en.wikipedia..../Two_complement

"I" is not an address, it's a counter. As a signed 16 bits integer, it can have values between -32768 and +32767.

#18 RXB OFFLINE  

RXB

    Dragonstomper

  • 539 posts
  • Location:Vancouver, Washington, USA

Posted Thu Nov 24, 2011 6:06 AM

View Postlucien2, on Thu Nov 24, 2011 5:07 AM, said:

View PostRXB, on Thu Nov 24, 2011 4:20 AM, said:

Then S would be a problem as the Compiler can not determine before hand if the S is negative DSUB or Positive DADD.
The XB interpeter does this on the fly but a Complier has to know one way of the other or it just will not work.
Also the memory address >0000 to >FFFF Hexidecimal or 0 to 65535 so there are not negative address, you are thinking in XB not GPL or Assembly.

You can add a negative number with DADD, -9 is represented as >FFF7 with the format used: http://en.wikipedia..../Two_complement

"I" is not an address, it's a counter. As a signed 16 bits integer, it can have values between -32768 and +32767.

A twos complement is where you sacrifice the top most bit to use as a sign bit. So >FFF7 is -9 but your range is then limited to like you said -32768 to 32767.
So of course a computation must be made each time you do this, using Assembly to do this is faster with a XML from GPL then straight GPL.
Thus this is why almost all XB is Floating Point as the Assembly is faster at this then just twos complement in GPL.
The point of the BASIC to GPL compiler is to speed it up, not stay the same speed. What would be the point of staying almost the same speed?

#19 Willsy OFFLINE  

Willsy

    Dragonstomper

  • 765 posts
  • Location:Uzbekistan (no, really!)

Posted Thu Nov 24, 2011 6:06 AM

View PostRXB, on Thu Nov 24, 2011 4:20 AM, said:

Then S would be a problem as the Compiler can not determine before hand if the S is negative DSUB or Positive DADD.
The XB interpeter does this on the fly but a Complier has to know one way of the other or it just will not work.
Also the memory address >0000 to >FFFF Hexidecimal or 0 to 65535 so there are not negative address, you are thinking in XB not GPL or Assembly.

You don't need to use DSUB or DADD. Just use DADD.

Think about it:

9 - 9 = 0
9 + -9 = 0

So, you don't need to worry about the sign (i.e. whether the number is +ve or -ve) - If you are doing a subtraction (like stepping the loop index down by -9) then you add -9. If the loop index is going upwards, then, again, it's just an add.

HTH

#20 RXB OFFLINE  

RXB

    Dragonstomper

  • 539 posts
  • Location:Vancouver, Washington, USA

Posted Thu Nov 24, 2011 6:09 AM

K will see if the Assembler will accept this, I was thinking straight through interpetation. You are right the GPL Assembler will do the Twos Complement.

View Postlucien2, on Thu Nov 24, 2011 5:07 AM, said:

View PostRXB, on Thu Nov 24, 2011 4:20 AM, said:

Then S would be a problem as the Compiler can not determine before hand if the S is negative DSUB or Positive DADD.
The XB interpeter does this on the fly but a Complier has to know one way of the other or it just will not work.
Also the memory address >0000 to >FFFF Hexidecimal or 0 to 65535 so there are not negative address, you are thinking in XB not GPL or Assembly.

You can add a negative number with DADD, -9 is represented as >FFF7 with the format used: http://en.wikipedia..../Two_complement

"I" is not an address, it's a counter. As a signed 16 bits integer, it can have values between -32768 and +32767.


#21 Willsy OFFLINE  

Willsy

    Dragonstomper

  • 765 posts
  • Location:Uzbekistan (no, really!)

Posted Thu Nov 24, 2011 6:14 AM

View PostRXB, on Thu Nov 24, 2011 6:06 AM, said:

View Postlucien2, on Thu Nov 24, 2011 5:07 AM, said:

View PostRXB, on Thu Nov 24, 2011 4:20 AM, said:

Then S would be a problem as the Compiler can not determine before hand if the S is negative DSUB or Positive DADD.
The XB interpeter does this on the fly but a Complier has to know one way of the other or it just will not work.
Also the memory address >0000 to >FFFF Hexidecimal or 0 to 65535 so there are not negative address, you are thinking in XB not GPL or Assembly.

You can add a negative number with DADD, -9 is represented as >FFF7 with the format used: http://en.wikipedia..../Two_complement

"I" is not an address, it's a counter. As a signed 16 bits integer, it can have values between -32768 and +32767.

A twos complement is where you sacrifice the top most bit to use as a sign bit. So >FFF7 is -9 but your range is then limited to like you said -32768 to 32767.

Quote

So of course a computation must be made each time you do this, using Assembly to do this is faster with a XML from GPL then straight GPL.

What computation do you mean? I'm a little bit confused by that!

Quote

Thus this is why almost all XB is Floating Point as the Assembly is faster at this then just twos complement in GPL.

Respectfully, I don't think that can be true. Admittedly, I haven't ever tested it, but having just written a floating point library for TurboForth, I reckon that FP computations are at least 1000 times slower than normal integer based operations. Okay, there is an extra computational 'layer' to go through when in GPL, but integer math will always be an order of magnitude faster than floating-point, even if the floating-point is written in assembly and the integer math is written in GPL. Don't forget, on the 9900 integer math is performed by the processor itself. Floating point must be done in software. A DADD or a DSUB will eventually resolve down to a 9900 A or S instruction, whereas a floating-point operation is a number of multiplies and divides performed in a loop.

#22 RXB OFFLINE  

RXB

    Dragonstomper

  • 539 posts
  • Location:Vancouver, Washington, USA

Posted Fri Nov 25, 2011 3:12 AM

Ok so it does not work.
100 FOR X=-128 TO -12 STEP -7
110 ! PROGRAM HERE
120 NEXT X

Now the GPL code using what you said:
99/4 GPL-ASSEMBLER (Pass 1) correct								   PAGE 0001
Version 2.0 (Weiand 1985)	 Options : LCSFPF								 
[0001]				 GROM >6000
[0002]			   
[0003] A000		  X EQU >A000
[0004] 6000 BF,8F,1D L100 DST -128,@X
	   6003 00,FF,80
[0005] 6006 05,60,09 L100A B $+3
[0006] 6009		  L110 * ! ROUTINE HERE.
[0007] 6009 A3,8F,1D L120 DADD -7,@X
	   600C 00,FF,F9
[0008] 600F CB,8F,1D	  DCHE -12,@X
	   6012 00,FF,F4
[0009] 6015 40,06		 BR L100A
[0010]			   
[0011]				    END
.
99/4 GPL-ASSEMBLER (Pass 1) correct								   PAGE 0002
Version 2.0 (Weiand 1985)	 Options : LCSFPF								 

So first pass >A000 is >FF80
Add the -7 to >A000 is >FFF9 equals >FF79
So that is larger then -12 is >FFF4 so next pass
Add the -7 to >A000 is >FFF9 equals >FF72 and that is less then -12 and the program is done. Way off.

The problem is there is no CLE or CLT in GPL only CH or CHE or CGE or CEQ so kind of screwed doing this way.

#23 Willsy OFFLINE  

Willsy

    Dragonstomper

  • 765 posts
  • Location:Uzbekistan (no, really!)

Posted Fri Nov 25, 2011 4:24 AM

It doesn't work because you have the loop the wrong way 'round! Go ahead and write it out in TI BASIC as you have written it - it won't work. Of course if the step was 7 (not -7) it would have worked!

It should be:
FOR X=-12 TO -128 STEP -7
;-)

#24 RXB OFFLINE  

RXB

    Dragonstomper

  • 539 posts
  • Location:Vancouver, Washington, USA

Posted Fri Nov 25, 2011 5:03 PM

Thanks Willsy would be first pass in GPL as >FFF4 + >FFF9 equals >FFED and that is larger then -128 =>FF80 so ends in one pass.
(with out a CLE or CLT in GPL this is a real pain, Assembly has the tools for this that GPL does not.)

So again fails. This is why Floating Point is so much better as it also handles decimals and exponents plus negative numbers.

Thank you but the idea was not to have to use twos complement conversions every time I load a number. I wanted to just use 0 to 65535 and check if it was negative.

I will have to use something that combines twos complement and Floating Point instead though this will really cut into the speed.

#25 Lee Stewart ONLINE  

Lee Stewart

    Chopper Commander

  • 175 posts

Posted Fri Nov 25, 2011 9:57 PM

Rich...

You don't need CLT or CLE. CLT is equivalent to C¬GE (compare not-GE). That is, if the result of a comparison is not "≥", then it must be "<". By the same token, CLE is equivalent to C¬GT. So, if you would do a BS if you had a CLT instruction, then do a BR after a CGE, etc.

...lee




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users