Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;******************** (C) COPYRIGHT HAW-Hamburg ********************************
- ;* File Name : main.s
- ;* Author : Alfred Lohmann
- ;* Author : Tobias Jaehnichen
- ;* Version : V2.0
- ;* Date : 23.04.2017
- ;* Description : This is a simple main.
- ; : The output is send to UART 1. Open Serial Window when
- ; : when debugging. Select UART #1 in Serial Window selection.
- ; :
- ; : Replace this main with yours.
- ;
- ;*******************************************************************************
- EXTERN Init_TI_Board ; Initialize the serial line
- EXTERN ADC3_CH7_DMA_Config ; Initialize the ADC
- ;EXTERN initHW ; Init Timer
- EXTERN puts ; C output function
- EXTERN TFT_puts ; TFT output function
- EXTERN TFT_cls ; TFT clear function
- EXTERN TFT_gotoxy ; TFT goto x y function
- EXTERN Delay ; Delay (ms) function
- EXTERN GPIO_G_SET ; Set output-LEDs
- EXTERN GPIO_G_CLR ; Clear output-LEDs
- EXTERN GPIO_G_PIN ; Output-LEDs status
- EXTERN GPIO_E_PIN ; Button status
- EXTERN ADC3_DR ; ADC Value (ADC3_CH7_DMA_Config has to be called before)
- ;********************************************
- ; Data section, aligned on 4-byte boundery
- ;********************************************
- AREA MyData, DATA, align = 2
- GLOBAL text
- GLOBAL max
- text DCB "Hallo TI-Labor!\n\r",0
- max DCD 1001
- AREA SamiData, DATA, align = 0
- primfeld FILL 1000*1,1 ;1000x1Byte werden mit 1 initialisiert
- ;********************************************
- ; Code section, aligned on 8-byte boundery
- ;********************************************
- AREA |.text|, CODE, READONLY, ALIGN = 3
- ;--------------------------------------------
- ; main subroutine
- ;--------------------------------------------
- EXPORT main [CODE]
- main PROC
- BL Init_TI_Board ; Initialize the serial line to TTY
- ; for compatability to out TI-C-Board
- ;BL initHW ; Timer init
- LDR r0,=primfeld ;r0 = address von feld
- ;ADD r0,r0,#1
- LDRB r5,[r0] ;in r5 wird der aktuelle Wert von der Adresse
- MOV r1,#1 ;i=1
- ;MOV r2,#1 ;r2 =1 ueberfluessig?
- LDR r3,=max ;laedt adresse von max in r3
- LDR r3,[r3] ;r3=max
- MOV r6,#0 ;unser NICHTPRIMZAHL wert, meckert wenn STRB #0, daher STRBr6
- for01 ADD r1,r1,#1 ;i++
- MUL r4,r1,r1 ;i*i
- CMP r4,r3 ;i*i<=max
- BGE end01 ;Wenn i*i>=1000
- if01 LDRB r5,[r0,r1] ;Laedt wert von primfeld[i]
- CMP r5,#1 ;Kuckt ob primfeld[i] = true ist
- BNE for01 ;wenn nicht true auf for01 springen
- MOV r7,r4 ;initialisiert p(r7) mit i*i
- for02 CMP r7,r3 ;p >= max
- BGE for01
- ADD r8,r0,r7 ;primfeld[p] Adresse+p wird in r8 gespeichert
- STRB r6,[r8] ;Setzt den Boolean bei unserer aktuellen Adresse auf 0/falsch
- ADD r7,r7,r1 ;p+=i springt auf nächste multiple vom Index unseres Arrays
- BAL for02
- end01
- if02
- forever b forever ; nowhere to retun if main ends
- ENDP
- ALIGN
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement