Advertisement
phyrrus9

Untitled

Jan 8th, 2014
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .init _main
  2.  
  3. .segment 32768      # Start of code
  4.  
  5. _main:
  6.                     # 0 - Index
  7.                     # 4 - Terminator
  8.                     # 8 - Location of buffer
  9.                     # 12 - Random Value
  10.                    
  11.  
  12.     # Some init stuff for my variables
  13.     sub sp, sp, $16
  14.     lda r10, $3
  15.     stw r10, $0(sp)
  16.    
  17.     lda r10, $243
  18.     stw r10, $4(sp)
  19.  
  20.     lda r10, $1
  21.  
  22.     lda r60, $65536
  23.     call    _randomMod
  24.     stw r2, $12(sp)
  25.     add r20, r2, r60        # r20 = 65536 + rand(65536)
  26.     stw r20, $8(sp)
  27.     lda r20, $0
  28.  
  29.  
  30.     ldw r40, $8(sp)
  31.     call    memcpy
  32.    
  33.     sub sp, sp, $12
  34.     stw r10, $0(sp)
  35.     stw r20, $4(sp)
  36.     stw r60, $8(sp)
  37.     lda r60, $0    
  38.     call    StudentCode
  39.     ldw r10, $0(sp)
  40.     ldw r20, $4(sp)
  41.     ldw r60, $8(sp)
  42.     add sp, sp, $12
  43.  
  44.  
  45.     # Run my loop
  46.     ldw r11, $0(sp)
  47.     ldw r12, $4(sp)
  48. maintop:
  49.     mov r59, r10
  50.     call    _printint
  51.     lda r50, $nl
  52.     call    _printstr
  53.     mul r10, r10, r11
  54.     ble r10, r12, maintop
  55.  
  56.  
  57.     ldw r40, $8(sp)
  58.     call    memcpy
  59.  
  60.  
  61.     ldw r50, $8(sp)
  62.     call    _printstr
  63.  
  64.     call    control
  65.  
  66.     add sp, sp, $16
  67.     exit
  68.  
  69.  
  70. ###########################################################################
  71. #
  72. # Code and code addresses below this point are subject to change without
  73. # notice or warning.  Well, lets be honest.  What is really going to happen
  74. # is that I'm going to grade your StudentCode.s with a different version of
  75. # this file than what I am providing you with.  Of course, if you did the
  76. # assignment correctly, then that shouldn't matter.  If you took shortcuts...
  77. #
  78. ############################################################################
  79. .segment 48000      # Note to students, these two locations WILL change
  80. memcpy:
  81.     lda r41, $49000
  82. memtop:
  83.     ldw r45, $0(r41)
  84.     stw r45, $0(r40)
  85.     add r40, r40, $1
  86.     add r41, r41, $1
  87.     bne r45, $0, memtop
  88.     lda r40, $0
  89.     lda r41, $0
  90.     ret
  91.    
  92.  
  93.  
  94. control:
  95.     lda r50, $nl
  96.     call    _printstr
  97.  
  98.     lda r50, $nl
  99.     call    _printstr
  100.  
  101.     lda r50, $msg
  102.     call    _printstr
  103.  
  104.     lda     r50, $line
  105.     call    _printstr
  106.  
  107.     lda r50, $text
  108.     call    _printstr
  109.  
  110.     lda     r50, $line
  111.     call    _printstr
  112.  
  113.     ret
  114.    
  115.  
  116. .segment 49000      # This location could change! Too bad for you
  117. text:  
  118.             # This string might even change!  It's kinda lame.
  119.             # Of course, the first print that you do shouldn't be
  120.             # this anyways! (But the control better still show what
  121.             # it is supposed to!)
  122. .string "Hello World\nIf any of this shows up on your screen in the first test then you are out\nof luck!  Here are a bunch more bits of text that you will have to deal with.\nTyping is a lot of fun, isn't it?  Computers are great.\nLook another line of stuff that you can't see.\nEven more here.\nLife is so hard, isn't it?\nSo, I guess I will stop typing now so that I can get on with writing the rest\nof this assignment up.  Enjoy!\n"
  123.  
  124. msg:
  125. .string "Original comment block for testing purposes:\n"
  126. nl:
  127. .string "\n"
  128. line:
  129. .string "---------------------------------------------\n"
  130.  
  131. .segment 65536
  132. .space 65536
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement