Identical programs in assembly and C
ASSEMBLY | C
---------------------------|---------------------
|
COUNT = 5 | #define COUNT 5
|
.area DATA (ABS) | unsigned int x;
.org 0x0000 |
i .ds 2 |
|
.area CODE (ABS) | main()
.org 0x0100 | {
lds #0x01FF | x = COUNT;
ldd #COUNT | }
std i |
swi |
---------------------------|----------------------
|
.area DATA (ABS) | char div(char j);
.org 0x0000 |
i .ds 2 | char i;
|
.area CODE (ABS) | main()
.org 0x0100 | {
lds #0x01FF | i = div(16);
ldaa #16 | }
jsr div |
staa i |
swi |
|
div: asra | char div(char j)
rts | {
| return j/2;
| }