Author Topic: Assembler Directives  (Read 6699 times)

0 Members and 1 Guest are viewing this topic.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Assembler Directives
« 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.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Binder News

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 785
  • Rating: +46/-3
  • Zombie of Tomorrow
    • View Profile
Re: Assembler Directives
« Reply #1 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.
« Last Edit: January 06, 2011, 06:48:06 pm by Binder News »
Spoiler For userbars:







Hacker-in-training!   Z80 Assembly Programmer     Axe Programmer
C++ H4X0R             Java Coder                           I <3 Python!

Perdidisti ludum     Cerebrum non habes

"We are humans first, no matter what."
"Fame is a vapor, popularity an accident, and riches take wings. Only one thing endures, and that is character."
Spoiler For Test Results:





Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Assembler Directives
« Reply #2 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)
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Assembler Directives
« Reply #3 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.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Assembler Directives
« Reply #4 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?
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Assembler Directives
« Reply #5 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.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Binder News

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 785
  • Rating: +46/-3
  • Zombie of Tomorrow
    • View Profile
Re: Assembler Directives
« Reply #6 on: January 06, 2011, 09:10:42 pm »
do you have .nolist #include ..... .list ?
Spoiler For userbars:







Hacker-in-training!   Z80 Assembly Programmer     Axe Programmer
C++ H4X0R             Java Coder                           I <3 Python!

Perdidisti ludum     Cerebrum non habes

"We are humans first, no matter what."
"Fame is a vapor, popularity an accident, and riches take wings. Only one thing endures, and that is character."
Spoiler For Test Results:





Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Assembler Directives
« Reply #7 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.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Binder News

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 785
  • Rating: +46/-3
  • Zombie of Tomorrow
    • View Profile
Re: Assembler Directives
« Reply #8 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.
« Last Edit: January 06, 2011, 09:39:29 pm by Binder News »
Spoiler For userbars:







Hacker-in-training!   Z80 Assembly Programmer     Axe Programmer
C++ H4X0R             Java Coder                           I <3 Python!

Perdidisti ludum     Cerebrum non habes

"We are humans first, no matter what."
"Fame is a vapor, popularity an accident, and riches take wings. Only one thing endures, and that is character."
Spoiler For Test Results:





Offline FloppusMaximus

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +57/-5
    • View Profile
Re: Assembler Directives
« Reply #9 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.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Assembler Directives
« Reply #10 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.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Binder News

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 785
  • Rating: +46/-3
  • Zombie of Tomorrow
    • View Profile
Re: Assembler Directives
« Reply #11 on: January 06, 2011, 10:44:45 pm »
I have no idea.
Spoiler For userbars:







Hacker-in-training!   Z80 Assembly Programmer     Axe Programmer
C++ H4X0R             Java Coder                           I <3 Python!

Perdidisti ludum     Cerebrum non habes

"We are humans first, no matter what."
"Fame is a vapor, popularity an accident, and riches take wings. Only one thing endures, and that is character."
Spoiler For Test Results: