In this article I try to talk about implementation part of CPU that can execute instructons subset of original AVR core. It’s only preview and can be use for academic using only. Because most useful programm that this CPU can execute is LED blinking :-) You can view this in following video:
Here right 8 LEDs indicate value of register R20. Left 8 LEDs – value of IP(PC). read more
Monthly Archives: June 2013
AVR electronicImplement CPU in FPGA. Core SomeAVR on verilog
24.06.2013 – 00:14
Link assembly and c
01.06.2013 – 12:53
I using nasm to generate object code from assembly source. 3 application required to compile executable:
– nasm
– gcc from gcc-
– ld from binutils package
*package names in ubuntu distribution
To install this packages run following command:
1 |
sudo apt-get install nasm binutils gcc-4.7-base |
Files contents:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
global func section .text func: push rbp mov rbp, rsp mov rax, 1 ; sys_write mov rdi, 1 ; stdout mov rsi, message ; message address mov rdx, length ; message string length syscall pop rbp ret section .data message: db 'Hello, world!',0x0A ; message and newline length: equ $-message ; NASM definition pseudo-instruction |
1 2 3 4 5 6 |
void func(); //may be extern void func(); is more true way int main(){ func(); return 0; } |
1 2 3 |
nasm -f elf64 func.asm gcc -c use_asm.c gcc use_asm.o func.o -o use_asm |
And finaly:
1 2 |
$ ./use_asm Hello, world! |