Macro/Function Pseudo Instructions Everyone Should Use?
Re: Macro/Function Pseudo Instructions Everyone Should Use?
I tried to build, but didn't quite make it. I've contacted the owner of a fork on their Github issue. (Tragically, Andrew passed away earlier this month, so we will need third-party assistance. It would be great to have this project of his available as a runnable release.)
Re: Macro/Function Pseudo Instructions Everyone Should Use?
Oh my goodness, that's terrible. I had no idea. I've benefitted considerably from his work in both hardware and software, which he gave to the public so generously.
My condolences to his family and friends. A really sad loss to all of those who interacted with him here.
My condolences to his family and friends. A really sad loss to all of those who interacted with him here.
Re: Macro/Function Pseudo Instructions Everyone Should Use?
Oh-Two wrote:
I've downloaded Andrew Jacob's Dev65 assembler...But I can't figure out how to run it!
I don't mind helping out with some answers, but there's likely to be a lot of back-and-forth that will not be of any interest at all to many readers of this thread.
Curt J. Sampson - github.com/0cjs
Re: Macro/Function Pseudo Instructions Everyone Should Use?
BigEd wrote:
I tried to build, but didn't quite make it. I've contacted the owner of a fork on their Github issue. (Tragically, Andrew passed away earlier this month, so we will need third-party assistance. It would be great to have this project of his available as a runnable release.)
Re: Macro/Function Pseudo Instructions Everyone Should Use?
Not sure it's something everyone should be using, but personally i added some alternative instruction mnemonics to make them more readable.
specifically for INC, DEC, CL*, SE*, PH*, and PL*
examples:
can be turned into:
it's especially noticable with the NotePad++ highlighting i'm using for Assembly:
I also got the good old "ADD" and "SUB" Pseudo Instructions which assemble into "CLC ADC" and "SEC SBC" respectively.
and just for fun, and becuase i often hear people compare the Zeropage to a RISC CPU's Register File i added a bunch of RISC-like instructions that actually use the Zeropage as it's Register file. it also predefines some constants so you can use R0-R255 to refer to decimal 0-255, making the RISC Experience even more immersive! maybe one day i'll make a 65C02 FPGA Core around this idea.
specifically for INC, DEC, CL*, SE*, PH*, and PL*
examples:
Code: Select all
PHA
PLP
CLC
INX
DEY
SEI
etcCode: Select all
PSH A
PLL P
CLR C
INC X
DEC Y
SET I
etcand just for fun, and becuase i often hear people compare the Zeropage to a RISC CPU's Register File i added a bunch of RISC-like instructions that actually use the Zeropage as it's Register file. it also predefines some constants so you can use R0-R255 to refer to decimal 0-255, making the RISC Experience even more immersive! maybe one day i'll make a 65C02 FPGA Core around this idea.
Re: Macro/Function Pseudo Instructions Everyone Should Use?
Agumander wrote:
One assembler feature I've been wondering exists anywhere is using "{" as label to the next instance of "}", with the ability to nest them.
(It could be some other pair of demarcating characters, those are just the first I think of as a C guy)
This would save me from having to come up with unique label names, or avoid bugs that happen if i miscount bytes when writing BEQ *+n
Had this happen on my current project when I forgot that one of my named memory locations wasn't actually zero page. Oops!
(It could be some other pair of demarcating characters, those are just the first I think of as a C guy)
This would save me from having to come up with unique label names, or avoid bugs that happen if i miscount bytes when writing BEQ *+n
Had this happen on my current project when I forgot that one of my named memory locations wasn't actually zero page. Oops!
Author of the GeckOS multitasking operating system, the usb65 stack, designer of the Micro-PET and many more 6502 content: http://6502.org/users/andre/
Re: Macro/Function Pseudo Instructions Everyone Should Use?
Proxy wrote:
Not sure it's something everyone should be using, but personally i added some alternative instruction mnemonics to make them more readable.
BLO for BCC
BHS for LCS
Code: Select all
cmp #Value
blo Label
Code: Select all
cmp #Value
bcc Label
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Macro/Function Pseudo Instructions Everyone Should Use?
BillG wrote:
is more obvious than
Edit, addition: In my program flow-control structure macros, what I would do for the CMP #value, BCC <label> is something like:
Code: Select all
CMP #value
IF_GE ; If it was greater than or equal to the value,
<do_stuff> ; do this stuff.
<do_stuff>
END_IFand the IF_GE assembles the BCC down to the END_IF. It leaves a dummy byte for the branch distance, and that byte gets filled in by the END_IF later when it is encountered during assembly. No label is needed. These are nestable too, with more structures of the same or different kind.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: Macro/Function Pseudo Instructions Everyone Should Use?
These are from the Motorola instruction sets.
BLT, BLE, BGT, BGE are for use after signed comparision.
BLO (LOwer), BLS (Lower or Same), BHI (Higher) and BHS (Higher or Same) are the unsigned counterparts.
MOS may not have adopted those out of "copyright" concerns.
BLT, BLE, BGT, BGE are for use after signed comparision.
BLO (LOwer), BLS (Lower or Same), BHI (Higher) and BHS (Higher or Same) are the unsigned counterparts.
MOS may not have adopted those out of "copyright" concerns.
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Macro/Function Pseudo Instructions Everyone Should Use?
Ah, that makes sense, although require a small amount of learning if one has not come from the other processors. I added to my post above while you were posting.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: Macro/Function Pseudo Instructions Everyone Should Use?
GARTHWILSON wrote:
In my program flow-control structure macros, what I would do for the CMP #value, BCC <label> is something like:
and the IF_GE assembles the BCC down to the END_IF. It leaves a dummy byte for the branch distance, and that byte gets filled in by the END_IF later when it is encountered during assembly. No label is needed. These are nestable too, with more structures of the same or different kind.
Code: Select all
CMP #value
IF_GE ; If it was greater than or equal to the value,
<do_stuff> ; do this stuff.
<do_stuff>
END_IFYou can choose different phrases or add a suffix: GES and GEU
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Macro/Function Pseudo Instructions Everyone Should Use?
For that, I think your signed comparison with the EOR #$80's would come before the IF, like the CMP above comes before the IF. I don't think I have ever done signed for 8-bit numbers though, only 16 or more.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
- BigDumbDinosaur
- Posts: 9425
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: Macro/Function Pseudo Instructions Everyone Should Use?
BillG wrote:
MOS may not have adopted those out of "copyright" concerns.
More likely, they didn't adopt them because the 6502 didn't have a direct equivalent for any of them. As part of the cost reduction done by Chuck Peddle and company, instructions were removed that could be synthesized with short sequences of other instructions.
I personally have never had a need for instruction aliases. To me, it's just more junk to learn.
x86? We ain't got no x86. We don't NEED no stinking x86!
- BigDumbDinosaur
- Posts: 9425
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: Macro/Function Pseudo Instructions Everyone Should Use?
Getting back on topic, a macro I use a lot in 65C816 programming is one that generates a stack frame when given a list of parameters:
The above is for the Kowalski assembler. The leftmost parameter in the macro invocation will be at the top of the stack frame. The lowest word on the stack, that is, the word at SP+1, will be a count of the total words in the frame, not including the count itself.
The %0$ variable is the macro's name. Should the macro be invoked without any parameters, the message...
...will be displayed and assembly will halt.
I've found in 65C816 programming that "long" addresses are better handled as 32-bit quantities instead of 24 bits, especially if pointer arithmetic will be involved. The problem is how to push a 32-bit pointer given a 16- or 24-bit address. In the Kowalski assembler, that's easy. For example, to push two 32-bit pointers, the macro would be invoked as follows:
The >> 16 notation is a 16-bit right-shift and & $FFFF is a logical AND that masks bits 16-31.
Code: Select all
; generate stack frame from words...
;
pushparm .macro ... ;accepts an arbitrary number of parameters
.if %0 ;if at least 1 parameter...
.i .set 0 ;initialize parameter index
.rept %0 ;repeat for number of parameters
.i .= .i+1
pea #%.i ;push parameter as a word
.endr ;end of repeated block
pea #.i ;push number of words in frame
.else
.error "error: macro syntax: "+%0$+" param1[,param2[,param3]] ..."
.endif
.endmThe above is for the Kowalski assembler. The leftmost parameter in the macro invocation will be at the top of the stack frame. The lowest word on the stack, that is, the word at SP+1, will be a count of the total words in the frame, not including the count itself.
The %0$ variable is the macro's name. Should the macro be invoked without any parameters, the message...
- error: macro syntax: pushparm param1[,param2[,param3]] ...
...will be displayed and assembly will halt.
I've found in 65C816 programming that "long" addresses are better handled as 32-bit quantities instead of 24 bits, especially if pointer arithmetic will be involved. The problem is how to push a 32-bit pointer given a 16- or 24-bit address. In the Kowalski assembler, that's easy. For example, to push two 32-bit pointers, the macro would be invoked as follows:
Code: Select all
pushparm ptr1 >> 16, ptr1 & $FFFF, ptr2 >> 16, ptr2 & $FFFFThe >> 16 notation is a 16-bit right-shift and & $FFFF is a logical AND that masks bits 16-31.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: Macro/Function Pseudo Instructions Everyone Should Use?
Gungwald wrote:
BigEd wrote:
I tried to build, but didn't quite make it. I've contacted the owner of a fork on their Github issue. (Tragically, Andrew passed away earlier this month, so we will need third-party assistance. It would be great to have this project of his available as a runnable release.)
Download installer
If you have trouble, open an issue and I'll fix it.