Page 1 of 1

YOU SEE THIS?

Posted: Thu Nov 10, 2005 11:57 pm
by AttentionKMartShoppers
.orig x3000
AND R0, R0, #0
AND R1, R1, #0
AND R2, R2, #0
AND R3, R3, #0
LD R7, z3051 ; loads R7 with beginning of first matrix
ADD R6, R7, #4 ;loads R6 with beginning of second matrix
LDR R5, R7, #-1 ; loads number of matrices into R5
ADD R5, R5, #-1 ; decrements matrix counter by one
BRn None ; puts x3200-x3203 (one matrix) to zero.
Brz Store ; puts first matrix into x3200-x3203.
BitOne AND R2, R2, #0
LDR R0, R7, #0 ;loads R0 with first matrix
LDR R1, R6, #0 ;loads R1 with second matrix
LD R3, z000f ;loads first bit breaker
AND R0, R0, R3 ; separates first bit in R0
AND R1, R1, R3 ; separates first bit in R1
ADD R0, R0, R1 ; adds bits, places them into R0
LD R1, z00f0 ; loads first bit overflow checker/next bit checker
AND R1, R1, R0 ; checks for overflow
BRz Update1 ; no overflow, loads R0 (bit total) with running total of line
ADD R0, R3, #0 ; if overflow, put an F in R0
Update1 ADD R2, R0, R2
BitTwo LDR R0, R7, #0 ;loads R0 with first matrix
LDR R1, R6, #0 ;loads R1 with second matrix
LD R3, z00f0 ;loads first bit breaker
AND R0, R0, R3 ; separates first bit
AND R1, R1, R3 ; separates first bit
ADD R0, R0, R1 ; adds bits
LD R1, z0f00 ; loads first bit overflow checker/next bit checker
AND R1, R1, R0 ; checks for overflow
BRz Update2
ADD R0, R3, #0 ; if overflow, put an F0 in R0
Update2 ADD R2, R0, R2
BitThree LDR R0, R7, #0 ;loads R0 with first matrix
LDR R1, R6, #0 ;loads R1 with second matrix
LD R3, z0f00 ;loads first bit breaker
AND R0, R0, R3 ; separates first bit
AND R1, R1, R3 ; separates first bit
ADD R0, R0, R1 ; adds bits
LD R1, zf000 ; loads first bit overflow checker/next bit checker
AND R1, R0, R1 ; checks for overflow
BRz Update3
ADD R0, R3, #0 ; if overflow, put an F00 in R0
Update3 ADD R2, R0, R2
BitFour LDR R0, R7, #0 ;loads R0 with first matrix
LDR R1, R6, #0 ;loads R1 with second matrix
LD R3, zf000 ;loads first bit breaker
AND R0, R0, R3 ; separates first bit
Brn Negative
AND R1, R1, R3
Brn PosNeg
ADD R0, R0, R1
Br Update4
Negative AND R1, R1, R3 ; separate second bit
BRp PosNeg
BRn Neg4thBit
PosNeg AND R1, R1, R3 ; separate second bit
Brn Neg4thBit
ADD R0, R0, R1
Br Update4
Neg4thBit ADD R0, R3, #0
Update4 ADD R2, R0, R2
STR R2, R7, #0 ;loads matrix line into memory
ADD R6, R6, #1 ;increments second matrix counter by one
ADD R7, R7, #1 ;increments first matrix counter by one
AND R4, R7, #15 ;checks to see if an entire matrix has been added
ADD R4, R4, #-5 ;checks to see if an entire matrix has been added
Brz Restart
Brn BitOne
Restart ADD R7, R7, #-5 ; sets first matrix counter to x3101 again
ADD R5, R5, #-1 ;decreases matrix counter by 1
Brz Store
Brp BitOne
Store LD R7, z3200; loads beginning of answer location
LD R6, z3051; loads beginning of matrix
LDR R0, R6, #0
LDR R1, R6 #1
LDR R2, R6 #2
LDR R3, R6 #3
Br None
.BLKW 18
None STR R0, R7, #0
STR R1, R7, #1
STR R2, R7, #2
STR R3, R7, #3
HALT
z3051 .fill x3051 ;for loading matrices as well as #of matrices
z3200 .fill x3200 ;for addressing answer's location
z000f .fill x000f ;for splitting 4 bit hex
z00f0 .fill x00f0 ; for splitting 4 bit hex
z0f00 .fill x0f00 ; for splitting 4 bit hex
zf000 .fill xf000 ; for splitting 4 bit hex
.end

Posted: Thu Nov 10, 2005 11:57 pm
by AttentionKMartShoppers
That is LC3 assembly language, and you know what it does? It adds 4X4 matrices.

Posted: Fri Nov 11, 2005 10:47 am
by SUGAAAAA
I'd hate to think what it'd look like if they were 8X8 matrices....

Posted: Sat Nov 12, 2005 12:41 am
by BGoodForGoodSake
.ORIG X3000
LD R2, CHANGE;FFD0 in R2
LD R4, CHANGE2;0030 in R4
AND R6, R6, #0;
ADD R1, R5, #1;1 in R1
LOOP ADD R5, R1, #0; 1 in R5
BRz END;if R5 = 0 then go to END

TRAP x23;print a prompt on the screen and read a single;character from the keyboard its ascii code í R0
ADD R1, R0, R2;ASCII prompt + ffd0 í  R1
ADD R7, R1, #-3;result in R1 - 3 í  R7
BRz GETNUM;if R7 = 0 go to GETNUM

ADD R7, R1, #-6;result in R1 -3 í  R7
BRz GETNUM;if R7 = 0 go to GETNUM

ADD R7, R1, #-9;result in R1 -3 í  R7
BRz GETNUM;if R7 = 0 go to GETNUM
BR ENDIF;Go to ENDIF

GETNUM ADD R6, R6, R1;Ascii value goes to R6
ENDIF BR LOOP;Go to LOOP
END AND R1, R1, #0;clear R1
AND R2, R2, #0;clear R2
AND R3, R3, #0;clear R3
ADD R1, R6, #0;Ascci value goes to R1
BRz RESULT1;if R1 = 0 go to RESULT1
BRp RESULT2;if R2 = positive # go to RESULT2
;
RESULT1 LEA R0, ERROR;address of ERROR í  R0
TRAP x22;write a string of ascii characters to the console
TRAP x25;halt execution and print a message on the console
;
RESULT2 LEA R0, MESSAGE;address of MESSAGE í  R0
TRAP x22;write a string of ascii characters to the console
ADD R1, R6, #-9;
BRnz RESULT3;If R1 = - or 0 go to RESULT3
BR RESULT4;Go to RESULT4
;
RESULT3 ADD R6, R6, R4;ASCII value + 0030 í  R6
ADD R0, R6, #0;what is in R6 í  R0
TRAP x21;Write a character in R0 to the console display
TRAP x25;halt execution and print a message on the console
;
RESULT4 ADD R0, R6, #0; what is in R6 í  R0
WHILE ADD R0, R0, #-10;what is in R6 - 10 í  R0
;
BRzp DOBODY;if R0 = 0 or positive go to DOBODY
BR ENDWHILE;go to ENDWHILE
;
DOBODY ADD R3, R3, #1;increment R3
BR WHILE;go to WHILE
;
ENDWHILE ADD R2, R0, #0;result of R0 goes into R2
ADD R2, R2, #10;
ADD R0, R3, R4;
TRAP x21;Write a character in R0 to the console display
;
ADD R0, R2, R4;
TRAP x21;Write a character in R0 to the console display
TRAP x25;halt execution and print a message on the console
;
MESSAGE .STRINGZ " The sum of the multiples of three is:"
ERROR .STRINGZ "There are no multiples of three in the list"
CHANGE .FILL XFFD0
CHANGE2 .FILL x0030
.END

Posted: Sat Nov 12, 2005 12:14 pm
by AttentionKMartShoppers
You had to program on that evil simulator as well?

Posted: Sat Nov 12, 2005 8:19 pm
by BGoodForGoodSake
AttentionKMartShoppers wrote:You had to program on that evil simulator as well?
Good luck let me know if you need help.

Posted: Sat Nov 12, 2005 8:27 pm
by AttentionKMartShoppers
SWEEEEET

Posted: Sat Nov 12, 2005 10:09 pm
by kateliz
And here I was deceived by Norton into thinking computer languages could be fun! I had picked up a free and pretty old copy of one of his books, (free education- can't beat that,) and it gave some basics on it. Turns out I'd probably think it was boring! What a shame.

Posted: Sat Nov 12, 2005 10:10 pm
by AttentionKMartShoppers
What I don't get is why does everyone start the program at x3000

Posted: Sat Nov 12, 2005 10:12 pm
by BGoodForGoodSake
AttentionKMartShoppers wrote:What I don't get is why does everyone start the program at x3000
you don't have to you can start at x6000 or just leave it blank.
Older computers used to reserve the lower memory addresses.
If you leave it blank the program will run in the first available memory space.

Posted: Sat Nov 12, 2005 10:32 pm
by AttentionKMartShoppers
Ah, so it's just tradition