Thursday, December 31, 2009

Renaming the Blog

Well, it's been almost a month and I've done what I set out to do. I've played with all the moving parts of ARM Assembly - except for I/O, which is kind of implementation specific. I could go on doing exercises in assembly - a program to sort values, a program to find primes in a range - of the kind I did for other programming languages, but you don't do those things in assembly.

The next thing I want to learn about is compilers. I'm getting a book from the library about the GNU compiler (there's also lots of stuff at GNU.org).

Before I go away, though, and before my evaluation license goes bad, I think I'll go back over my heap manager and clean it up. This is what I have in mind:
  • Implement my stack so I can use clean, safe function calls.
  • Make sure the code is commented adequately and cleanly.
  • Change the structure so that the manager saves an entry in the first free spot (I had a klugey bit of code that looked for the last spot, which accomplished nothing.)
  • Write some overview documentation.
  • Expand it to deal with larger values, such as multi-word values.
I think the last one might be too ambitious for a weekend project, so it'll be last.

After that, I'll see what interesting stuff lives in compiler world.

Wednesday, December 30, 2009

More with Interrupts

Today I did more with software interrupts.

One of the things that SWI is used for is to run more than one program or more than one thread on a system. Today, I re-purposed my stack to be a program swap stack. In this example, when execution reaches the interrupt, it shifts to an area of code that saves the registers and does something else for a while, then returns to the next place in execution.


; Software interrupt example.
;
;
;


AREA HEAP, NOINIT, READWRITE, ALIGN=3

Heap_Size EQU 0x500 ; Size of heap. 0x500, from my earlier project
Stack_Size EQU 0x400 ; Size of stack. 0x400
Manager_Offset EQU 0x100 ; Size of ordinary heap. Manager lives on top of it.

Heap_Memory SPACE Heap_Size ; Allocate memroy for the heap.
Stack_Memory SPACE Stack_Size ; Allocate memory for the stack.


Heap_Manager EQU (Heap_Memory + Manager_Offset)

AREA HelloWorld, CODE, READONLY ;
EXPORT mystart ; Export this code to the project

; Exception handlers.


Vectors B Reset_Handler
Undef_Handler B Undef_Handler
B SWI_Handler


Reset_Handler B mystart

SWI_Handler
STMFD sp!, {R4, R7, R9-R11, R14} ; Push test values and Link Register (R14) onto stack

MOV R4, #0xb ; Overwrite test values in registers
MOV R7, #0xb
MOV R9, #0xb
MOV R10, #0xb
MOV R11, #0xb

LDMFD sp!, {R4, R7, R9-R11, R14} ; Pop test values off stack.

BX R14

; Test code to see if the SWI works as expected.
mystart
LDR sp, =Stack_Memory ; Set stack memory. This points to the base of the stack.
ADD sp, sp, #Stack_Size ; Because this is a decrementing stack, we need to point to the top of the stack.

MOV R4, #0xA ; Load test values into registers
MOV R7, #0xB
MOV R9, #0xC
MOV R10, #0xD
MOV R11, #0xE
SWI #02

stop
BAL stop ; gives me a loop to be caught in

END ; end.


Of course, to do anything interesting with this, there'd have to be a thread manager at SWI_Handler and it could not be implemented as a stack. If it was a stack, the program components would all have to be nested.

Monday, December 28, 2009

Interruptions

I started to puzzle out software interrupts.

I placed an SWI command in my latest sample code. When execution reached the SWI line, it jumped to line 8 - just as I expected from the explanations I've read.

I gather that in a real application, the first few commands are simple branches to different exception handlers. I saw this in some of the sample code in the Keil tool.

So, to do it right, I need a small intro section that gets compiled first and jumps to the right locations.

I may go back to some of the startup programs and look again at how that works.

Sunday, December 27, 2009

Throw it on the Stack

Today, I implemented a stack. It's primitive, but it has all the moving parts of a call stack.

Some code:

; A call stack
;
;
;


AREA HEAP, NOINIT, READWRITE, ALIGN=3

Heap_Size EQU 0x500 ; Size of heap. 0x500, from my earlier project
Stack_Size EQU 0x400 ; Size of stack. 0x400
Manager_Offset EQU 0x100 ; Size of ordinary heap. Manager lives on top of it.

Heap_Memory SPACE Heap_Size ; Allocate memroy for the heap.
Stack_Memory SPACE Stack_Size ; Allocate memory for the stack.


Heap_Manager EQU (Heap_Memory + Manager_Offset)

AREA HelloWorld, CODE, READONLY ;
EXPORT mystart ; Export this code to the project


; Test code to see if the stack works as expected.

;
mystart
LDR sp, =Stack_Memory ; Set stack memory. This points to the base of the stack.
ADD sp, sp, #Stack_Size ; Because this is a decrementing stack, we need to point to the top of the stack.

MOV R4, #0xA ; Load test values into registers
MOV R7, #0xA
MOV R9, #0xA
MOV R10, #0xA
MOV R11, #0xA

STMFD sp!, {R4, R7, R9-R11, R14} ; Push test values and Link Register (R14) onto stack

MOV R4, #0xb ; Overwrite test values in registers
MOV R7, #0xb
MOV R9, #0xb
MOV R10, #0xb
MOV R11, #0xb

LDMFD sp!, {R4, R7, R9-R11, R14} ; Pop test values off stack.

stop
BAL stop ; gives me a loop to be caught in

END ; end.


When I ran this in debug mode, it loaded the test values into registers, then saved the registers into memory in the stack. After making whatever changes to the registers (in what would be the body of the subroutine), the code pops the values from the stack.

As expected, the final values in the test registers were all 0xA.

The only thing that didn't go as expected was that when the STMFD command was executed, all the test registers were set to 0x0. I don't know if this is part of the language specification, the hardware, or something the simulator does.

Saturday, December 26, 2009

Tooling Around

Spent some time this morning playing with the Keil software.

As I've said before, ARM programming is dependent on the intended platform. So far, I've written my test program for one chip - one of the TI chips. I wanted to see if I could get it or some code running for another chip.

I selected one of the ARM 7 chips again. I ran into the same problem as I did the first time around. The system was running code I didn't write.

I dug around in the files generated by the tool - a good exercise, at any rate. I still didn't find what I expected.

I suppose the system could be emulating code built into the chip that I can't change and can't see. It looked like it was using a stack (in debug mode, there was an STMFD instruction, so there must have been a stack already set up.)

Anyway, maybe tomorrow, I'll try the same thing with a different chip.

Friday, December 25, 2009

It's Alive

Well, my starter project is complete - not perfect, but it does what I specked it out to do. Yay, me.

Yes, here is the code:

; A little Heap Manager that will manage a 256 byte heap that can
; store 1, 2, 3, and 4 byte values.
; Name: HelloWorld.s
; modifying to play with different aspects.


AREA HEAP, NOINIT, READWRITE, ALIGN=3

Heap_Size EQU 0x00000500 ; line changed

Heap_Mem SPACE Heap_Size

Temp EQU 0x100
Heap_Manager EQU (Heap_Mem + Temp)

AREA HelloWorld, CODE, READONLY ;
EXPORT mystart ; Export this code to the project
; IMPORT Heap_Mem ; This is the base of the heap.
; IMPORT Heap_Manager ; base for the Heap Manager


; This version of the program manually loads five values into memory then unloads them.

; This section sets R3 to a test value and gotos write_value
mystart ldr R3, =0xDDCCBBAA ; Set R3 to value
MOV R14, R15
B write_value

ldr R3, =0x11 ; Set R3 to value
MOV R14, R15
B write_value

ldr R3, =0x345678 ; Set R3 to value
MOV R14, R15
B write_value

ldr R3, =0x1234 ; Set R3 to value
MOV R14, R15
B write_value

ldr R3, =0xabcdef12 ; Set R3 to value
MOV R14, R15
B write_value

LDR R2, =Heap_Mem ; testing.
LDR R3, [R2]
NOP

LDR R3, =0x1
MOV R14, R15
B read_value

LDR R3, =0x0
MOV R14, R15
B delete_value

LDR R3, =0x1
MOV R14, R15
B read_value

MOV R14, R15
B compact_heap


stop
BAL stop ; gives me a loop to be caught in


; This routine looks in R3 for a value to save. It saves it in the first free heap space
; It saves an entry in the heap manager

write_value LDR R4, =Heap_Manager ; Load beginning of Heap Manager
LDR R6, =0x400 ; Length of the Heap Manager 0x400 or 1024 bytes
LDR R5, =0xFFFFFFFC ; 2's comp rep of -4
; EDGE Condition: if the 255 spot is full, this stuff fails.
next ADD R6, R6, R5 ; Add -4 to R4 - moves offset back to the previous word
LDR R2, [R4, R6] ; get value at Heap Manager
CMP R6, #0 ; Check whehter we've hit the beginning of the Heap Manager
BEQ done ; If so, jump out of the loop
CMP R2, #0 ; Check whether the value is 0
BEQ next ; if 0, go back to the start of the loop.

done

; R2 is the value of the saved heap memory offset (including size)
MOV R5, R2, LSR#24 ; set R5 to the size of the element in the heap
AND R2, R2, #0xFF ; mask off the high bits (that record size)
ADD R2, R2, R5 ; add offset to size
; R2 is now the offset for the next write to the heap.

; TODO write code here to fail routine if R2 > 255 - means that out of space in heap.


ADD R4, R4, R6 ; add offset to Heap Manager location.
; R4 is the address that previous heap pointer resides at

CMP R2, #0 ; if R2 has a value of 0, this is the first write action and should write to 0 offset
BEQ first_write
ADD R4, R4, #4

first_write
; Testing size of R3.
MOV R5, R3, LSR#8 ; Load R3 into R5, shifted R 8 bits Value will be consumed.
CMP R5, #0 ; Compare with 0. If R3 is less than 8 bits, now R5 will be 0
BNE case_2 ; If larger than 0, jump ahead
LDR R5, =0x1000000 ; If 0, only 1 byte. Set size to 001.
B done_cases ; Jump to end.
case_2 MOV R5, R5, LSR#8 ; Shift R 8 bits.
CMP R5, #0 ; See if there are still any bits.
BNE case_3 ; If more bits, jump ahead.
LDR R5, =0x2000000 ; If 0, only 1 byte. Set size to 010.
B done_cases ; Jump to end.
case_3 MOV R5, R5, LSR#8 ; Shift R 8 bits.
CMP R5, #0 ; See if there are still any bits.
BNE case_4 ; If more bits, jump ahead.
LDR R5, =0x3000000 ; If 0, only 1 byte. Set size to 011.
B done_cases ; Jump to end.
case_4 LDR R5, =0x4000000 ; Default case. Must be 4 bytes. Set size to 100.


done_cases
ADD R5, R5, R2 ; Add size to offset.
STR R5, [R4] ; Store (the offset in Heap Memory) at R4.

; Entry is now stored in Heap_Manager

LDR R5, =Heap_Mem ; Add offset to Heap_Mem base.
ADD R2, R2, R5 ; Add offset to Heap_Mem base.

; R2 is now the address in the heap where the value in R3 will be saved.

save_byte AND R5, R3, #0xFF ; Set R5 to R3 masked & 00000000000000000000000011111111 0xFF
STRB R5, [R2] ; Save R5 to location R2.
ADD R2, R2, #1 ; Increment R2.
MOVS R3, R3, LSR#8 ; Consume lowest 8 bits of R3.

BNE save_byte ; R3 is 0, jump to start_save
; to do: modify to return offset of Heap manager entry in R3 (subtract Heap_Manager from R4)
BX R14

read_value
; Takes heap manager offset in R3
; Returns 0xFFFFFFFF if you try to read from a non-entry.
LDR R4, =Heap_Manager ; Set R4 to Heap_Manager base.
MOV R3, R3, LSL#2 ; Multiply R3 by 4: Heap manager uses words, not bytes
ADD R4, R4, R3 ; Get address of heap_manager entry.
LDR R2, [R4] ; Load entry into R2.
CMP R2, #0 ; Check for 0 value, meaning read is not valid
BEQ error_out
MOV R4, R2 ; Entry also into R4
AND R2, R2, #0xFF ; mask off just the offset part of entry.
LDR R5, =Heap_Mem ; Set R5 to Heap_Mem base
ADD R2, R2, R5 ; R2 is now first address of value in heap memory.
MOV R4, R4, LSR#24 ; Shift bits over so that only the size bits remain.
ADD R4, R2, R4 ; R4 is now the first address after the value to be read.

MOV R3, #0 ; Set R3 to 0
LDR R6, =0xFFFFFFFF
MOV R5, #0

read_loop MOV R3, R3, LSL#8 ; Shift R3 8 bits left.

ADD R4, R4, R6 ; Decrements R4 to read next byte

LDRB R5, [R4] ; Read byte
ADD R3, R3, R5 ; Add byte to R3

CMP R2, R4 ; compare R2 and R4.
BNE read_loop ; If not same, repeat loop.

BX R14 ; Return
error_out LDR R3, =0xFFFFFFFF
BX R14

delete_value
; Takes offset of value to be deleted in R3.
; Returns 1 in R3 if there is a problem.
; Returns 0 in R3 for success.

LDR R4, =Heap_Manager ; Set R4 to Heap_Manager base.
MOV R3, R3, LSL#2 ; Multiply R3 by 4: Heap manager uses words, not bytes
ADD R4, R4, R3 ; Get address of heap_manager entry.
MOV R3, #0 ; Set heap manager entry to 0
STR R3, [R4]
BX R14 ; Return

compress_man

LDR R2, =Heap_Manager ; Will use R2 as address of heap Man
MOV R5, R2
LDR R3, =0x3fc
ADD R5, R5, R3 ; Set to top of heap manager.
; First pass ; Not sure about edge case here.
LDR R3, [R2] ; Load the value at R2 into R3
CMP R3, #0 ; Compare R3 to 0.
BNE begin_c_loop ; First number is greater than 0. Jump ahead.
LDR R4, [R2, #4] ; Load the value at R2+4 into R4
CMP R4, #0 ; Compare R4 to 0.
BEQ begin_c_loop ; If R4 is 0, jump ahead.
STR R4, [R2] ; Store the value from R2+4 at R2
MOV R3, #0
STR R3, [R2, #4] ; Store 0 in R2+4

begin_c_loop ; loop for checking.
ADD R2, R2, #4 ; Increment R2
CMP R2, R5 ; compare R2 and R5
BEQ check_manager

LDR R3, [R2] ; Load the value at R2 into R3
CMP R3, #0 ; Compare R3 to 0.
BNE begin_c_loop ; First number is greater than 0. Go through loop again.
LDR R4, [R2, #4] ; Load the value at R2+4 into R4
CMP R4, #0 ; Compare R4 to 0.
BEQ begin_c_loop ; If R4 is 0, jump ahead.
STR R4, [R2] ; Store the value from R2+4 at R2
MOV R3, #0
STR R3, [R2, #4] ; Store 0 in R2+4
B begin_c_loop


check_manager
LDR R2, =Heap_Manager ; First compare can;t be wrong.
cm_loop
ADD R2, R2, #4
CMP R2, R5 ; compare R2 and R5
BEQ check_done
LDR R3, [R2] ; Load the value at R2 into R3
CMP R3, #0 ; Compare R3 to 0.
BNE cm_loop ; First number is greater than 0. Go through loop again.
LDR R4, [R2, #4] ; Load the value at R2+4 into R4
CMP R4, #0 ; Compare R4 to 0.
BEQ cm_loop ; If R4 is 0, jump ahead.

B compress_man



check_done
BX R14 ; Return




compact_heap
; Read each saved byte in the heap and write them from the beginning,
; writing over deleted values and updating the Heap Manager as we go.

LDR R2, =Heap_Mem ; Heap memory base. Start writing at this address
LDR R7, =Heap_Mem

LDR R3, =Heap_Manager ; Heap manager base.
MOV R4, #0x0 ; Set offset to 0.
ADD R5, R3, #0x400 ; Top of Heap Manager

heap_compact_loop
LDR R6, [R3, R4] ; Load entry into R6
CMP R6, #0 ; Check whther entry has content
BEQ empty_entry
MOV R8, R6, LSR#24
AND R6, R6, #0xFF ; Mask off lower 8 bits


; Save the new offset (R2 - R7) and old size (R8) to the space specified in (R3 + R4)
SUB R9, R2, R7
ADD R9, R9, R8, LSL#24
STR R9, [R3, R4]

; Read and write.

ADD R6, R6, R7 ; get location of first byte to read.
ADD R8, R8, R6 ; get location of next byte beyond the value.

compact_loop LDRB R9, [R6] ; read first byte.
STRB R9, [R2] ; store first byte.

ADD R2, R2, #1 ; increment R2.
CMP R2, R3 ; check against end of heap
BEQ com_done
ADD R6, R6, #1 ; increment R6

cmp R8, R6 ; check whether we are at the end of the write
BNE compact_loop ; If not, go back to the loop for more writing

empty_entry
ADD R4, R4, #4 ; Increment R4 (Heap Manager loop)
ADD R6, R3, R4 ; Set R6 to next Heap Manager location
cmp R5, R6 ; Check whether the heap manager current location is at the top of the heap
BNE heap_compact_loop

com_done

BX R14 ; Return

END ; end.


Next up:

I'm going to implement a little stack so I can do subroutine calls recursively.

Also, I need to go back over the ARM instruction set. I've used only a handful of stuff here and I should get to know the other commands. This page has been helpful so far: Instruction Set.

Thursday, December 24, 2009

Read Errors on Christmas Eve

Short post today.

I did make a good run at writing the compact routine. It takes up a lot of registers. It is a couple of loops - one controlling the read-write in the heap, one controlling the entry-by-entry in the heap manager.

I had various little troubles along the way. There must be better ways to write this code.

When I stopped for the day, it was writing the same first entry to all the spaces in the heap.

Better than a read error, I promise.

Wednesday, December 23, 2009

Spaghetti is Tasty!

So, I wrote the compress function I mentioned previously.

The implementation works like this: It checks for cases where two entries have a pattern of [zero][not zero]. This means that there is an empty value before a non-empty value.

My whole implementation is klugey. First, I compare the first two values. Then I start up a loop that compares adjacent values going down the line.

After the first pass, control goes to a section that checks whether there are any viloations of the [zero][not zero] rule.

If so, control returns to the beginning of the routine to start over.

This does work. (After I fixed the memory violation that came from a typo.) Here's the code:
compress_man

LDR R2, =Heap_Manager ; Will use R2 as address of heap Man
MOV R5, R2
LDR R3, =0x3fc
ADD R5, R5, R3 ; Set to top of heap manager.
; First pass ; Not sure about edge case here.
LDR R3, [R2] ; Load the value at R2 into R3
CMP R3, #0 ; Compare R3 to 0.
BNE begin_c_loop ; First number is greater than 0. Jump ahead.
LDR R4, [R2, #4] ; Load the value at R2+4 into R4
CMP R4, #0 ; Compare R4 to 0.
BEQ begin_c_loop ; If R4 is 0, jump ahead.
STR R4, [R2] ; Store the value from R2+4 at R2
MOV R3, #0
STR R3, [R2, #4] ; Store 0 in R2+4

begin_c_loop ; loop for checking.
ADD R2, R2, #4 ; Increment R2
CMP R2, R5 ; compare R2 and R5
BEQ check_manager
; NOT EXITING OUT OF LOOP - START HERE.
LDR R3, [R2] ; Load the value at R2 into R3
CMP R3, #0 ; Compare R3 to 0.
BNE begin_c_loop ; First number is greater than 0. Go through loop again.
LDR R4, [R2, #4] ; Load the value at R2+4 into R4
CMP R4, #0 ; Compare R4 to 0.
BEQ begin_c_loop ; If R4 is 0, jump ahead.
STR R4, [R2] ; Store the value from R2+4 at R2
MOV R3, #0
STR R3, [R2, #4] ; Store 0 in R2+4
B begin_c_loop


check_manager
LDR R2, =Heap_Manager ; First compare can;t be wrong.
cm_loop
ADD R2, R2, #4
CMP R2, R5 ; compare R2 and R5
BEQ check_done
LDR R3, [R2] ; Load the value at R2 into R3
CMP R3, #0 ; Compare R3 to 0.
BNE cm_loop ; First number is greater than 0. Go through loop again.
LDR R4, [R2, #4] ; Load the value at R2+4 into R4
CMP R4, #0 ; Compare R4 to 0.
BEQ cm_loop ; If R4 is 0, jump ahead.

B compress_man



check_done
BX R14 ; Return
It's just not very pretty. Or efficient.

Delete Entry

Delete entry was straight forward. I had most of the code from read_value already.

delete_value
; Takes offset of value to be deleted in R3.
; Returns 1 in R3 if there is a problem.
; Returns 0 in R3 for success.

LDR R4, =Heap_Manager ; Set R4 to Heap_Manager base.
MOV R3, R3, LSL#2 ; Multiply R3 by 4: Heap manager uses words, not bytes
ADD R4, R4, R3 ; Get address of heap_manager entry.
MOV R3, #0 ; Set heap manager entry to 0
STR R3, [R4]
BX R14 ; Return

This sets the specified entry to 0. I documented a return value of 1 as an error, but there are no error conditions.

This addition does bring up a problem: What happens if you now try to read from the spot you just deleted? Well, the way the read routine worked, it would have returned the first byte below the heap memory.

Yes, before the heap memory. It's a side effect of the decrement approach.

I added an exit with error code to the read function.

CMP R2, #0 ; Check for 0 value, meaning read is not valid
BEQ error_out
...
error_out LDR R3, =0xFFFFFFFF
BX R14


Testing seems to work, but I'm sticking with pretty straight-forward test cases.

Tuesday, December 22, 2009

Do You Read

Last night, I started working on a read sub-routine. It seemed kind of woolly to me, so I decided to start over.

I decided to assigning R2 the value of the base for the value to be read. I would assign R4 the value of the next value in the heap (the value to be read plus the offset) and then increment R2 until it equaled R4, stopping the read before reading R4.

This all worked, with one small problem: I had written values to memory from the least significant bit to the most significant bit. That way, I could write 0x00112233 as three bytes without having to do anything special to deal with 0x00112200. But reading from the lower end to the higher end, I would get something like 0x332211.

I thought about changing the way that the write routine worked to save the higher bits first, but didn't want to deal with the added complexity. Instead, I decided to decrement R4 down to R2.

This approach made the routine woolly, again, but it does seem to give the right results.

Here's some code:

read_value
; Takes heap manager offset in R3
LDR R4, =Heap_Manager ; Set R4 to Heap_Manager base.
MOV R3, R3, LSL#2 ; Multiply R3 by 4: Heap manager uses words, not bytes
ADD R4, R4, R3 ; Get address of heap_manager entry.
LDR R2, [R4] ; Load entry into R2.
MOV R4, R2 ; Entry also into R4
AND R2, R2, #0xFF ; mask off just the offset part of entry.
LDR R5, =Heap_Mem ; Set R5 to Heap_Mem base
ADD R2, R2, R5 ; R2 is now first address of value in heap memory.
MOV R4, R4, LSR#24 ; Shift bits over so that only the size bits remain.
ADD R4, R2, R4 ; R4 is now the first address after the value to be read.

MOV R3, #0 ; Set R3 to 0
LDR R6, =0xFFFFFFFF
MOV R5, #0

read_loop MOV R3, R3, LSL#8 ; Shift R3 8 bits left.

ADD R4, R4, R6 ; Decrements R4 to read next byte

LDRB R5, [R4] ; Read byte
ADD R3, R3, R5 ; Add byte to R3

CMP R2, R4 ; compare R2 and R4.
BNE read_loop ; If not same, repeat loop.

BX R14 ; Return


Next time: I have three more routines in mind for this exercise:
  • Delete: Set's the entry in Heap Manager to 0. Memory in the heap is untouched, but won't be accessed.
  • Compress: Clears out empty spaces in the Heap Manager.
  • Compact: Rewrites the contents of the heap to be contiguous.
I realized that Compress won't work in a useful way with my current design, since it will change the offset pointing to a value on the heap. (You'll see what I mean.) I'm going to do implement it anyway, since this is an exercise.

Monday, December 21, 2009

Getting Ready to Read

I wrote some code tonight to be the basis of the read_value routine. It's not done.

I have to do a bunch of things, of course, to read the data as written.
  • Get the offset and size from the Heap_Manager entry.
  • Separate the offset and size and store them.
  • Add the offset to the Heap_Mem base.
  • Read each byte, counting how many against the size.
I'll finish tomorrow.

Sunday, December 20, 2009

Following the Flesh

I went back over the code and found a couple of simple typos that messed things up. For instance, ADD R2, R2 instead of ADD R2, R2, R5.

After I wrung out the errors, it worked for two consecutive saves.

Then I tested it for 5 saves. Seems to be working.

So, what else needs to be done?
  • read_value: Takes an offset in R3 and reads the value from the heap.
  • delete_value: Takes an offset in R3 and deletes the entry from the manager. Heap is untouched.
  • compress: Removes any empty entries from the manager.
  • compact_heap: Reads each entry from the manager, reads corresponding value in heap, writes value in heap, starting at 0, and writes 0 to the rest of the heap.
After having gone through all this, today, though, I thing the rest will be straight forward, if not exactly cake-walky.

Wanna see the code? Sure you do.

; A little Heap Manager that will manage a 256 byte heap that can
; store 1, 2, 3, and 4 byte values.
; Name: HelloWorld.s
; modifying to play with different aspects.

AREA HelloWorld, CODE, READONLY ;
EXPORT mystart ; Export this code to the project
IMPORT Heap_Mem ; This is the base of the heap.
IMPORT Heap_Manager ; base for the Heap Manager

; This version of the program manually loads five values into memory then unloads them.
mystart
; This section sets R3 to a test value and gotos write_value
ldr R3, =0xDDCCBBAA ; Set R3 to value
MOV R14, R15
B write_value

ldr R3, =0x11 ; Set R3 to value
MOV R14, R15
B write_value

ldr R3, =0x345678 ; Set R3 to value
MOV R14, R15
B write_value

ldr R3, =0x1234 ; Set R3 to value
MOV R14, R15
B write_value

ldr R3, =0xabcdef12 ; Set R3 to value
MOV R14, R15
B write_value

LDR R2, =Heap_Mem ; testing.
LDR R3, [R2]
NOP

stop
BAL stop ; gives me a loop to be caught in


; This routine looks in R3 for a value to save. It saves it in the first free heap space
; It saves an entry in the heap manager

write_value LDR R4, =Heap_Manager ; Load beginning of Heap Manager
LDR R6, =0x400 ; Length of the Heap Manager 0x400 or 1024 bytes
LDR R5, =0xFFFFFFFC ; 2's comp rep of -4
; EDGE Condition: if the 255 spot is full, this stuff fails.
next ADD R6, R6, R5 ; Add -4 to R4 - moves offset back to the previous word
LDR R2, [R4, R6] ; get value at Heap Manager
CMP R6, #0 ; Check whehter we've hit the beginning of the Heap Manager
BEQ done ; If so, jump out of the loop
CMP R2, #0 ; Check whether the value is 0
BEQ next ; if 0, go back to the start of the loop.

done

; R2 is the value of the saved heap memory offset (including size)
MOV R5, R2, LSR#24 ; set R5 to the size of the element in the heap
AND R2, R2, #0xFF ; mask off the high bits (that record size)
ADD R2, R2, R5 ; add offset to size
; R2 is now the offset for the next write to the heap.

; TODO write code here to fail routine if R2 > 255 - means that out of space in heap.


ADD R4, R4, R6 ; add offset to Heap Manager location.
; R4 is the address that previous heap pointer resides at

CMP R2, #0 ; if R2 has a value of 0, this is the first write action and should write to 0 offset
BEQ first_write
ADD R4, R4, #4

first_write
; Testing size of R3.
MOV R5, R3, LSR#8 ; Load R3 into R5, shifted R 8 bits Value will be consumed.
CMP R5, #0 ; Compare with 0. If R3 is less than 8 bits, now R5 will be 0
BNE case_2 ; If larger than 0, jump ahead
LDR R5, =0x1000000 ; If 0, only 1 byte. Set size to 001.
B done_cases ; Jump to end.
case_2 MOV R5, R5, LSR#8 ; Shift R 8 bits.
CMP R5, #0 ; See if there are still any bits.
BNE case_3 ; If more bits, jump ahead.
LDR R5, =0x2000000 ; If 0, only 1 byte. Set size to 010.
B done_cases ; Jump to end.
case_3 MOV R5, R5, LSR#8 ; Shift R 8 bits.
CMP R5, #0 ; See if there are still any bits.
BNE case_4 ; If more bits, jump ahead.
LDR R5, =0x3000000 ; If 0, only 1 byte. Set size to 011.
B done_cases ; Jump to end.
case_4 LDR R5, =0x4000000 ; Default case. Must be 4 bytes. Set size to 100.


done_cases
ADD R5, R5, R2 ; Add size to offset.
STR R5, [R4] ; Store (the offset in Heap Memory) at R4.

; Entry is now stored in Heap_Manager

LDR R5, =Heap_Mem ; Add offset to Heap_Mem base.
ADD R2, R2, R5 ; Add offset to Heap_Mem base.

; R2 is now the address in the heap where the value in R3 will be saved.

save_byte AND R5, R3, #0xFF ; Set R5 to R3 masked & 00000000000000000000000011111111 0xFF
STRB R5, [R2] ; Save R5 to location R2.
ADD R2, R2, #1 ; Increment R2.
MOVS R3, R3, LSR#8 ; Consume lowest 8 bits of R3.

BNE save_byte ; R3 is 0, jump to start_save
; to do: modify to return offset of Heap manager entry in R3 (subtract Heap_Manager from R4)
BX R14

END ; end.

(I know it's a little hard to read this in the HTML formatting.)

After I was done, it occurred to me that I should return the offset of the in Heap_Manager. It won't be hard to implement, but it will have to wait.

Fleshing Out

OK, I started fleshing out the heap write function.

These are the things it has to do:
  • Find the last used entry in the Heap Manager table or the 0th if this is the first write.
  • Read the value in that entry, which consists of an offset and a size.
Offset: offset from beginning of heap. Last 8 bits of entry.
Size: size of value stored (1-4). Bits number 26-24.
  • Add the offset to the size to get the location for the next write. (This is 0-base stuff, so I think the math works.)
  • Save that value to a new entry in Heap Manager.
  • Save the size of value stored on the heap to the new entry just created.
  • Save the actual value in the heap, starting at the value saved in Heap Manager.
So, it's not working yet. It saves the first value at the 0 location in the heap OK, but it the second time around, it saves over it.

It either isn't finding the first entry or it isn't reacting right when it does.

Or the first entry isn't being made in the right place in memory.

No code today - it's starting to look a little spaghetti-ish, so I'll work through it again, see what I'm missing.

Saturday, December 19, 2009

Consuming R3

Last time, I left with two outstanding problems. Did some reading and figured them out, plus one I didn't know about.
  • My STR command was storing words because it is supposed to store words. I needed to use the Byte version of the write command, STRB.
  • My branching using BMI wasn't working. The N flag is not defined for comparisons on unsigned numbers.
  • Also, CMP does not require an S to set flags - it is implied.
So, I got to work fixing those things.

First I ran through it with four blocks of code and branch commands taking me to the end. After each save of a byte, I shifted bits to the right 8 bits, consuming the value in R3 as it was being saved. This may have design fall-out later, since I need to store the size of the value in bytes when I save it.

The blocks were so similar, I just had to make it into a loop, even with my comment last time about not complicating things. Here's the code: (I used the NOPs to host breakpoints I used in stepping through the program.)

; Get the base from the Heap Manageer
LDR R2, =Heap_Mem ; temp just the Heap_Mem

ldr R3, =0xDDCCBBAA ; Set R3 to value

AND R4, R3, #0xFF ; Set R4 to R3 masked & 00000000000000000000000011111111 0xFF
STRB R4, [R2] ; Save R4 to location R2

ADD R2, R2, #1 ; increment R2
CMP R3, R4 ; compare R3 and R4
BEQ end_of_save ; if equal, jump to end_of_save

NOP

AND R4, R3, #0xFF ; Set R4 to R3 masked & 00000000000000000000000011111111 0xFF
STRB R4, [R2] ; Save R4 to location R2
ADD R2, R2, #1 ; increment R2
MOVS R3, R3, LSR #8 ; Consume lowest 8 bits of R3
CMP R3, R4 ; compare R3 and R4
BNE end_of_save ; if equal, jump to end_of_save

NOP

MOV R3, R3, LSR #8 ; Consume lowest 8 bits of R3
AND R4, R3, #0xFF ; Set R4 to R3 masked & 00000000000000000000000011111111 0xFF
STRB R4, [R2] ; Save R4 to location R2
ADD R2, R2, #1 ; increment R2
CMP R3, R4 ; compare R3 and R4
BEQ end_of_save ; if equal, jump to end_of_save


NOP

MOV R3, R3, LSR #8 ; Consume lowest 8 bits of R3
AND R4, R3, #0xFF ; Set R4 to R3 masked & 00000000000000000000000011111111 0xFF
STRB R4, [R2] ; Save R4 to location R2
ADD R2, R2, #1 ; increment R2
CMP R3, R4 ; compare R3 and R4
BEQ end_of_save ; if equal, jump to end_of_save

NOP

end_of_save


The only difference between the first time through the loop and the other three was that the first byte-write and the remaining ones was that I needed to shift R3 in those. I decided to implement it as a loop, regardless of what I'd said about keeping it simple.

This got a little easier when I realized I could use MOV R3, R3, LSR #8 to set the zero flag. Otherwise, I had to both shift R3 and compare R3 to R4. (Not sure if this is a clever feature of ARM Assembly or a giant hack that will fall apart.)

Here's some more code:

start_save AND R4, R3, #0xFF ; Set R4 to R3 masked & 00000000000000000000000011111111 0xFF
STRB R4, [R2] ; Save R4 to location R2
ADD R2, R2, #1 ; increment R2
MOVS R3, R3, LSR #8 ; Consume lowest 8 bits of R3

BNE start_save ; R3 is 0, jump to start_save

I tested it with values AA, BBAA, CCBBAA, DDCCBBAA, and 0. They all seemed to work fine.

So, it's time to make a run at making this a subroutine. I'm using the simple subroutine method (don't remember what to call it - the kind without a stack.)

The Keil tool warned me - while building the files - that BX was the preferred way to do it. Thanks, helpful Keil tool.

Here's the result:

; A little Heap Manager that will manage a 256 byte heap that can
; store 1, 2, 3, and 4 byte values.

; Name: HelloWorld.s
; modifying to play with different aspects.

AREA HelloWorld, CODE, READONLY ;
EXPORT mystart ; Export this code to the project
IMPORT Heap_Mem ; This is the base of the heap.
IMPORT Heap_Manager ; base for the Heap Manager

; This version of the program manually loads five values into memory then unloads them.
mystart

; Get the base from the Heap Manager
LDR R2, =Heap_Mem ; temp just the Heap_Mem
ldr R3, =0x00 ; Set R3 to value
MOV R14, R15
B start_save


LDR R2, =Heap_Mem ; testing.
LDR R3, [R2]
NOP

stop
BAL stop ; gives me a loop to be caught in


start_save AND R4, R3, #0xFF ; Set R4 to R3 masked & 00000000000000000000000011111111 0xFF
STRB R4, [R2] ; Save R4 to location R2
ADD R2, R2, #1 ; increment R2
MOVS R3, R3, LSR #8 ; Consume lowest 8 bits of R3

BNE start_save ; R3 is 0, jump to start_save

BX R14

END ; end.


This version also works with the values that I tested.

Thursday, December 17, 2009

Diversions

When I realized my alignment problem yesterday, I thought about changing my design to save words, not individual bytes. The reason I'd chosen bytes in the first place, though, was to save an items of arbitrary size - 1 to 4 bytes - without padding. In principle, this would be scalable to objects of larger size.

I decided to try to save each byte in multiple byte numbers. Along with keeping my original design, this would allow me to practice some masking, shifting, and branching.

Some code:

LDR R2, =Heap_Mem ; temp just the Heap_Mem

ldr R3, =0xCCBBAA ; Set R3 to value
AND R4, R3, #0xFF ; Set R4 to R3 masked & 00000000000000000000000011111111 0xFF
STR R4, [R2] ; Save R4 to location R2

ADD R2, R2, #1 ; increment R2
CMPS R3, R4 ; compare R3 and R4
BEQ end_of_save ; if equal, jump to end_of_save

NOP

MOV R4, R3, LSL #16 ; Set R4 to R3 shifted left 16 bits
MOV R4, R4, LSR #24 ; Set R4 to R4 shifted right 24 bits
STR R4, [R2] ; Save R4 to location R2

ADD R2, R2, #1 ; increment R2

ldr R4, =0xFFFF ; Set R4 to FFFF
CMPS R4, R3 ; check whether R3 <>
THIS ISNT WORKING START HERE BMI end_of_save ; if so, jump to end_of_save

NOP

end_of_save


As you can see, I'm planning on walking all the way through the number, paring it down as I go. Yes, this could be a loop and if I was writing in C, I'd be confident enough to implement it that way. For now, just baby steps.

You'll notice the note to myself - I need to figure out conditionals. That's up first tomorrow.

Up second is, this hasn't overcome my alignment problem.

This code saves "aa" and then "bb" at the same memory location. Not sure why, yet.

Wednesday, December 16, 2009

Non-aligned Access

So, I decided to make a run at writing a little heap memory manager. Essentially, this would be a stack that would keep track of where in my heap I stored some values.

I considered a few designs and settled on this: 256 bytes of memory managed by a queue 256 words long. The astute reader will have noticed that I planned to pack 256 bytes into five times as much space.

Stunning, is it not?

Actually, since I planned to allow memory storage in 1, 2, 3, or 4 byte amounts, the maximum amount of items to be stored would be 256, which means I'd need a management queue that oculd handle that many members. The fact that I wanted to use words, not bytes, for the management queue was just a simplifying assumption.

On the bus, on the way home, I made a list of things to do:

  1. Adjust the SPACE allocation to allow for 0x500 bytes.
  2. Create a new section of the heap to act as a manager for the managed area.
  3. Load and read some test values into the heap.

Well, 1 and 2 were learning experiences that I managed to work my way through.

What happened when I tried to do 3 was "Non-aligned Access" - since I was trying to manage all the bytes, it was loading more than it should.

That would not have been a problem - or at least not one that I hadn't expected.

The bigger problem was that it was writing over some of the writes. I'm still not sure why, but I gather that ARM takes non-aligned matters into its own hands.

On the bus, tomorrow, I'll decide what to do next.

Tuesday, December 15, 2009

The Memory of Persistence

Tonight, I started playing with saving and loading data to/from memory.

First, I modified the startup.s since it seemed to have a 0 length heap. Again, I assume that is a place holder than anyone would modify according to their design. I set it to 100. (The SPACE directive uses bytes, not words.)

Then I set up an IMPORT statement and an EXPORT statement for Heap_Mem and used indirect addressing to store a number and load it to another register.

Here is the code:

; A Hello World type of program intended to see if I can get something to compile.
; Name: HelloWorld.s
; modifying to play with different aspects.

AREA HelloWorld, CODE, READONLY ;
EXPORT mystart ; Export this code to the project
IMPORT Heap_Mem ; This is the base of the heap.
mystart
MOV R3, #25 ; Set R3 to 25
LDR R2, = Heap_Mem ; Load memory location into R2
STR R3, [R2] ; Store contents of R3 in R2
LDR R4, [R2] ; Load contents at R2 into R3

stop
BAL stop ; gives me a loop to be caught in
END ; end.

I also did an example with an offset, just to try it out.

Monday, December 14, 2009

Success!

Just a brief update tonight.

After going over the startup.s file for the TI chip some more, I read up on EXPORT and IMPORT. I decided to take another run at HelloWorld. If you remember, when I tried to just create a standalone project, it ran into memory management issues because there was no scatter file. If I used a technology with a Keil-generated start up file, it didn't seem to run my code.

What I needed to do, then, was use EXPORT and IMPORT to call my code from the generated code. I read up on the syntax, started a new project, and copied/added one of my HelloWorld.s samples from before to the new project.

I had to futz around with breakpoints a little to be sure it was running, but it did run. Here's the code:

; A Hello World type of program intended to see if I can get something to compile.
; Name: HelloWorld.s


AREA HelloWorld, CODE, READONLY ;
EXPORT mystart ; Export this code to the project

mystart
MOV R3, #25 ; Set R3 to 25
MOV R2, R3 ; Set R2 to R3

stop
BAL stop ; gives me a loop to be caught in
END ; end.


I was able to set breakpoints on it and verify that R3 got a value of 0x00000019 and then R2 got the same value.

Sunday, December 13, 2009

Lighthouse Keeping

I went back through the posts for the last week and added labels.

Yesterday, I got a CD from the nice people at Keil. (Hi, nice people at Keil.)

I hope they understand that I'm using their evaluation download for educational purposes and am not likely to buy a copy any time soon.

Into the Code Section

Finished going through the equate statements in the first half of the program. So far, I've just been able to flick back and forth between the equate statement and the line of code using the value. If it gets more complicated, I'll make a spreadsheet with the values and names (Excel - the last refuge of scoundrels.)

The system defines several flash banks (Flash Bank 1, Flash Bank 2 - with parallel setup.) I'm going to guess these are banks of flash memory that the chip can access.

Some DCD instructions assigning values equated above or 0xFFFFFFFF in a default case. They don't have labels, so I don't see how they are used later. Well, they're written to a specified location, so I guess it's done directly. Everything else has labels, though, so I'm not sure why not these.

And we're up to the area definition and entry point. Starts out with a series of unconditional branch commands. I recognize the concept from Gibson's book. These commands start at the 0 memory location, which is where the control jumps when the power is cycled.

There's no code for the reset handler, but it is exported. I assume you have to write the export handler.

Note to me: read up on IMPORT and EXPORT keywords.

And we're getting into assigning values specified in the EQU section to the correct locations in memory - also specified in the EQU section.

More tomorrow.

Saturday, December 12, 2009

High End Time

Spent an hour this morning continuing to go through the startup program for the TI chip. I'm about a third of the way through. So far, it's pretty much EQU directives. The file is commented, so I have more than a few clues as to what's going on.

In my notes, I keep writing "why is this 0?" next to EQU directives. This could be because this is a template for design and the 0 values are intended to be replaced.

The only thing that sent me scurrying off to google was a section called HET RAM - several EQU directives with labels containing "HET". I found a document from TI about their High End Timer: "The HET is a micro machine and programmed with its own instruction set." So I'm assuming HET RAM interacts with the HET system.

I'll spend some more time on this today or tomorrow. The code section starts half way through the file. I'm highlighting the EQU directives as I go through them. If I have trouble referring back to them, I can always make a spreadsheet for reference.

Thursday, December 10, 2009

The Final Frontier

The last few days with the Keil IDE have not been very productive, so I decided to go another way. I'm going through one of the Startup.s files. I'm going to go through it in depth, making sure I either understand all the elements or make notes of those that I don't get.

My goal in this is to see a bigger, more elaborate program than the snippets I've seen in books and on-line tutorials.

This file is about 1100 lines long. It's for one of the TI chips.

I'm a hundred lines in or so, making notes as I go. So far, there isn't anything I haven't seen -- except for the SPACE directive, which I looked up.

More tomorrow.

In other news, MS Visual Studio has support for embedded programming. I've used Visual Studio before. I'll look into that over the next few days.

Wednesday, December 9, 2009

Just Noodling Around

Not much time tonight, so I just noodled around with one of the startup files for a TI chip. I compiled a project with it (after commenting out the __main IMPORT and a couple of other lines.)

Then I looked through it to see some of the moving parts.

I'll do some more of that tomorrow.

I also looked for some more resources on line - some tutorials or something.

Tuesday, December 8, 2009

Daedalus, your twine broke

So, last night, I got an ARM assembly language program to build. No errors, no warnings.

Running it in Debugger didn't work so well. I think I included a couple of the errors in the last post.

I assumed it was a problem with my code, but what if I'm using the debugger wrong?

So, this is what's currently happening when I run HelloWorld in debugger:

Dissassembly window:

13: MOV R3, R3 ;
0x00000000 0330A0E1 TEQEQ R0,#0x000000E1
14: MOV R3, #25 ;
15:
16:
17:
18: stop
0x00000004 1930A0E3 LDMNEDB R0!,{R0-R1,R5-R7,R13,PC}
19: BAL stop
0x00000008 FEFFFFEA (???)
0x0000000C 00000000 ANDEQ R0,R0,R0
0x00000010 00000000 ANDEQ R0,R0,R0
0x00000014 00000000 ANDEQ R0,R0,R0
0x00000018 00000000 ANDEQ R0,R0,R0
0x0000001C 00000000 ANDEQ R0,R0,R0

Command window:

*** Error: 'C:\Keil\ARM\BIN\DARMO.DLL' not found
Running with Code Size Limit: 32K
Load "C:\\keil\\MyProgs\\aHello\\HelloWorld.AXF"

*** Restricted Version with 32768 Byte Code Size Limit
*** Currently used: 12 Bytes (0%)

Hmm. What the hell's DARMO.DLL? (It is not a DLL on my system. It's not in the help.)

And if I hit F5, I get this error:

*** error 65: access violation at 0xFFFFFFFC : no 'read' permission

I put a couple of hard returns in before "start" and now if I single step, it goes back and forth between 0x00000000 and 0x00000004.

I recognize LDMNEDB as a branch -- what I don't understand is why its there.

Back to the manual.

Back from the manual.

Did some poking around and settled on trying to run the Hello example that comes with the debugger - written in C. I'm just as puzzled as before. The Dissassembly window looks like C code where each line is followed by the assembly code to implement the C code.

Then why doesn't my HelloWorld source code correspond to the assembly commands in the Dissassembly window in my example?

Well, that has to do it for tonight.

One tidying up task -- I didn't install the GNU compiler that I downloaded with the Keil tools. Maybe that has the DLL I was looking for or some other help. I'll poke around in it tomorrow.

Monday, December 7, 2009

An Error Error

You'd think that for a Technical Writer, I'd be more willing to RTFM.

So, my task today was to get my HelloWorld program to compile and maybe run.

The first thing I had to figure out was a scatter file to get past the error I was fighting with yesterday. I put one together from "ADS 1.2 Build Tools - Errors and Warnings".

Once I had that saved and included in the Options for Target dialog, my

HelloWorld.axf: Error: L6206E: Entry point (0x00000000) lies outside the image.

error from yesterday went away, but I got another build error:

HelloWorld.axf: Error: L6204E: Entry point (0x00000000) does not point to an instruction.

This one puzzled me for a few minutes -- after all, I had an entry point. I noodled around until I realized that I didn't have any valid instructions. This version of the program was as follows:

AREA HelloWorld, CODE, READONLY ;
ENTRY ;

mystart


stop

END


I just wanted it to build, after all. I didn't expect it to do anything.

I added a couple of commands. I also dug back through the Gibson book to see if there was anything else I needed to be doing to be using the Keil tools. The result was a build-able program.

Here's the code, btw:

; A Hello World type of program intended to see if I can get something to compile.
; Name: HelloWorld.s
; spliced together from Gibson's example on p. 40.

AREA HelloWorld, CODE, READONLY ;
ENTRY ;

EXPORT Reset_Handler ;

Reset_Handler

mystart
MOV R3, R3 ;
MOV R3, #25 ;



stop
BAL stop ;

END ;

(I know the semicolons are not necessary eol, but I can't help myself.)

After that, I got the following error:

*** error 65: access violation at 0xFFFFFFFC : no 'read' permission

Of course, this is not a build error, it is an error error.

-aah, progress.

Up for tomorrow: Try to figure out why the debugger Disassembly pane displays code that doesn't resemble the code I wrote.

Sunday, December 6, 2009

Scatter Shot

This afternoon, I made a run at compiling and running a snippet of code, per my NPT of yesterday.

By the way, I'm not jumping into the Keil tools without any preliminaries. I read Gibson's ARM Assembly Language, an Introduction. I was hoping that would be enough to get me to a "Hello World" level.

Not quite.

The first thing that struck me is the degree to which this is embedded programming. Doing C doesn't involve first choosing a target architecture.

ARM programming does, however, so the first choice I was faced with was to pick a chip to write to. I started with "ARM7 (Big Endian)", which I assumed (and still assume) is vanilla.

I then copied a few lines of sample code from Gibson's book, tried to build it, and got my first error:

HelloWorld.axf: Error: L6206E: Entry point (0x00000000) lies outside the image.

Okey-dokey.

Let's try the same thing with another chip, say something from Samsung:

First, this selection got me the option to create a Startup.s file. OK. That file assumed an entry point in a C program and blew an error when it didn't find it.

NP: I commented out a couple of offending IMPORT statements and got a compile.

After a side-trip through creating a separate source file, I decided to try simply adding my basic code to the startup file. That compiled, but the debugger didn't reach it.

A couple more misadventures in a different project later, I decided to go back to my first HelloWorld and troubleshoot the first error some more. As far as I can tell, there's a map file that defines the image. The linker settings that I found (Options for Target dialog) are requesting a 0 sized region for my code.

Which explains why my entry point is outside it.

The next thing I'll try is digging through the linker settings, looking for a way to set the sizes if the relevant parts of the memory map.

Saturday, December 5, 2009

And Hello from the World

Last night, I downloaded the Keil tools and got installed. The download and install process was pretty straight forward. They insisted on a bit of information - name and address, that sort of thing. I've coughed up my personal information for much stupider fellows, though, so I proceeded.

They are a bit cagey about how long the evaluation period lasts. If it's less than a month, I will write in an complain - demand my money back.

A couple of times, I got a dialog box explaining that the evaluation version was limited to 32K, which should be fine.

The program (for the record, μVision V4.00a) looks like a grown-up IDE, not that different from Eclipse or MS Visual Studio. There's a project tree on the left, a code window upper right, and a code output window lower right.

LEARN MORE ABOUT: the Project pane and how the projects work.

I dinked around with the IDE for a while, but didn't get it to do anything except cause my code to error out.

This morning, I got a little more systematic. I dug through the help for some tutorial like content and followed the steps. The sample was a C program called Blinky.

The important part - wrt the LMA above - is that I could walk through the steps for creating a project.

The debug mode is also pretty familiar from other IDEs. It even uses F5 to run, although, you have to be in debug mode to use that. Unlike my experiments last night, this code ran and I was able to play with the debug tools.

NEXT PROGRAMMING TASK: Something like a Hello World, just to create and compile a program of my own.

What this blog is about

So, I have a project in mind.

I'm going to learn assembly language for the ARM class of microprocessors. Within a few weeks, I expect to be able to understand simple programs written for ARM chips, be familiar with the moving parts, and write simple programs for a simulator.

I'm a Programmer Writer, currently working a gig for a major software company that probably wouldn't appreciate my using their name in this unofficial capacity. I started as a Technical Writer back in the 1990s when you could get a job in high tech by being able to turn on a computer.

Although I was good at it, I was concerned early on that I would lose out on jobs because I had no training in Technical Writing. At the time, it seemed like certificate programs in Technical Communication were popping up all over the place. I can show experience and samples to a person, but a search engine looking at my resume will not find a degree in Technical Communications.

Also, GUI design and presentation were getting better and more standardized. There was less need for people to write a stand-alone help file for an end-user program.

So, I decided to bulk up my technical skills.

I started with C++, went on to Java, did a side trip through Visual Basic, did some Python and Perl, and then came back to Java and got a programmer certification from Sun. That got me my first API Writer gig.

From there, I worked on C# and some other MS technologies (including PowerShell, which is pretty cool.)

I spent some time looking at HLA (High Level Assembly). This is an x86 assembly language, somewhere between - well, here's a link: http://homepage.mac.com/randyhyde/webster.cs.ucr.edu/index.html. I learned a bunch of stuff that programmers learn in school - like why a switch statement is faster than a series of if-elses and how type casting works.

I spent a lot more time, after that, on C.

Good old C - close enough to the processor to smell the oil, but still expressive enough to do - well, whatever the hell you want.

So, why ARM Assembly?

Well, there's a butt-load of software that runs on ARM chips. It's mostly written in C and other stuff, but for embedded systems, it seems like assembly is used to some degree in the implementation. Also, understanding the architecture of the chip goes hand-in-hand with the structure of the assembly language.

Besides, it's pretty cool.

So, I decided to blog this - just to avoid the possibility of distraction. If I work on this a little bit every day, including ten minutes for a brief posting, I should be able to make good progress by the time my Keil Evaluation License goes bad.

Wish me luck.