Simple Programs in Assembly and C
ASSEMBLY | C
---------------------------|---------------------
|
COUNT EQU 5 | #define COUNT 5
|
DATA: section .data | unsigned int i;
org $0900 |
i: ds.w 1 |
|
CODE: section .text | main()
org $0800 | {
lds #$0A00 | i = COUNT;
ldd #COUNT | }
std i |
swi |
---------------------------|----------------------
|
DATA: section .data | signed char div(signed char j);
org $0900 |
i: ds.b 1 | signed char i;
|
CODE: section .text | main()
org $0800 | {
lds #$0A00 | i = div(16);
ldaa #16 | }
jsr div |
staa i |
swi |
|
div: asra | signed char div(signed char j)
rts | {
| return j/2;
| }