Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: Quigibo on January 06, 2011, 06:36:31 pm

Title: Assembler Directives
Post by: Quigibo on January 06, 2011, 06:36:31 pm
I am using TASM I think... or possibly SPASM.   The problem I am encountering is that the .org statement physically moves the code to that region instead of telling the compiler to reference all future labels from that origin.  Like for instance, if I do:

Code: [Select]
.org $0000
.dw  $F00D
.org $0000
.dw  $CAFE

The the first bytes of the executable will be $CAFE, but $F00D will be ignored.  Likewise, if I do:

Code: [Select]
.org $0000
.dw  $F00D
.org $9002
.dw  $CAFE

The first bytes will be $F00D, followed by $9000 zeros, and then $CAFE

What I would expect is that both should output just $F00D and then $CAFE as the origin should only tell the assembler what to do with labels and not to actually affect the compiled code.  Is there some other assembly directive or macro that behaves just like .org but doesn't physically move the code around?  I tried searching but I couldn't find one.
Title: Re: Assembler Directives
Post by: Binder News on January 06, 2011, 06:42:13 pm
.relocate ? Wait, I think that's in Brass. Let me check. Yea, relocate is a directive in Brass. It lets you do just what you want Quigibo.
Title: Re: Assembler Directives
Post by: calcdude84se on January 06, 2011, 08:11:39 pm
TASM supports nothing of the sort to my knowledge. To do relocation, you have to do something like this:
Code: [Select]
destination .equ $9001
.org $0000
.dw $CODE
;relocation
relocate .equ $
label:
dec a
jp nz,label+destination-relocate
In short, you need to define a couple equates and use +destination-relocate with any non-relative address (anything that's not jr or djnz)
Title: Re: Assembler Directives
Post by: calc84maniac on January 06, 2011, 08:14:29 pm
SPASM handles this properly, i.e. it only affects label values from that point on, but it doesn't move the location in the output binary.
Title: Re: Assembler Directives
Post by: Quigibo on January 06, 2011, 09:08:32 pm
Ok, I'm trying out SPASM, but every time I try to compile, the entire "ti83plus.inc" file is highlighted in red but with no error message and the code and data sizes say 0.  What do I need to do to make my TASM z80 file SPASM compatible?
Title: Re: Assembler Directives
Post by: calc84maniac on January 06, 2011, 09:10:16 pm
Ok, I'm trying out SPASM, but every time I try to compile, the entire "ti83plus.inc" file is highlighted in red but with no error message and the code and data sizes say 0.  What do I need to do to make my TASM z80 file SPASM compatible?
Try piping the output to a file, and you might be able to see the error message.
Title: Re: Assembler Directives
Post by: Binder News on January 06, 2011, 09:10:42 pm
do you have .nolist #include ..... .list ?
Title: Re: Assembler Directives
Post by: Quigibo on January 06, 2011, 09:16:52 pm
Oh there was actually an error in the file... so weird TASM didn't pick it up.   One of the comments accidentally started with a colon instead of a semicolon.  Thanks for the suggestion about piping it, I forgot about that.  The errors really should be displayed at the end of the message though so you can see it in the terminal.  Should be working now.
Title: Re: Assembler Directives
Post by: Binder News on January 06, 2011, 09:38:58 pm
Have you ever used Wabbitcode? It's and IDE for ASM. It's still Alpha version, but it works. http://wabbit.codeplex.com/releases/view/45275
Use Ctrl+B to compile.
Title: Re: Assembler Directives
Post by: FloppusMaximus on January 06, 2011, 09:50:07 pm
SPASM handles this properly, i.e. it only affects label values from that point on, but it doesn't move the location in the output binary.
"Properly" is a matter of opinion... it's a useful feature, to be sure, but it's also rather annoying that it doesn't behave the same way ORG does in every other assembler.

In tpasm (and I'm pretty sure I've seen this in other assemblers, too, though I'm not sure which), there are distinct ORG and RORG directives.  ORG sets both the program counter and output location (i.e., does the same thing ORG does in most assemblers); whereas RORG sets the program counter but keeps the same output location (i.e., what spasm's .ORG or brass's .RELOCATE does.)  I've done the same in miniasm and Mimas.
Title: Re: Assembler Directives
Post by: Quigibo on January 06, 2011, 10:43:45 pm
Hmm... I still have a strange problem.  The .db and .dw directives don't seem to be working.  It compiles with no errors, but I go to open the .lst file and even though the program counter is advancing correctly for the data, nothing is being outputted to the binary.  Here is an example:

Code: [Select]
   93 00:000A -  -  -  - 
   94 00:000A -  -  -  -
   95 00:000A -  -  -  -  .dw $6DBB
   96 00:000C -  -  -  - 
   97 00:000C -  -  -  -
   98 00:000C F3 -  -  -  di
   99 00:000D -  -  -  - 
  100 00:000D -  -  -  -  Loop:
  101 00:000D 3E -  -  -      ld a,1
  102 00:000F D3 -  -  -      out ($20),a
  103 00:0011 FD 21 -  -      ld iy,plotsScreen+384
  104 00:0015 21 -  -  -      ld hl,Length

The data directives aren't being added to the binary like the instructions are, I even checked the binary to make sure it wasn't just an output error with the list file, but they're not there either.
Title: Re: Assembler Directives
Post by: Binder News on January 06, 2011, 10:44:45 pm
I have no idea.