OSS Action!
One of my favorite programming languages for the Atari 8-bit computers is OSS Action!. Action is a compiled, structured programming language similar to C or Pascal. One of the impressive features of Action is it’s very fast an efficient compiler. Not only does it compile programs quickly, it produced pretty tight machine code executables. I thought it would be interesting to take a look at some of the machine code that the compiler produces.
First lets look at the classic “Hello World” program. This Action code simply prints HELLO WORLD:
PROC MAIN() PRINTE("HELLO WORLD") RETURN
The resulting assembly code would look like this:
246E: JMP $2471 2471: JMP $2480 2474: .byte #$0B 2475: .string "HELLO WORLD" 2480: LDX #$24 2482: LDA #$74 2484: JSR $A46C 2487: RTS
The program starts with two JMP instructions. Although this isn’t very efficient, it’s at the start of the program so isn’t a big problem. The first JMP jumps to the MAIN procedure which is the starting point for all Action programs. The second JMP is the start of the MAIN procedure and it needs to jump over the static text that stored before the procedure.
Next we have the static text we will be printing. The first byte contains the length of the string and the rest the actual string data. After the string we have the actual code for the procedure. It simply loads the address of the string into the X and A registers and calls a library subroutine to do the printing.
2 Comments
Recommended Comments