Jump to content



0

Problems creating my first ASM program

assembly

23 replies to this topic

#1 samishal OFFLINE  

samishal

    Space Invader

  • 35 posts

Posted Sun Dec 25, 2011 11:00 AM

Dear all,

First off, Merry Christmas, I hope you all eat as much food as you can and sleep for the rest of the day, I know I will :)

Anyway, I have madea little helloworld program however it will not assemble and obviously wont run, I have been using the classic99 emualtor for this and after I can get one or two programs to work on there I'll move onto my real iron system lol.

Here is the program :



              REF VMBW
MYREG BSS >20
ADDR1  TEXT 'HELLO WORLD'
BEGIN   LWPI MYREG
              LI R0,102
              LI R1,ADDR1
              LI R2,12
              BLWP @VMBW
              JMP $

Also, is it possible to write a program in a text editor and save to to the right folder and then assemble it in the classic99 program or must it always be typed through the program?

Samishal

Merry Xmas!!!

#2 marc.hull OFFLINE  

marc.hull

    Dragonstomper

  • 646 posts
  • Location:Oklahoma CIty.

Posted Sun Dec 25, 2011 11:09 AM

View Postsamishal, on Sun Dec 25, 2011 11:00 AM, said:

Dear all,

First off, Merry Christmas, I hope you all eat as much food as you can and sleep for the rest of the day, I know I will :)

Anyway, I have madea little helloworld program however it will not assemble and obviously wont run, I have been using the classic99 emualtor for this and after I can get one or two programs to work on there I'll move onto my real iron system lol.

Here is the program :



Add this...

DEF BEGIN

as the first instruction and

END BEGIN

as the last



			  REF VMBW
MYREG BSS >20
ADDR1  TEXT 'HELLO WORLD'
BEGIN   LWPI MYREG
			  LI R0,102
			  LI R1,ADDR1
			  LI R2,12
			  BLWP @VMBW
			  JMP $

Also, is it possible to write a program in a text editor and save to to the right folder and then assemble it in the classic99 program or must it always be typed through the program?

Samishal

Merry Xmas!!!


#3 samishal OFFLINE  

samishal

    Space Invader

  • 35 posts

Posted Sun Dec 25, 2011 11:38 AM

I have added the DEF BEGIN and END BEGIN lines to the program however I am still encountering the "Invalid Register error" that I encountered before...

#4 moulinaie OFFLINE  

moulinaie

    Chopper Commander

  • 185 posts
  • Location:France, Burgundy

Posted Sun Dec 25, 2011 11:50 AM

Hi,

Try to remove the letter "r" before every register reference.
LI 0,102 etc...

Guillaume.

#5 marc.hull OFFLINE  

marc.hull

    Dragonstomper

  • 646 posts
  • Location:Oklahoma CIty.

Posted Sun Dec 25, 2011 12:02 PM

Are you using register zero or register ohhh...

#6 samishal OFFLINE  

samishal

    Space Invader

  • 35 posts

Posted Sun Dec 25, 2011 2:55 PM

I removed the 'r' from the register calls, is that just for the emualtor that I have to remove the r's or is it for the real thing as well?? Also after assembling the program how do I run it?

Samishal

#7 moulinaie OFFLINE  

moulinaie

    Chopper Commander

  • 185 posts
  • Location:France, Burgundy

Posted Sun Dec 25, 2011 2:58 PM

View Postsamishal, on Sun Dec 25, 2011 2:55 PM, said:

I removed the 'r' from the register calls, is that just for the emualtor that I have to remove the r's or is it for the real thing as well?? Also after assembling the program how do I run it?

Samishal

For the real thing as well!
But there is an option that I forgot when running the assembler (letter L ??) to make it accept R7 instead of 7.
Tu run it then, just select "RUN" in the menu and type BEGIN as program name (if you have inserted DEF BEGIN)

Guillaume.

#8 moulinaie OFFLINE  

moulinaie

    Chopper Commander

  • 185 posts
  • Location:France, Burgundy

Posted Sun Dec 25, 2011 3:02 PM

View Postsamishal, on Sun Dec 25, 2011 2:55 PM, said:

I removed the 'r' from the register calls, is that just for the emualtor that I have to remove the r's or is it for the real thing as well?? Also after assembling the program how do I run it?

Samishal

When assembling, on the line "OPTIONS?", just answer R and you'll be able to use R0 - R15 instead of 0 - 15.
(E/A manuel, page 34)

Guillaume.

#9 Tursi OFFLINE  

Tursi

    Stargunner

  • 1,448 posts
  • Location:SJC

Posted Thu Dec 29, 2011 3:12 PM

Looks like you are getting good help here, but I wanted to note that I did post a step-by-step assembly 'hello world' using Classic99. It's lost somewhere here on the forum but I can relink it here: http://harmlesslion....a/01_G.png.html

Make sure to view the full size images, and there is step-by-step with screenshots. A gallery probably isn't the best interface for that, but maybe it's useful. :)

That covers typing it in through the E/A. You /can/ use windows text files, if you like. By default, to make Classic99 understand that it is a text file, it must have a .TXT or .OBJ extension -- in your case .TXT makes more sense. You must also use the extension on the TI side. So, for instance, if you save your file as C:\Classic99\DSK1\SOURCE.TXT, then when you load the assembler, your source filename is DSK1.SOURCE.TXT (and the rest as normal).

#10 apersson850 OFFLINE  

apersson850

    Star Raider

  • 84 posts

Posted Sat Mar 3, 2012 7:07 AM

Insert the command EVEN after the text definition. Your text is 11 bytes, and instructions must start at even addresses.

#11 Lee Stewart OFFLINE  

Lee Stewart

    Chopper Commander

  • 175 posts

Posted Fri May 18, 2012 11:43 AM

View Postapersson850, on Sat Mar 3, 2012 7:07 AM, said:

Insert the command EVEN after the text definition. Your text is 11 bytes, and instructions must start at even addresses.

Inserting EVEN after BYTE and TEXT directives is probably a good habit, but machine instructions (this case) or DATA directives immediately following BYTE and TEXT directives are always started on even addresses.

...lee

#12 matthew180 OFFLINE  

matthew180

    Stargunner

  • 1,242 posts
  • Location:Marshall, Michigan

Posted Fri May 18, 2012 1:10 PM

Depends on the assembler. Win994a has certain instances where it gets it wrong. I can't remember the specifics right off my head, but it is documented in this forum (we have discussed this before and I know I posted at least one example somewhere).

#13 Lee Stewart OFFLINE  

Lee Stewart

    Chopper Commander

  • 175 posts

Posted Fri May 18, 2012 4:04 PM

View Postmatthew180, on Fri May 18, 2012 1:10 PM, said:

Depends on the assembler. Win994a has certain instances where it gets it wrong. I can't remember the specifics right off my head, but it is documented in this forum (we have discussed this before and I know I posted at least one example somewhere).

I do wish things were easier to find. When I am starting from scratch, it often takes a discouragingly long time to get the information I am looking for even when I am reasonably sure it is there. Thanks for the information, especially since I am thinking of soon embarking upon a rather ambitious assembly project.

...lee

#14 matthew180 OFFLINE  

matthew180

    Stargunner

  • 1,242 posts
  • Location:Marshall, Michigan

Posted Fri May 18, 2012 4:12 PM

Let me see if I can find it. The "assembly my way" thread I stared would be my first guess.

Here, starting about post #36:

http://www.atariage....25#entry1970943

I agree with you about finding stuff. I like a forum format for allowing a topic to be discussed without noise from other topics, but it lacks an index. Hmm, the "next big thing" in form frameworks, auto indexes and auto topic summarizing. You heard it here first. :-)

Edited by matthew180, Fri May 18, 2012 5:30 PM.


#15 lucien2 OFFLINE  

lucien2

    Chopper Commander

  • 160 posts
  • Location:Switzerland

Posted Sat May 19, 2012 3:07 AM

View Postmatthew180, on Fri May 18, 2012 4:12 PM, said:


Here is your exemple with the GNU assembler. It does not automatically add EVEN directives.
But it's open source, you could add your GPU instructions.

GAS LISTING test.asm 			page 1


   1               		DEF	MAIN
   2 0000 01        	VAR1	BYTE	1
   3               	
   4               	MAIN
   5               	TEST	EQU	ND-ST
   6 0001 0200 000B 		LI	r0,TEST
   7 0005 1000      		JMP	$
   8               	
   9 0007 4845 4C4C 	ST	TEXT	'HELLO WORLD'
   9      4F20 574F 
   9      524C 44
  10               	ND	END
GAS LISTING test.asm 			page 2


DEFINED SYMBOLS
            test.asm:4      .text:00000001 MAIN
            test.asm:2      .text:00000000 VAR1
            test.asm:4      *ABS*:0000000b TEST
            test.asm:10     .text:00000012 ND
            test.asm:9      .text:00000007 ST

NO UNDEFINED SYMBOLS


#16 Willsy ONLINE  

Willsy

    Dragonstomper

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

Posted Sat May 19, 2012 3:57 AM

Okay, I'll bite! :-) what's the project?

#17 retroclouds OFFLINE  

retroclouds

    Stargunner

  • 1,096 posts
  • Location:Germany

Posted Sat May 19, 2012 5:26 AM

Hmm... got a feeling it'll have something to do with Forth and Assembler? ;-)

#18 Lee Stewart OFFLINE  

Lee Stewart

    Chopper Commander

  • 175 posts

Posted Sat May 19, 2012 6:55 AM

View Postmatthew180, on Fri May 18, 2012 4:12 PM, said:

Let me see if I can find it. The "assembly my way" thread I stared would be my first guess.

Here, starting about post #36:

http://www.atariage....25#entry1970943

I agree with you about finding stuff. I like a forum format for allowing a topic to be discussed without noise from other topics, but it lacks an index. Hmm, the "next big thing" in form frameworks, auto indexes and auto topic summarizing. You heard it here first. :-)

Thanks! I had not thought about the byte-counting consequences of TI E/A's forcing the even-byte boundary on machine instructions and DATA directives and I certainly was unaware of the mistaken alignment of those by other assemblers.

...lee

#19 Lee Stewart OFFLINE  

Lee Stewart

    Chopper Commander

  • 175 posts

Posted Sat May 19, 2012 7:12 AM

View PostWillsy, on Sat May 19, 2012 3:57 AM, said:

Okay, I'll bite! :-) what's the project?

The project is hoisting TI Forth into cartridge ROM to be functionally equivalent to the current version. That is actually down the road from (1) annotating the assembly source for TI Forth and (2) detailing how to produce a working system from that source, which, of course, are necessary excercises to enable me to even think about the project. If I manage to complete all this, I might then attempt a version upgrade to use normal file I/O for Forth screens/blocks and use sector I/O only for reading to convert current TI Forth screens. Ambitious, I know---but, so far, I am having fun!

...lee

#20 Lee Stewart OFFLINE  

Lee Stewart

    Chopper Commander

  • 175 posts

Posted Sat May 19, 2012 7:13 AM

View Postretroclouds, on Sat May 19, 2012 5:26 AM, said:

Hmm... got a feeling it'll have something to do with Forth and Assembler? ;-)

Well, duh! :D I wonder what gave you that idea?

...lee

#21 Willsy ONLINE  

Willsy

    Dragonstomper

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

Posted Sat May 19, 2012 1:06 PM

Ah! Okay that sounds pretty interesting. Well, when you get around to putting it in a ROM let me know. I have some tools that can make it easier for you and I can give you some advice re ASM994A - I have used it for Turboforth since day 1 with no issues at all.

There's a bit of a Forth renaissance at the moment in our little 4A world. All good!

Mark

#22 matthew180 OFFLINE  

matthew180

    Stargunner

  • 1,242 posts
  • Location:Marshall, Michigan

Posted Sat May 19, 2012 6:53 PM

View PostLee Stewart, on Sat May 19, 2012 6:55 AM, said:

Thanks! I had not thought about the byte-counting consequences of TI E/A's forcing the even-byte boundary on machine instructions and DATA directives and I certainly was unaware of the mistaken alignment of those by other assemblers.

...lee

Machine instructions and word-based (16-bit) instructions (i.e. anything that is *not* one of the 8 byte instructions) will always address memory at even addresses because the 9900 only has a 15-bit address bus. If the assembler messes up and writes the object file with instructions at an odd address, your program will crash in a hurry.

IMO, the only time an assembler should force EVEN alignment is when it encounters a machine instruction, otherwise leave it up to the programmer to use BYTE, TEXT, DATA, and EVEN to control where the data goes.

#23 Lee Stewart OFFLINE  

Lee Stewart

    Chopper Commander

  • 175 posts

Posted Sat May 19, 2012 11:50 PM

View PostWillsy, on Sat May 19, 2012 1:06 PM, said:

Ah! Okay that sounds pretty interesting. Well, when you get around to putting it in a ROM let me know. I have some tools that can make it easier for you and I can give you some advice re ASM994A - I have used it for Turboforth since day 1 with no issues at all.

There's a bit of a Forth renaissance at the moment in our little 4A world. All good!

Mark

Thanks! I certainly knew I could count on you, as well as Matthew and Retroclouds!

...lee

#24 apersson850 OFFLINE  

apersson850

    Star Raider

  • 84 posts

Posted Mon May 21, 2012 3:42 PM

You're right about the EVEN directive being redundant in many cases with TI's assembler software. It's only if you do something like this

EVEN
BYTE 1
XYZZY
DATA 112

Then the label XYZZY will not have the value of the address of the DATA (112), but one byte less.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users