Ladies and Gentlemen,
i have to ask for a quick favor. My free time is currently quite limited, however i try to continue with my B4A-C64. (It's a C64 emulator written in B4A)
The good news is everything i coded so far compiles without problems. File Handling works (at least the memory dump looks after initializing the roms good)
I'm somewhat more the assembler guru so i'm trying to understand how byte operations (xor, and, shift etc) with B4A works. Since B4A is leaned towards java i know that there is no "real" unsigned char, basically a byte is always signed. That is of course no problem as long as you just carry "bytes" around, however it will not work with operations such as xor for example. So what i did is declaring basically all bytes as integers, because the BIT library expects Integers.
I have here for example the C64 opcode "BRK" in B4A. Before i end up in huge debugging i thought it would be a good idea to ask here before if that works.
I wrote that for the iOS before in C/C++ and the C code is after the B4A code.
Here's the code for that function - it's pretty much self explaining:
' Der Assembler-Befehl BRK erzeugt einen softwareseitigen Interrupt.
' Um den BRK-Interrupt vom Hardware-Interrupt unterscheiden zu können, setzt der BRK-Befehl das Break-Flag im Statusregister.
Sub BRK
Dim hb As Int
Dim lb As Int
Dim adr As Int
vars.PC = vars.PC + 2
hb = Bit.ShiftRight(vars.PC,8)
lb = Bit.And(vars.PC, 0xFF)
memory.PushStack(hb)
memory.PushStack(lb)
memory.SetFlagB
memory.PushStack(vars.PS)
adr = memory.AbsAdd(memory.peek(0xFFFE), memory.peek(0xFFFF), vars.c64true)
memory.SetFlagI
vars.PC = adr
End Sub
and here is my c-code (iOS)
void BRK(void)
{
//store PC in Stack
PC +=2;
c64byte hb = PC >> 8;
c64byte lb = PC & 0xFF;
PushStack(hb);
PushStack(lb);
//store Processor Status in Stack
SetFlagB();
PushStack(PS);
//Set new Programm Counter
c64ushort adr = AbsAdd(peek(0xFFFE), peek(0xFFFF), c64true);
SetFlagI();
PC=adr;
}
Comments?
i have to ask for a quick favor. My free time is currently quite limited, however i try to continue with my B4A-C64. (It's a C64 emulator written in B4A)
The good news is everything i coded so far compiles without problems. File Handling works (at least the memory dump looks after initializing the roms good)
I'm somewhat more the assembler guru so i'm trying to understand how byte operations (xor, and, shift etc) with B4A works. Since B4A is leaned towards java i know that there is no "real" unsigned char, basically a byte is always signed. That is of course no problem as long as you just carry "bytes" around, however it will not work with operations such as xor for example. So what i did is declaring basically all bytes as integers, because the BIT library expects Integers.
I have here for example the C64 opcode "BRK" in B4A. Before i end up in huge debugging i thought it would be a good idea to ask here before if that works.
I wrote that for the iOS before in C/C++ and the C code is after the B4A code.
Here's the code for that function - it's pretty much self explaining:
' Der Assembler-Befehl BRK erzeugt einen softwareseitigen Interrupt.
' Um den BRK-Interrupt vom Hardware-Interrupt unterscheiden zu können, setzt der BRK-Befehl das Break-Flag im Statusregister.
Sub BRK
Dim hb As Int
Dim lb As Int
Dim adr As Int
vars.PC = vars.PC + 2
hb = Bit.ShiftRight(vars.PC,8)
lb = Bit.And(vars.PC, 0xFF)
memory.PushStack(hb)
memory.PushStack(lb)
memory.SetFlagB
memory.PushStack(vars.PS)
adr = memory.AbsAdd(memory.peek(0xFFFE), memory.peek(0xFFFF), vars.c64true)
memory.SetFlagI
vars.PC = adr
End Sub
and here is my c-code (iOS)
void BRK(void)
{
//store PC in Stack
PC +=2;
c64byte hb = PC >> 8;
c64byte lb = PC & 0xFF;
PushStack(hb);
PushStack(lb);
//store Processor Status in Stack
SetFlagB();
PushStack(PS);
//Set new Programm Counter
c64ushort adr = AbsAdd(peek(0xFFFE), peek(0xFFFF), c64true);
SetFlagI();
PC=adr;
}
Comments?