All 0s and 1s

;MATTHEW JIN

;The actual poem is at the bottom of the page


.ORIG x3000
 
  LEA R1,FONT_DATA ;load output string's address

  LD R2,ZERO   ;location x5000 stored
  LDR R2,R2,#0 ;character to be printed for 0 bits stored

  LD R3,ONE    ;location x5001 stored 
  LDR R3,R3,#0 ;character to be printed for 1 bits stored

         LD R4,INPUT  ;location x5002 stored 
  LDR R4,R4,#0 ;The ASCII character to be printed stored

  LD R6,FOUR ;Load register 6 with x0004 to serve as counter

;Multiply the value in R4 by 16 so that program can add the result to 
;FONT_DATA to find ASCII character to be printed
NEXT  ADD R4,R4,R4 ;double the value in register 4
  ADD R6,R6,#-1 ;decrement R6
  BRp NEXT 
  
  ADD R5,R5,#0
  BRz ROW

LABEL        ADD R1,R1,R4 ;Add R4 to R1 to get to location of character
  ADD R5,R5,#0
  BRzp NEXTLINE
  
  ADD R5,R5,#0
  BRp NEW_ROW

ROW  ADD R5,R5,#15 ;row counter set to 15

NEW_ROW  ADD R5,R5,#0 
  BRn DONE ;if row counter is negative, go to DONE
  

NEW_CHAR AND R6,R6,#0
  ADD R6,R6,#7 ;column counter set to 7 
  
  LDR R4,R1,#0
 
NEW_COLUMN  ADD R6,R6,#0
  BRn NEXTCHAR ;if column counter is negative, go to NEXTCHAR

  ADD R4,R4,#0 
  BRzp POSITIVE
  ADD R0,R3,#0 ;character to be printed when bit is one
  OUT ;print the char
  BRnzp FORWARD 

POSITIVE ADD R0,R2,#0 ;character to be printed when bit is zero
  OUT ;print the char
 
FORWARD         ADD R4,R4,R4 ;shift left

  ADD R6,R6,#-1 ;decrement column counter
  BRnzp NEW_COLUMN ;move to next column

DONE_ROW  LD R0,ASCII_NL ;load new line
  OUT
  ADD R5,R5,#-1 ;decrement row counter
  LEA R1,FONT_DATA
  LD R4,INPUT
  LDR R4,R4,#0
  LD R6,FOUR
AGAIN  ADD R4,R4,R4 ;double the value in register 4
  ADD R6,R6,#-1 ;decrement R6
  BRp AGAIN
  BRnzp LABEL
  

NEXTLINE        LD R4,SIXTEEN ;load #16 into R4
  NOT R6,R5 
  ADD R6,R6,#1 ;#-R5
  ADD R4,R6,R4 
  ADD R1,R1,R4 ;Add to R1 to get location
  BRnzp NEW_ROW

  
NEXTCHAR LEA R1,FONT_DATA 
  LD R4,INPUT 
  ADD R4,R4,#1
  LDR R4,R4,#0
  BRz DONE_ROW
  LD R6,FOUR
  BRnzp NEXT
  
DONE  HALT

ASCII_NL .FILL xA

ZERO  .FILL x5000

ONE   .FILL x5001

INPUT .FILL X5002

FOUR  .FILL x0004

NULL  .FILL x0000

SIXTEEN .FILL x0010


FONT_DATA
...

;EXPLANATION:


Everything above is to print a single word on to a monitor. This is the LC-3 Assembly Language. Unlike the many different high-level languages, this low-level language talks directly to the microprocessor of a computer. I would imagine that the first poem artificial intelligence wrote would have been very complex. LC-3 is very complex because of the many steps you have to take to get your program to run. For example, it is very easy to run the computer language Python as programmer/user. In some cases, all you have to do is press "Run". That doesn't mean Python is an easy language; it's just that the Python interpreter does everything behind the scenes to make it easy for the user. For LC-3, I have to be aware of every memory location in the program. After finishing writing the program, I have to go through two passes of testing. The first test is to see if all the memory locations are correct. The second test is the one actually reading the code, putting it all together. After that, I would have to convert from a .asm file to a .obj file. Doing all that, I can finally run my program. 

Notice that below FONT_DATA, nothing is there. I couldn't include the FONT_DATA because that would take up 500 lines. The FONT_DATA is essentially a dictionary where I can pick which characters I want to use. The only language computers speak is binary. All the programming languages that we see were made so that humans can understand such complex material. Yeah, we might see words, such as "for" or "while", but the computer sees those words as 0s and 1s. In binary, we can represent characters by using ASCII characters. Each character has a corresponding binary representation. Here's an ASCII table:




Using binary notation, I'll be writing a poem. This part is actually all zero's and one's. Altogether, while I can write a poem with this representation, I won't be able to put it on to a monitor without the code above. The code above will not only print the poem on to the screen, it will enlarge it so that it's 8 by 16 bits. I decided to go with a limerick.



First line: 

01000110 01101001 01101100 01100101 00100000 01010100 01110010 01100001 01101110 01110011 01100110 01100101 01110010 00100000 01010000 01110010 01101111 01110100 01101111 01100011 01101111 01101100 

Second line:

01010000 01110010 01101111 01100111 01110010 01100001 01101101 01110011 00100000 01111001 01101111 01110101 00100000 01101110 01100101 01100101 01100100 00100000 01110100 01101111 00100000 01101001 01101110 01110011 01110100 01100001 01101100 01101100 

Third line: 

01001000 01100001 01100011 01101011 01100101 01110010 01110011 00100000 01100001 01101110 01100100 00100000 01101000 01100001 01100011 01101011 01100101 01110010 01110011

Fourth line: 

01000010 01110010 01100101 01100001 01101011 01100101 01110010 01110011 00100000 01100001 01101110 01100100 00100000 01100010 01110010 01100101 01100001 01101011 01100101 01110010 01110011 

Fifth line:

01001111 01101000 00100000 01110000 01101100 01100101 01100001 01110011 01100101 00100000 01100100 01101111 00100000 01101110 01101111 01110100 00100000 01100010 01110010 01100101 01100001 01101011 00100000 01110100 01101000 01100101 00100000 01101100 01100001 01110111 


Actual poem:

File Transfer Protocol
Programs you need to install
Hackers and hackers
Breakers and breakers
Oh please do not break the law












Comments

  1. I don't really understand the programming, but from your description I can definitely follow the process behind making the poem. I never thought about how much work goes into a computer printing a simple stanza, so this post was very interesting. Do you think future programs will also follow this binary/ASCII representation, or will programming languages become more suited to printing words? I also liked how the limerick is relevant, and sounds like a rudimentary comp lit creation. Good effort! Way to flex!

    ReplyDelete
    Replies
    1. Hey Robert! Programming languages now are made so that printing words are a lot easier. The LC-3 Assembly language is honestly a language to help students understand the deeper mechanism in a microprocessor. People don't use it honestly. They got so many other high level languages they can use.

      Thank you for your kind comments. This is why I write blog posts: for people like you.

      Delete
  2. Well played Matthew! This looks like it took a long time to write, and I commend your effort! I am impressed by your binary abilities. I don't know how the LC-3 assembly language works, but you explained the idea very well. I am surprised by how much code it takes the assembly language to print one word--imagine having to use LC-3 for more complicated tasks! I think that the Limerick you wrote in binary is a very reasonable idea for something a computer would print. I like that it is actually relevant to the topic. You might consider submitting it to the limerick contest :)

    ReplyDelete
    Replies
    1. Thank you so much Kevin! You are truly the best. The rhythm is a bit off for the limerick, but if I can somehow manage to make it better, I'll submit!

      Delete
  3. Matthew this is a nice attempt at envisioning what the first poem written by and AI will be like. I though it was an interesting choice to include all the coding that you did even though I didn't understand any of it. I like how the actual poem ties back to computer related things because that appears to be what the AI knows best. The last line of the poem was also humorous. Nice Attempt! You must know your stuff.

    ReplyDelete
  4. Very interesting solution. Though I'm not sure how much I agree with it being similar to the first poem AI might write (there would most likely be many layers of abstraction between the AI and the character's representation in binary), I appreciate the twisting of the question and I think you have produced a more interesting answer as a result.

    I'm curious why you chose to use LC-3 instead of a more common assembly language such as x86, ARM, or MIPS. Did you learn LC-3 in a class, and therefor used it because you're familiar with it? I'm very impressed if you wrote all this assembly yourself; I've done a bit of toying with a made up assembly language that Mr. Smith invented for the Computer Programming class, but nothing close to this complexity. Even a simple for loop is frighteningly complex in assembly, but I do enjoy trying to find the most efficient way to solve a problem with it.

    ReplyDelete
  5. I think you called LC-3 a "low-level language" and I just about died. But I'm no coder. That said, I do like what you say about programs being user-friendly because of all their work behind the scenes as a metaphor. I think it's interesting consider poetry in this way as well. If a poem seems "easy" to understand, its message clear, it could be because the poet has done the heavy-lifting while writing the poem. Great post, Matthew!

    ReplyDelete
  6. The process of making this poem is insane. The post is obviously incredibly thought out and well executed. I am impressed by the sheer size of all of the "AI" outputs. The poem is cute, and I think that you did a good job representing it in different fashions. Great post!

    ReplyDelete
  7. I think your choice of LC-3 assembly language was pretty cool since as you mentioned, there are a lot of other languages that you could have chosen that would have made your life easier. Also, nice limerick!

    ReplyDelete

Post a Comment

Popular posts from this blog

are all poems married?

Box