Last active
March 9, 2018 05:13
-
-
Save owskio/d7cfaaaf14583345da6731f0f97c1323 to your computer and use it in GitHub Desktop.
The simplest avr assembly program I could come up with (does however include a macro), just initializes a port's direction and sets its output value to drive an 8 led array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; | |
; Hello world in assembly, for me, is actually just setting a port to a value, | |
; This can affect the state of a single LED, or 8 as in my case | |
; m1284def.asm can be found online | |
; | |
; Output file in intel hex format with -fI | |
; | |
; wine avrasm2.exe -fI -l test.lst test.asm \ | |
; | |
; avrdude -c usbtiny -p atmega1284 -U flash:w:test.hex | |
; | |
.nolist | |
.include "./m1284def.asm" | |
.list | |
.macro outi | |
;out immediate | |
push r30 ;Preserve contents of register | |
ldi r30,@1 ;Load immediate value into register | |
out @0,r30 ;Must use out because are usually setting memory mapped port address which is in the low memory where mappings happen or whatever | |
pop r30 ;Restore contents of register | |
.endm | |
.cseg ;Code (flash) segment; would be defaulted to code segment without declaration | |
;Port initialization | |
;should be necessary but is apparently not, also makes leds too bright on the eyes | |
outi DDRA,0xff | |
;Output a value with both repetition (to verify the non accidental nature of the assignment) | |
;and assymetry (to verify the orientation of the bits/nibbles with respect to the port pins) | |
outi PortA,0b_0101_0110 | |
Main: | |
rjmp Main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment