You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to do some "bare metal" programming with this emulator. This seems to be great since the source code is clean and being able to read the emulator seems to be a good idear.
// vexpress.js:651
// >> 2 because int is 4 bytes and the given addresses are individual bytes.
const int DR = 0x00 >> 2;
const int FR = 0x18 >> 2;
const int IBRD = 0x24 >> 2;
const int FBRD = 0x28 >> 2;
const int LCR_H = 0x2c >> 2;
const int CR = 0x30 >> 2;
const int IFLS = 0x34 >> 2;
const int IMSC = 0x38 >> 2;
const int MIS = 0x40 >> 2;
const int ICR = 0x44 >> 2;
unsigned int *uart;
void
putc(char c)
{
// wait for UART to become ready to transmit
// vexpress.js:707
while (!(uart[FR] & (1 << 7)));
uart[DR]= c;
while (!(uart[FR] & (1 << 7)));
}
void
puts(char *s) {
while(*s)
putc(*(s++));
}
int
main()
{
//char s[] = { 'H', 'a', 'l', 'l', 'o' , 0};
//char t[10];
char *t;
t = (char *) 0x10000;
// vexpress.js:1455
uart = (unsigned int *)0x10009000;
// This does work
putc('H');
putc('a');
putc('l');
putc('l');
putc('o');
putc(' ');
putc('W');
putc('e');
putc('l');
putc('t');
putc('\n');
putc('\r');
// This does not
puts("asdfasdf");
/*
neither does this.
t[0] = 'H';
t[1] = 'a';
t[2] = 'l';
t[3] = 'l';
t[4] = 'o';
t[5] = 0;
puts(t);
//putss(s);
int i=0;
int j,x=0;
for(i=97;i<123;i++){
putc((char)i);
for(j=0;j<5;j++);
x += j;
}
*/
//putc(s[1]);
//putc(s[2]);
//puts("Hallo Welt\n\r");
while(1);
}
This does not work as expected.. Puts is called, the address is in r0, it is copied to r2, the address from r2 is derfferenced (it is 0x60 = 'a') and putc is called. putc does work, the loop is still running. and 8074 there is a jump.
The register r2 is expected to contain the variable s, but it is empty. I feel this is a bug in the emulator since this is not hand written assembly, but the output of a c compiler. On the other hand i don't get why not simply a mov r15 #0x58 is used.
The text was updated successfully, but these errors were encountered:
/Edit the hole post
I tried to do some "bare metal" programming with this emulator. This seems to be great since the source code is clean and being able to read the emulator seems to be a good idear.
I compiled it, the result is
http://paste.ubuntu.com/5598293/
And this disassembled
This does not work as expected.. Puts is called, the address is in r0, it is copied to r2, the address from r2 is derfferenced (it is 0x60 = 'a') and putc is called. putc does work, the loop is still running. and 8074 there is a jump.
At this point (tick 240) stuff breaks:
The register r2 is expected to contain the variable s, but it is empty. I feel this is a bug in the emulator since this is not hand written assembly, but the output of a c compiler. On the other hand i don't get why not simply a
mov r15 #0x58
is used.The text was updated successfully, but these errors were encountered: