Jump to content
IGNORED

Assembly on the 99/4A


matthew180

Recommended Posts

On 7/22/2019 at 8:05 AM, TheBF said:

 

Can you explain why my JNE $+4 didn't work?

I assumed I would jump 4 lines of code forward no matter what those lines said?

Then I assumed, because I'm Not finding much info on $, that I should add 2 bytes for each line?..that didn't work either.

Link to comment
Share on other sites

5 minutes ago, GDMike said:

Can you explain why my JNE $+4 didn't work?

I assumed I would jump 4 lines of code forward no matter what those lines said?

Then I assumed, because I'm Not finding much info on $, that I should add 2 bytes for each line?..that didn't work either.

Think of $ as the label to the left of current line.

youre better off using real labels until you really understand how instructions are stored. 

 

But

 

The way to be really sure is to look at the listing file to see how many words apart your target is. Some instructions are 2 bytes, but if they have addresses or immediate arguments, these add another word. 

 

JNE $+2 is a no-op

JNE $+4 will skip over a simple instruction like DECT or A R4,R5

JNE $+6 will skip over LI R0,1234

 

or MOV R4,@>A000

 

JNE $+8 will skip over MOV @>2002,@>8C00

  • Thanks 1
Link to comment
Share on other sites

As I understand it JMP $+4 will jump 4 BYTES forward not 4 lines of code.

So you have to understand how many bytes are between where $ is and where you want to jump to.

As a rule of thumb, register to register instruction are 2 bytes.  Immediate instructions are 4 bytes and address to address instruction are 6 bytes (i think)

 

You could make some tests by putting some routines in memory and then JMP $+2  or  JMP $+4 ETC... to see which routine runs.

It's why the assembler gives us labels, ? but you can make label-less code work as farmer potato demonstrated.

 

what he said

Edited by TheBF
  • Thanks 1
Link to comment
Share on other sites

I've been using labels, but I've tried two bytes, one byte, but you're saying, what he's saying, which is I have to actually count up bytes used, as in if I had LI R0,750 million!, I get it.i was afraid of that answer..Darn it.  Lol but it's great for simple instructions as you said... thank you!

Edited by GDMike
Link to comment
Share on other sites

Another gotcha with jump instructions is that the target address must be within -128 to +127 words (-256 to +254 bytes) of the instruction following the jump instruction. The machine code for a jump instruction stores the assembler-calculated word offset as a signed byte, hence the limitation in the jump range. When the jump instruction is executed, this offset is converted to a byte offset and added to the current Program Counter (PC) to get the jump’s target address. The PC always points to the next instruction to be executed, which, in this case and before adding the byte offset for the jump, is the instruction following the jump instruction.

 

If you would rather think of the jump range in terms of the address of the jump instruction, just add one to each end of the word range, making the range -127 to +128 words (-254 to +256 bytes) from the address of the jump instruction.

 

...lee

  • Like 2
Link to comment
Share on other sites

18 hours ago, GDMike said:

Can you explain why my JNE $+4 didn't work?

I assumed I would jump 4 lines of code forward no matter what those lines said?

Then I assumed, because I'm Not finding much info on $, that I should add 2 bytes for each line?..that didn't work either.

in the example:

B000 0600 DEC  R0
B002 10FE JNE  $-2        i like no labels
B004 C2FA MOV  *R10+,R11
B006 045B RT

line B002 jumps to line B000. "conditional loop"


if changed to:

B000 0600 DEC  R0
B002 10FE JNE  $+4        i like no labels
B004 C2FA MOV  *R10+,R11
B006 045B RT

line B002 would jump to line B006. "return"


if changed to:

B000 0600 DEC  R0
B002 10FE JNE  $+4        i like no labels
B004 A80F A    R15,@BNK
B006 A000
B008 045B RT

line B002 would jump to line B006. But A000 is not an instuction!


this is also wrong:

if changed to:

B000 0600 DEC  R0
B002 10FE JNE  $+4        i like no labels
B004 C820 MOV  @>AA00,@BNK
B006 AA00
B008 A000
B00A 045B RT

line B002 would jump to line B006. But AA00 is not an instuction!

...hope this helps a little?

:)

      <<<corrected>>>... #936

Edited by HOME AUTOMATION
made a little boo-boo here ...see correction below
  • Thanks 1
Link to comment
Share on other sites

3 hours ago, GDMike said:

Oh yeah, I forgot there is still that limitation of how far it can jump! it's not a B..ohh can't B goto like >FFFF or something?

 

No, to >FFFE. :)

 

But our machine is very forgiving, you can also go to FFFF, but it will ignore the last bit. Other architecture will throw a Bus Error at you.

  • Like 1
Link to comment
Share on other sites

9 hours ago, HOME AUTOMATION said:

I was just testing you...:grin:

 

No, really I used line-by-line assembler to crunch the op-codes...
Then I juggled the addresses around in notpad(sic).
I did overlook the offset limits a little.:roll:

...anyway sounds like you'll go far at this!;)

 

 P.S. too bad B is unconditional.:woozy:

I stayed up a little too late last night...

The offset limits are within range here.
But... I'd forgotten to update the op-codes for B002 in the last 3 examples!
Fixed!

In THIS UPDATED example:

B000 0600 DEC  R0
B002 10FE JNE  $-2        i like no labels
B004 C2FA MOV  *R10+,R11
B006 045B RT

line B002 jumps to line B000. "conditional loop"


if changed to:

B000 0600 DEC  R0
B002 1001 JNE  $+4        i like no labels
B004 C2FA MOV  *R10+,R11
B006 045B RT

line B002 would jump to line B006. "return"


if changed to:

B000 0600 DEC  R0
B002 1001 JNE  $+4        i like no labels
B004 A80F A    R15,@BNK
B006 A000
B008 045B RT

line B002 would jump to line B006. But A000 is not an instuction!


this is also wrong:

if changed to:

B000 0600 DEC  R0
B002 1002 JNE  $+6        i like no labels
B004 C820 MOV  @>AA00,@BNK
B006 AA00
B008 A000
B00A 045B RT

line B002 would jump to line B008. But A000 is not an instuction!

...I hope this is a little better?

8) I can see!

Edited by HOME AUTOMATION
spelling
  • Thanks 1
Link to comment
Share on other sites

If it were disassembled into something that could be edited into usable source code it would be cool. There are some things I'd change on the original, like screen size of display area, a count-down timer of lines left to compile etc...I love what he did with making it dont get me wrong.  ( I know, learn GPL and it would all make sense right).

Edited by GDMike
Link to comment
Share on other sites

On 7/24/2019 at 2:36 PM, GDMike said:

..I believe that assembler was written in GPL... thank you!!!

I don't think it is GPL because it runs fine on my computer which only has RAM - there is no gram kracker or final grom. As far as I know there is no way to make GPL run from RAM. For what it's worth, the simpler TI assembler is considerably faster than RAGASM

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

1 hour ago, senior_falcon said:

I don't think it is GPL because it runs fine on my computer which only has RAM - there is no gram kracker or final grom. As far as I know there is no way to make GPL run from RAM. For what it's worth, the simpler TI assembler is considerably faster than RAGASM

wrong.  Many grom games were converted to run from ram with a little code to copy the grom image to ram then execute.. runs great..from disk or rom cart.. needs 32k tho if your copy needs 32k, that's what it's doing.

  • Like 2
Link to comment
Share on other sites

1 hour ago, Tursi said:

Tombstone City is assembly, it's one of the examples from the Editor/Assembler disk. :)

 

I've not looked at the cartridge version to see what's on it... 

 

One EPROM, one GROM, the latter with only little code in it (< 0x580 byte). Seems to be just a link to the ROM.

 


6000: DATA  >AA,>01,>01,>00,>00,>00,>60,>10
6008: DATA  >00,>00,>00,>00,>00,>00,>00,>00
6010: DATA  >00,>00,>60,>23,>0E
6015: TEXT 'TOMBSTONE CITY'
6023: DST   >0900,@>834A
6027: CALL  GROM@>0018
602A: MOVE  >0010 BYTES FROM GROM@>6077 TO VDP@>0C80
6031: MOVE  >0032 BYTES FROM GROM@>6087 TO VDP@>0AE0
6038: MOVE  >0030 BYTES FROM GROM@>60B7 TO VDP@>0B40
603F: MOVE  >0010 BYTES FROM GROM@>60E7 TO VDP@>0B80
6046: MOVE  >00B8 BYTES FROM GROM@>60F7 TO VDP@>0BC0
604D: MOVE  >0008 BYTES FROM GROM@>61AF TO VDP@>0CC0
6054: MOVE  >0010 BYTES FROM GROM@>6067 TO VDP@>0384
605B: BACK  >06
605D: MOVE  >03CC BYTES FROM GROM@>61B7 TO VDP@>1002
6065: XML   >70

 

Edited by mizapf
Added GPL code
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

I get so sick of seeing this hate for GPL when in fact it is the most easy way to do something with little code an gets the job done.

 

To do this with Assembly would take some hacks and would not be compatible with most configurations.

 

Take a look at above GPL code it loads VDP screen menu and also character set into VDP RAM, then executes Assembly from Scratch PAD.

 

Try to write something like that in Assembly without the 4K of support routines in RAM to run it, try to pull that off using only 1073 bytes of memory like GPL did above.

  • Like 1
Link to comment
Share on other sites

I don't think anyone expressed a hate for GPL. But I think that TI used GROMs not only as a way to distribute GPL but also to provide data for machine code programs otherwise stored in ROMs (e.g. Parsec), and also as a copy protection mechanism.

 

Edited by Asmusr
  • Like 2
Link to comment
Share on other sites

3 hours ago, RXB said:

I get so sick of seeing this hate for GPL when in fact it is the most easy way to do something with little code an gets the job done.

 

To do this with Assembly would take some hacks and would not be compatible with most configurations.

 

Take a look at above GPL code it loads VDP screen menu and also character set into VDP RAM, then executes Assembly from Scratch PAD.

 

Try to write something like that in Assembly without the 4K of support routines in RAM to run it, try to pull that off using only 1073 bytes of memory like GPL did above.

Sorry Rich.. you know I think GPL is okay and definitely has its place, but you made the challenge. ;)

 

challenge.lst

 

No support code needed, 342 bytes.

 

But I don't think the GPL code provided takes anywhere near 1073 bytes... what were you including?

 

Edited by Tursi
upload listing, not source
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...