That's not how you call a chicken!
This commit is contained in:
@@ -4,47 +4,47 @@
|
|||||||
* Date : 2015-06-09
|
* Date : 2015-06-09
|
||||||
* Description: RTFT
|
* Description: RTFT
|
||||||
*-----------------------------------------------------------
|
*-----------------------------------------------------------
|
||||||
ORG $3000
|
ORG $3000 ; Start at address 3000
|
||||||
|
|
||||||
* Put program code here
|
* Put program code here
|
||||||
FACTORIZATION:
|
FACTORIZATION:
|
||||||
move.l #2, D2
|
move.l #2, D2 ; Store the constant 2 into data register D2
|
||||||
|
|
||||||
FACTORIZATION_LOOP:
|
FACTORIZATION_LOOP:
|
||||||
move.l D0, D3
|
move.l D0, D3 ; Store the value in the register D0 into data register D3
|
||||||
divu D2, D0
|
divu D2, D0 ; Divide the value in the register D0 with the value in the register D2 and store the quotient in the right half and the remainder in the left half of data register D0
|
||||||
swap D0
|
swap D0 ; Swaps the first two and the last two bytes in data register D0
|
||||||
cmp.w #0, D0
|
cmp.w #0, D0 ; Compare the constant 0 and the value in the register D0
|
||||||
beq FACTOR_FOUND
|
beq FACTOR_FOUND ; Jump to label FACTOR_FOUND if the value in the register D0 == the constant 0
|
||||||
|
|
||||||
add.w #1, D2
|
add.w #1, D2 ; Increase the value in the register D2 by 1
|
||||||
move.l D3, D0
|
move.l D3, D0 ; Store the value in the register D3 into data register D0
|
||||||
bra FACTORIZATION_LOOP
|
bra FACTORIZATION_LOOP ; Jump to label FACTORIZATION_LOOP
|
||||||
|
|
||||||
FACTOR_FOUND:
|
FACTOR_FOUND:
|
||||||
swap D0
|
swap D0 ; Swaps the first two and the last two bytes in data register D0
|
||||||
move.w D2, (A1)+
|
move.w D2, (A1)+ ; Store the value in the register D2 into the memory at the address stored in address register A1. Afterwards increase the address in the register A1 by 2
|
||||||
|
|
||||||
cmp.w #1, D0
|
cmp.w #1, D0 ; Compare the constant 1 and the value in the register D0
|
||||||
bgt FACTORIZATION_LOOP
|
bgt FACTORIZATION_LOOP ; Jump to label FACTORIZATION_LOOP if the value in the register D0 > the constant 1
|
||||||
|
|
||||||
rts
|
rts ; Return from the subroutine
|
||||||
|
|
||||||
START: ; first instruction of program
|
START: ; first instruction of program
|
||||||
move.l #numbers, A0
|
move.l #numbers, A0 ; Store the address of the variable numbers into address register A0
|
||||||
move.l #liste, A1
|
move.l #liste, A1 ; Store the address of the variable liste into address register A1
|
||||||
move.l #anzahl, D1
|
move.l #anzahl, D1 ; Store the constant anzahl into data register D1
|
||||||
|
|
||||||
LOOP:
|
LOOP:
|
||||||
move.w (A0)+, D0
|
move.w (A0)+, D0 ; Store the value at the address stored in address register A0 into data register D0. Afterwards increase the address in the register A0 by 2
|
||||||
bsr FACTORIZATION
|
bsr FACTORIZATION ; Call subroutine FACTORIZATION
|
||||||
|
|
||||||
sub.l #1, D1
|
sub.l #1, D1 ; Decrease the value in the register D1 by 1
|
||||||
|
|
||||||
cmp.l #0, D1
|
cmp.l #0, D1 ; Compare the constant 0 and the value in the register D1
|
||||||
bgt LOOP
|
bgt LOOP ; Jump to label LOOP if the value in the register D1 > the constant 0
|
||||||
|
|
||||||
SIMHALT ; halt simulator
|
SIMHALT ; halt simulator
|
||||||
|
|
||||||
* Put variables and constants here
|
* Put variables and constants here
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ anzahl EQU 3
|
|||||||
|
|
||||||
liste ds.w 20
|
liste ds.w 20
|
||||||
|
|
||||||
END START ; last line of source
|
END START ; last line of source
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -61,3 +61,4 @@ liste ds.w 20
|
|||||||
*~Font size~10~
|
*~Font size~10~
|
||||||
*~Tab type~1~
|
*~Tab type~1~
|
||||||
*~Tab size~4~
|
*~Tab size~4~
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user