Problem with xbasic compiler

Pagina 4/4
1 | 2 | 3 |

Van PingPong

Prophet (3793)

afbeelding van PingPong

09-07-2021, 13:51

z80 and 6502 are extremely different beasts, z80 rely on its registers to perform fast operations on temporary data while 6502 uses heavily page 0 addressing.
this result in extremely different approaches in asm. while some operations are similar (add a value to another both stored in registers) there are others that have no equivalent. For example the pre-post indexed mode have no exact equivalent on z80, the close could be something like ld register, (IX+constant value) where IX is addedd with a 8 bit offset to form a full 16 bit address used to load a register from.
By contrast, some instructions have no equivalent on 6502 like LDIR which copy a byte array from a source address to another with a specified length (on 6502 you need to code a subroutine for this), or exotic Ex SP,(HL) EX (SP),HL which exchanges HL with the value on the stack (16 bit)

I'm a bit rusty on 6502 asm, but if you want, just for fun, try to convert this basic pseudo code in 6502 assembly. It does almost the same thing of the NYYRIKKI's asm z80 code .

Comparing the difference would be interesting...

DEF FN PEEK16(AD) = PEEK(AD)+256*PEEK(AD+1)

STRING_DESCRIPTOR = PEEK16(Z) load string descriptor 16 bit ptr
XBASIC_STRING_PTR = ADDRESS_OF_VAR (A$); basic ptr to string in X-BASIC 16 bit ptr

BASIC_STRING_LEN = PEEK(STRING_DESCRIPTOR) ; 8 bit value wuth length
POKE XBASIC_STRING_PTR, BASIC_STRING_LEN: XBASIC_STRING_PTR = XBASIC_STRING_PTR + 1
BASIC_STRING_PTR = PEEK16(STRING_DESCRIPTOR+1) 
FOR T=0 TO BASIC_STRING_LEN
POKE XBASIC_STRING_PTR+T, PEEK(BASIC_STRING_PTR+T)
NEXT T

Van freedom711

Rookie (27)

afbeelding van freedom711

09-07-2021, 16:52

Oh my God!! Big smile
I need to get help!!
Assmbly 6502 I don't remember anything anymore....
I was young when I learned something at university, and I applied it on Commodore 64, Apple II, Atari computers ...

It's a challenge to myself!!!

Pagina 4/4
1 | 2 | 3 |