All 0s and 1s pt.2
Last week, I wrote a blogpost that probably didn't make a lot of sense.
"I don't really understand the programming, but from your description I can definitely follow the process behind making the poem." - Anonymous
"I don't know how the LC-3 assembly language works..." - Anonymous
"I thought it was an interesting choice to include all the coding that you did even though I didn't understand any of it." - Anonymous
I tried to put forth a whole bunch of code without much explaining. While the comments to the code were there, there was obviously still a lot of confusion regarding the code and the decision to include that mess.
In this blogpost, I want to explain the code in a form of a poem :)
**Also I made some edits to the code realizing that there were some bugs**
"I don't really understand the programming, but from your description I can definitely follow the process behind making the poem." - Anonymous
"I don't know how the LC-3 assembly language works..." - Anonymous
"I thought it was an interesting choice to include all the coding that you did even though I didn't understand any of it." - Anonymous
I tried to put forth a whole bunch of code without much explaining. While the comments to the code were there, there was obviously still a lot of confusion regarding the code and the decision to include that mess.
In this blogpost, I want to explain the code in a form of a poem :)
**Also I made some edits to the code realizing that there were some bugs**
.ORIG x3000
LEA R1,FONT_DATA ;Load the information the program wants to access
LD R2,ZERO ;Character to print when program finds zeros in memory address LDR R2,R2,#0
STR R2,FIRSTCHAR
AND R2,R2,#0
ADD R2,R2,#1
LD R3,ONE ;Character to print when program finds ones in memory address LDR R3,R3,#0
STR R3,SECONDCHAR
AND R3,R3,#0
ADD R3,R3,#1
LD R4,INPUT ;Load the final character the program wants to express
LDR R4,R4,#0
START LD R6,FOUR
NEXT ADD R4,R4,R4 ;Multiply character value by 16 to get the actual location ADD R6,R6,#-1 BRp NEXT ADD R5,R5,#0 BRz ROW
LABEL ADD R1,R1,R4 ;Now let's go on vacation ADD R5,R5,#0 BRzp NEXTLINE
ADD R5,R5,#0 BRp NEW_ROW ROW ADD R5,R5,#15 ;For the 16 in 8 by 16 pixel font, I loop through 16 times NEW_ROW ADD R5,R5,#0 BRn DONE NEW_CHAR AND R6,R6,#0 ;For the 8 in 8 by 16 pixel font, I loop through 8 times ADD R6,R6,#7 LDR R4,R1,#0 NEW_COLUMN ADD R6,R6,#0 BRn NEXTCHAR ADD R4,R4,#0 BRzp POSITIVE ADD R0,R3,#0 ;One is found, let's print the character! OUT BRnzp FORWARD POSITIVE ADD R0,R2,#0 ;Zero is found, let's print the character! OUT ;print the char FORWARD ADD R4,R4,R4 ADD R6,R6,#-1 BRnzp NEW_COLUMN DONE_ROW LD R0,ASCII_NL ;Now I want a new line OUT ADD R5,R5,#-1 ;Transition line by line LEA R1,FONT_DATA LD R4,INPUT LDR R4,R4,#0 LD R6,FOUR AGAIN ADD R4,R4,R4 ADD R6,R6,#-1 BRp AGAIN BRnzp LABEL ;Now we got things to combine NEXTLINE ;Let's go to the next row
LD R4,SIXTEEN NOT R6,R5 ADD R6,R6,#1 ADD R4,R6,R4 ADD R1,R1,R4 BRnzp NEW_ROW NEXTCHAR ;Let's go to the next column LD R4,INPUT ADD R4,R4,R2 LDR R4,R4,#0 BRz DONE_ROW ADD R2,R2,#1 BRnzp START ;Now do it again! DONE HALT ASCII_NL .FILL xA ZERO .FILL x5000 ONE .FILL x5001 INPUT .FILL X5002 FOUR .FILL x0004 FIRSTCHAR .FILL x0000
SECONDCHAR .FILL x0000
SIXTEEN .FILL x0010
FINAL POEM:
Load the information the program wants to access
Character to print when program finds zeros in memory address
Different character to print when program finds ones in memory address
Load the final character the program wants to express
Multiply character value by 16 to get the actual location
Now let's go on vacation
For the 16 in 8 by 16 pixel font, I loop through 16 times
For the 8 in 8 by 16 pixel font, I loop through 8 times
One is found, let's print the character!
Zero is found, let's print the character!
Now I want a new line
Transition line by line
Now we got things to combine
Let's go to the next row
Let's go to the next column
Now do it again!
Comments
Post a Comment