Looking for tniASM v1.0 users

Page 1/2
| 2

By spacemoai1973

Expert (96)

spacemoai1973's picture

14-04-2016, 15:00

Hi I'm a supporter of tniASM and want to be in contact with other tniASM v1.0 users for share interesting macro's and technics.
This assembler is very powerfull and the possibilities are legion.

I will begin first.

; 16bit compare nondestructive all flags as expected
%macro cp hl,bc
and a
sbc hl,bc
add hl,bc
%endmacro

; define word then byte
%macro dwb %n,%n
%def16 #1
%def8 #2
%endmacro

dwb 4000h,2

; 16bit load in 8bit halfs
%macro ld hl,%n,%n
ld hl,#1 <<8| #2
%endmacro

ld hl,200,10

; pallette v9938
%macro rgb (%n,%n,%n)\(#2 <<8| #1 <<4| #3)\%endmacro

dw rgb(1,2,3), rgb(7,6,5), rgb(3,4,5)
Login or register to post comments

By syn

Paragon (1920)

syn's picture

14-04-2016, 16:11

I've used it a few times, nice tool. I used the free version at first (http://www.tni.nl/products/tniasm045.zip) and I decided to donate to the project because I liked it.

I dont use the macro functions yet, although I think bifi or guyver800 gave me a macro for something I needed once.

If you want to get in touch with tniasm users, you should definitely visit #msxdev .. the creator of tniasm is there often;) and some users:)

Anyway thanks for your macros, looks nice. I will give them a try sometimes when I get back to coding.

By Daemos

Paragon (1672)

Daemos's picture

14-04-2016, 20:19

I am a user of tniasm. I have no clue why but I just love the tool. Its fast simple and does the job.

By spacemoai1973

Expert (96)

spacemoai1973's picture

01-05-2016, 11:18

So nobody has macro's for to share.? :-(

By NYYRIKKI

Enlighted (5385)

NYYRIKKI's picture

01-05-2016, 20:54

Well... I have few additions to Z80N00B.INC:

%macro JP HL  \%def8 E9h\ %endmacro
%macro JP IX  \%def16 E9DDh\ %endmacro
%macro JP IY  \%def16 E9FDh\ %endmacro
%macro POP PC \%def8 C9h\ %endmacro

%macro RST Z,%n
  %if #1 <> 38h
    %error "Illegal RST"
    %def16 0
  %else
    %def16 $FF28
  %endif
%endmacro

%macro RST NZ,%n
  %if #1 <> 38h
    %error "Illegal RST"
    %def16 0
  %else
    %def16 $FF20
  %endif
%endmacro

By NYYRIKKI

Enlighted (5385)

NYYRIKKI's picture

02-05-2016, 01:05

This is maybe more useful:

CHPUT	equ $a2
CR	equ 13
LF	equ 10

%macro PRINT %s
	call _PRINT
        %% '%def8 '+#1
	%def8 0

%endmacro

_PRINT:
	pop hl
	ld a,(hl)
	inc hl
	push hl
	and a
	ret z
	call CHPUT
	jr _PRINT
	

;Example:

	PRINT "'Hello World!',CR,LF"
	ret

By flyguille

Prophet (3029)

flyguille's picture

02-05-2016, 01:06

NYYRIKKI wrote:

This is maybe more useful:

CHPUT	equ $a2

%macro PRINT %s
	call _PRINT
        %% '%def8 '+#1
	%def8 0
%endmacro

_PRINT:
	pop hl
	ld a,(hl)
	inc hl
	push hl
	and a
	ret z
	call CHPUT
	jr _PRINT
	

;Example:

	PRINT "'Hello World!',10,13"
	ret

Now encode the others like 125 BASIC commands in macros.

By NYYRIKKI

Enlighted (5385)

NYYRIKKI's picture

02-05-2016, 17:36

I was wondering, wouldn't it be nice to write structured Assembler? Unfortunately it seems that although tniASM is quite powerful with macros, there are quite a bad limitations that make things pretty hard... Anyway here is my first try.

%INCLUDE "Z80R800.INC"
%INCLUDE "STRUCTURE.INC"


	%ORG $D000

	LD A,[CALCBITS]
	AND A
	IF 'NZ'
	   LD A,[DATA]
	   LD B,8
	   LD HL,0
           
	   LOOP:
	   ;----
	   ADD A,A
	   IF 'C'
	      INC H
	   ELSE
	      INC L
	   ENDIF
	   DJNZ LOOP
	ENDIF
	RET

CALCBITS: %DEF8 $FF
DATA:	  %DEF8 $57

... to make it work you need few macros defined:


;-------------------------------------------;
;Stuctured Z80 coding script for tniASM 1.0 ;
;Version 0.1 Made By: NYYRIKKI (2016)       ;
;-------------------------------------------;
; Filename: STRUCTURE.INC                   ;
;                                           ;
;---;--- C O N F I G U R A T I O N ---------;

USE_JR_IN_IF: ; Comment out this line if you don't want JR usage.

;-------------------------------------------;

;Rest of the bullshit involved:

IF_INITCOUNT %SET "@"
NEXTIFDEEP %SET "A"
%MACRO IF_INIT
IF_INITCOUNT %SET IF_INITCOUNT + 1
%%'NEXTIFCNT'+IF_INITCOUNT+' %SET "@"'
%IF IF_INITCOUNT>"Y"
%ELSE
IF_INIT
%ENDIF
%ENDMACRO
IF_INIT
%MACRO INVERT_CONDITION %S
IF_RELATIVE_POSSIBLE %SET "N"
%IF (#1=="NZ") | (#1=="nz")
INVERTED_CONDITION %SET "Z"
IF_RELATIVE_POSSIBLE %SET "Y"
%ENDIF
%IF (#1=="Z") | (#1=="z")
INVERTED_CONDITION %SET "NZ"
IF_RELATIVE_POSSIBLE %SET "Y"
%ENDIF
%IF (#1=="NC") | (#1=="nc")
INVERTED_CONDITION %SET "C"
IF_RELATIVE_POSSIBLE %SET "Y"
%ENDIF
%IF (#1=="C") | (#1=="c")
INVERTED_CONDITION %SET "NC"
IF_RELATIVE_POSSIBLE %SET "Y"
%ENDIF
%IF (#1=="PO") | (#1=="po")
INVERTED_CONDITION %SET "PE"
%ENDIF
%IF (#1=="PE") | (#1=="pe")
INVERTED_CONDITION %SET "PO"
%ENDIF
%IF (#1=="P") | (#1=="p")
INVERTED_CONDITION %SET "M"
%ENDIF
%IF (#1=="M") | (#1=="m")
INVERTED_CONDITION %SET "P"
%ENDIF
%ENDMACRO
%MACRO JUMP_CONDITION %S
%% '%IF %DEF('+#1+"_ELSE"+')'
%% "IFJUMP_ADDRESS %SET "+#1+"_ELSE"
%ELSE
%% "IFJUMP_ADDRESS %SET "+#1+"_ENDIF"
%ENDIF
%if (IFJUMP_ADDRESS-(%apos+2) <= 127) & (IFJUMP_ADDRESS-(%apos+2) >= -128) & (%DEF(USE_JR_IN_IF)) & (IF_RELATIVE_POSSIBLE=="Y")
IF_JUMP_COMMAND %SET "JR "
%ELSE
IF_JUMP_COMMAND %SET "JP "
%ENDIF
%% '%IF %DEF('+#1+"_ELSE"+')'
%% IF_JUMP_COMMAND+INVERTED_CONDITION+","+#1+"_ELSE"
%ELSE
%% IF_JUMP_COMMAND+INVERTED_CONDITION+","+#1+"_ENDIF"
%ENDIF
%ENDMACRO
%MACRO IF %S
NEXTIFDEEP %SET NEXTIFDEEP + 1
%%'NEXTIFCNT'+NEXTIFDEEP+' %SET NEXTIFCNT'+NEXTIFDEEP+'+ 1'
%%'CURCNT %SET NEXTIFCNT'+NEXTIFDEEP
INVERT_CONDITION #1
%% 'JUMP_CONDITION "IF_" + NEXTIFDEEP+CURCNT'
%ENDMACRO
%MACRO ENDIF
%% "IF_" + NEXTIFDEEP+CURCNT +"_ENDIF:"
NEXTIFDEEP %SET NEXTIFDEEP - 1
%%'CURCNT %SET NEXTIFCNT'+NEXTIFDEEP
%ENDMACRO
%MACRO ELSE
%% "IFJUMP_ADDRESS %SET IF_" + NEXTIFDEEP+CURCNT +"_ENDIF"
%if (IFJUMP_ADDRESS-(%apos+2) <= 127) & (IFJUMP_ADDRESS-(%apos+2) >= -128) & (%DEF(USE_JR_IN_IF))
IF_JUMP_COMMAND %SET "JR "
%ELSE
IF_JUMP_COMMAND %SET "JP "
%ENDIF
%% IF_JUMP_COMMAND+" IF_" + NEXTIFDEEP+CURCNT +"_ENDIF"
%% "IF_" + NEXTIFDEEP+CURCNT +"_ELSE:"
%ENDMACRO
%MACRO ELSE IF %S
ELSE
IF #1
%ENDMACRO

Yes, I know... it is not great as it limits the number if IF-commands to ~26... need to look into that some day later. Today I've had enough of this. Smile

By Manuel

Ascended (15756)

Manuel's picture

02-05-2016, 19:00

OK, so what does this do? Smile Example code of usage?

By NYYRIKKI

Enlighted (5385)

NYYRIKKI's picture

02-05-2016, 19:04

Manuel wrote:

OK, so what does this do? Smile Example code of usage?

Example was on the top... As you may notice it reduces the amount of labels you need to write quite a much and makes the source a bit more readable.

By spacemoai1973

Expert (96)

spacemoai1973's picture

02-05-2016, 23:16

Wooow that is fantastic NYYRIKKI.!
GuyveR800 told me once that the goal for tniASM is to compile a form of BASIC direct to machine code.
I thought not possible but this gives me hope Cool

Page 1/2
| 2