simple 68k loop
Moderator: BigEvilCorporation
simple 68k loop
Hello, first time I try to do asm on the 68k, something is wrong with this code:
mov.b #62, d0
L1:
dc.l _INT
dbeq d0,L1
so, what is wrong ? I try to call it a init.
Thanks
mov.b #62, d0
L1:
dc.l _INT
dbeq d0,L1
so, what is wrong ? I try to call it a init.
Thanks
-
- Very interested
- Posts: 2442
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
Re: simple 68k loop
What is that DC.L doing there ? It will be executed as an instruction which will depend on exact value of _INT.
Mida sa loed ? Nagunii aru ei saa
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
Re: simple 68k loop
well I try to reduce the init code of megadrive :
from :
to :
but it doesnt work and dont know how to debug!
edit: and maybe I'm totally wrong
from :
Code: Select all
.section .text.keepboot
.org 0x00000000
_Start_Of_Rom:
_Vecteurs_68K:
dc.l 0x00FFFE00 /* Stack address */
dc.l main /* Program start address */
dc.l _INT
dc.l _INT
dc.l _INT
dc.l _INT
dc.l _INT
dc.l _INT
dc.l _INT
dc.l _INT
dc.l _INT
dc.l _INT
dc.l _INT, _INT, _INT, _INT
dc.l _INT, _INT, _INT, _INT
dc.l _INT, _INT, _INT, _INT
dc.l _INT, _INT, _INT, _INT
dc.l _INT
dc.l _INT
dc.l _INT
dc.l _INT
dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT
dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT
dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT
dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT
.incbin "boot/rom_head.bin", 0x10, 0x98
_INT:
rte
Code: Select all
.section .text.keepboot
.org 0x00000000
_Start_Of_Rom:
_Vecteurs_68K:
dc.l 0x00FFFE00 /* Stack address */
dc.l main /* Program start address */
mov.b #62, d0
L1:
dc.l _INT
dbeq d0,L1
.incbin "boot/rom_head.bin", 0x10, 0x98
_INT:
rte
edit: and maybe I'm totally wrong
Last edited by bioloid on Tue Oct 09, 2018 5:06 pm, edited 1 time in total.
Re: simple 68k loop
That is not code, it's data. You can't change it to code.
Re: simple 68k loop
shit, thanks.
Re: simple 68k loop
any idea to reduce the size ?
Re: simple 68k loop
maybe I should port this to asm :
I'm trying to do uniform color screen to less bytes possible lol
Code: Select all
typedef unsigned short u16;
typedef unsigned long u32;
typedef volatile u16 vu16;
typedef volatile u32 vu32;
#define GFX_DATA_PORT 0xC00000
#define GFX_CTRL_PORT 0xC00004
#define GFX_WRITE_CRAM_ADDR(adr) ((0xC000 + ((adr) & 0x3FFF)) << 16) + (((adr) >> 14) | 0x00)
void main()
{
static const unsigned char regValues[] = { 0x04, 0x74, 0xE000, 0xD000, 0xC000, 0xDC00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x81, 0xD800, 0x00, 0x02, 0x01, 0x00, 0x00 };
vu16 *pw;
vu32 *pl;
u16 i;
// init
pw = (u16 *) GFX_CTRL_PORT;
for (i = 0x00; i < 0x13; i++) *pw = 0x8000 | (i << 8) | regValues[i];
// set background color
pw = (vu16*) GFX_DATA_PORT;
pl = (vu32*) GFX_CTRL_PORT;
*pl = GFX_WRITE_CRAM_ADDR(0);
*pw = 7|7<<4|7<<8;
}
Re: simple 68k loop
Ok I give up, I've added the repo here https://github.com/skarab/megadrive-512
maybe use it later.. or not.
maybe use it later.. or not.
-
- Interested
- Posts: 33
- Joined: Tue Feb 23, 2016 4:45 pm
Re: simple 68k loop
That looks like the interupt table at the start of a ROM. You can't get that any smaller, that's just what the MD rom format is, every rom has to have it.
Re: simple 68k loop
All this thread and not a single person mentioned dcb.l? (which is basically dc.l in repeat)
This is the same thing as 62 dc.l _INT in a row:
...although I admit I'm not sure if GAS supports it, given how it loves to ignore established syntax (even if it doesn't, pretty sure it must have a similar directive)
This is the same thing as 62 dc.l _INT in a row:
Code: Select all
dcb.l 62, _INT
Sik is pronounced as "seek", not as "sick".
Re: simple 68k loop
Sik, you can always use repeat, like:
bioloid, if you don’t use exceptions for sure you can get rid of most of the vector table. And most of the header too except of the ‘SEGA’ mark. But yeah that’s kind of unorthodox.
If you are going for that kind of minimalism, absolutely go for asm instead of C.
Code: Select all
.rept 16
move.l d0, (a1)+
.endr
If you are going for that kind of minimalism, absolutely go for asm instead of C.
HELP. Spanish TVs are brain washing people to be hostile to me.
Re: simple 68k loop
Sik: wow awesome, will test
Miquel : I'm not sure if the header may be discarded, i've reduced .incbin "boot/rom_head.bin", 0x10, 0x98 <- the 0x100 to 0x98 it saves bytes but below it brokes the build. maybe I should play with sgdk.ld too.
You are perfectly right about asm, but I may want to keep C for flexibility if I want to use this for 4k and so later on...
Edit: Sik it doesn't compile sadly
and this one doesnt save bytes, it looks like it's unrolled at build time
maybe a m68k-elf-as option
Miquel : I'm not sure if the header may be discarded, i've reduced .incbin "boot/rom_head.bin", 0x10, 0x98 <- the 0x100 to 0x98 it saves bytes but below it brokes the build. maybe I should play with sgdk.ld too.
You are perfectly right about asm, but I may want to keep C for flexibility if I want to use this for 4k and so later on...
Edit: Sik it doesn't compile sadly
and this one doesnt save bytes, it looks like it's unrolled at build time
Code: Select all
.rept 62
dc.l _INT
.endr
Re: simple 68k loop
Certain, you only need 8 very first bytes for stack and pc init, and then on address 0x100 the ascii SEGA mark. You even can use this same address to init the copy protection chip, 2 less bytes!
That's just an example, check everything is ok first.
As a base rule every time you use 4bytes as data probably there is a better way to do it.
Code: Select all
.section .text.boot
.org 0x0
dc.l 0x00000000
dc.l Reset
Reset:
move.w #0x2700, sr /* disable exceptions */
move.l Header(pc), 0xA4000
.org 0x100
Header:
.ascii "SEGA"
As a base rule every time you use 4bytes as data probably there is a better way to do it.
HELP. Spanish TVs are brain washing people to be hostile to me.
Re: simple 68k loop
wow awesome thanks Miquel, it works!
I pushed it to the repo, I've added palette animation
I pushed it to the repo, I've added palette animation
-
- Very interested
- Posts: 746
- Joined: Sat Dec 15, 2007 7:49 am
- Location: Kazakhstan, Pavlodar
Re: simple 68k loop
The DBcc uses only 16 bits for count. So you should use .W and not .B or .L for move opcode. Also, DBcc count until -1, not 0. So, you should load counter with 4 for count to 5.
Anyway, all rookies should read M68000 Programming Manual.pdl before something ask here.
Anyway, all rookies should read M68000 Programming Manual.pdl before something ask here.