Go to advanced search

by NatKarmios
Mon Jun 17, 2019 9:52 am
Forum: Bare metal, Assembly language
Topic: Unexpected behaviour of arrays and switch statements
Replies: 10
Views: 792

Re: Unexpected behaviour of arrays and switch statements

I suspect we need to see your linker file and the function drawNum because it is obviously having issues with constant arrays. The linker file: https://gist.github.com/NatKarmios/9a15744909d6120b12ca0a4770797dae I highly doubt drawNum() is having an effect, but here it is just in case: void drawNum...
by NatKarmios
Sun Jun 16, 2019 7:13 pm
Forum: Bare metal, Assembly language
Topic: Unexpected behaviour of arrays and switch statements
Replies: 10
Views: 792

Re: Unexpected behaviour of arrays and switch statements

Most likely your linker file isn't saving the rodata section which is the one the constant data will go into, so basically your file doesn't actually contain the constant array and is printing junk. Without changing the linker file try putting the array in the text section ... something like int __...
by NatKarmios
Sun Jun 16, 2019 9:55 am
Forum: Bare metal, Assembly language
Topic: Unexpected behaviour of arrays and switch statements
Replies: 10
Views: 792

Re: Unexpected behaviour of arrays and switch statements

An interesting development; if I assign the array values at runtime like so: unsigned int cols[7]; cols[0] = 0xFFFF0000; cols[1] = 0xFFFF7F00; cols[2] = 0xFFFFFF00; cols[3] = 0xFF00FF00; cols[4] = 0xFF0000FF; cols[5] = 0xFF4B0082; cols[6] = 0xFF9400D3; drawNum(&display, 0x1234ABCD); drawNum(&display...
by NatKarmios
Sun Jun 16, 2019 9:48 am
Forum: Bare metal, Assembly language
Topic: Unexpected behaviour of arrays and switch statements
Replies: 10
Views: 792

Re: Unexpected behaviour of arrays and switch statements

lpoulain wrote:
Sun Jun 16, 2019 4:37 am
One thing I notice is that you are using an int type (so signed integers), but have numbers in your array which are negative numbers. You might want to use unsigned integers instead.
Good spot, though unfortunately this has no effect. I expect this is because drawNum() uses bitwise logic.
by NatKarmios
Sun Jun 16, 2019 2:02 am
Forum: Bare metal, Assembly language
Topic: Unexpected behaviour of arrays and switch statements
Replies: 10
Views: 792

Unexpected behaviour of arrays and switch statements

I currently have a simple program that sets up a framebuffer that can be written to. I am encountering behaviour where values stored i arrays, once retrieved, come back as seemingly random values, with no relation to the originals. I have also noticed some similarly strange and.unexpected behaviour ...

Go to advanced search