Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .include "m32def.inc"
- .org 0
- ldi zh, high(ASCII_TABLE << 1) ;28 because we take the value of .org 20 which is 14hex shifted by 1 ==28HEX
- ldi zl, low(ASCII_TABLE << 1) ;28 and since high() and low() uses 16 bits we convert it 2 16bit format 00000000 00101000
- ; so high() becomes 00000000 and low() becomes 00101000
- ldi r16, 0x0
- out DDRC, r16 input ;next we set ddrc as input 0-> 0x0
- ldi r16, 0xff
- out DDRD, r16 ;and ddrB as output -> 0xFF
- BEGIN:
- in r16, PINC ; now we take input from pinC and put it in register 16 (in this case 0)
- andi r16, 0b00000111 ;mask upper 5 bits to allow only 3 bits for input we do this with ANDi
- add zl, r16 ;now we the input of r16 into zl
- lpm r17, z ; here it gets tricky lpm loads the content of z into the register but we need to find either if we get
- ;the least significant bit or most significant bit. since the value of Z is 00101000 which
- ;is 0x28 which is stored in the memory adress
- ;now we go find in the memory and take the 8 bits (LPM) and we find 30
- out PORTD, r17
- rjmp BEGIN
- .org 20
- ASCII_TABLE:
- A+C 5/5
- .DB '0','1','2','3','4','5','6','7'
- ;so the output is 30 ASCI 0 DEC
- 0b00000111
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement