I'm a student at an engineering college, and I have encountered a problem while working on a project. In this project, I am designing a microcontroller. I opted to use the Z80 CPU due to its simplicity and popularity. However, the issue arises with the concept of controlling the pins through RAM addresses. While controlling RAM addresses through assembly code worked, transitioning to using C to manage the logic of the microcontroller proved challenging.
For instance, in the assembly code, I successfully managed to change the value of RAM at address 0x3FFF to 0x02.
.org $0000 ; Set origin to 0000h
START:
LD HL, 0X3FFF ; Load HL with the address 0x3FFF
LD A, 0X02 ; Load register A with the value 0x02
LD (HL), A ; Store the value in register A at the address pointed to by HL
I utilized a retro assembler to generate the binary file, which I then employed in the virtual EEPROM within the simulation program, Proteus 8.
Since my setup is functioning properly, I opted to experiment with using a C code instead of assembly. I found a suitable C compiler online (z88dk) and proceeded to utilize the following code to control the RAM address
int main(){
int *p = (int *)0x3FFF;
*p |= 0x02;
return 0;
}
https://github.com/z88dk/z88dk
And I used this command to generate the bin file
zcc +cpm -subtype=z80pack -compiler=sdcc mem.c -o mem.bin
and
zcc +cpm mem.c -create-app -subtype=z80pack -compiler=sdcc
I was able to use the bin file with the EEPROM simulation, but the code didn't work,what should I do to be able to control the ram addresses values with C?
Did I used it correctly or should I change the compiler?
|=does a bitwise OR, not a write of an entire byte value like in your assembly example.