need 24bit registers help

PM development, programming, hacking and all that fun stuff.
Post Reply
User avatar
YasaSheep
Posts: 195
Joined: November 20th, 2005, 04:04
Location: Portland (Also the discord)
Contact:

need 24bit registers help

Post by YasaSheep » June 21st, 2007, 03:24

I just wanna make sure this is right cause I don't really understand it. I'm using x1 to address a variable location that has to be calculated. If I add to x1 and it goes above 0xFFFF will it spill over into XI as I expect? Even better, can I just mul l,a and HL will spill into I if it goes above 0xFFFF? That'd be a time saver. :)

Lupin
Team Pokémé
Posts: 94
Joined: January 10th, 2005, 13:06

need 24bit registers help

Post by Lupin » June 24th, 2007, 23:16

nope, if you do an operation on a register you only do an operation on THAT register. There are no overflows into other registers. For overflowing X1 into XI you have to move XI to A then do addc A, 0 and then move A back to XI... i believe :)

User avatar
YasaSheep
Posts: 195
Joined: November 20th, 2005, 04:04
Location: Portland (Also the discord)
Contact:

need 24bit registers help

Post by YasaSheep » June 28th, 2007, 05:06

Okay.. so what about just moving an address? I'm not sure what happens in mov x1,map1 but I do know that mov x2,cmap; mov [x2],x1 only moves two bytes. I'd like to store all three bytes.. do I have to do: mov x1,strings; movx a,strings; mov x2,cmap; mov [x2],a; inc x2; mov [x2],x1 ?

Lupin
Team Pokémé
Posts: 94
Joined: January 10th, 2005, 13:06

need 24bit registers help

Post by Lupin » June 29th, 2007, 00:18

Dont know what you are doing with x1 and movx a, strings (that opcode doesnt exist afaik because a, b and BA arent addressing registers)... but lets keep it general: If you want to store 3 bytes then you'll have to do a 1 and a 2 byte write operation. mov [x1], a ; inc x1 ; mov [x1], x2 - something like that. For adressing there are seperate 8 bit HIGH adress register for HL ( the I register), one for x1 and one for x2 - these can have different values. The adressing of the PM is 21 bit internally not 24 bit (even though you have to write 24 bits into the registers)... paged memory is a thing you find out best by trial and error :-P

User avatar
YasaSheep
Posts: 195
Joined: November 20th, 2005, 04:04
Location: Portland (Also the discord)
Contact:

need 24bit registers help

Post by YasaSheep » June 29th, 2007, 03:53

Oh whoops, I was trying to take the first byte out of the address and put it into the a.. "strings" was also supposed to be "map1" :P So I guess the question was how to read the first byte of an address.

PlayerOne

need 24bit registers help

Post by PlayerOne » July 6th, 2007, 15:25

Don't know if you've solved this yet, but it struck me today that one possible solution would be to force the page using the .org keyword, so at least you know what value to put in the high byte. That is: ".org $40000" will put the next 64k on page 4. Probably.

Post Reply