https://www.liquidpoker.net/


LP international    Contact            Users: 285 Active, 1 Logged in - Time: 02:30

Computer Science Help

New to LiquidPoker? Register here for free!
Forum Index > Poker Blogs
StArCuE   United States. Sep 14 2009 20:41. Posts 123
I need help writing a basic machine language program that counts and adds a list of integers. If you can help me understand it I will pay with ps money for your time. Thx Chris. For blog sake, poker is going well.

0 votes
Facebook Twitter

jasper5408   United States. Sep 14 2009 20:47. Posts 820

can u be a bit more specific? is this list of integers an arrray?


tec27   United States. Sep 14 2009 21:12. Posts 173

Machine language as in assembly? If you can be a little more specific I can definitely help you out.


StArCuE   United States. Sep 14 2009 21:30. Posts 123

Heres the assignment. This is a hw assignment and I'm having trouble getting started so I hope this is specific enough.

;; insert a prologue comment here, with
;; your name, our class name, date, and
;; a short description of the program

;; Register usage (add more as needed)
;; R0 – a value of zero, for JUMP instructions
;; R1 – current number
;; R2 – running total
;; R3 – running count
;; R4 – data address
;; R5 – a value of one, for incrementing the count and the current data address

;; Memory usage (add more as needed)
;; 80 – count of numbers found
;; 81 – sum of numbers found
;; 82 – first value to be processed
;; 83 > ?? – additional values to be processed, terminated with a zero value

;; Assumptions
;; 1. Total and count will not exceed the capacity of 1 signed integer byte (i.e.,
;; data values are one byte long).
;; 2. There is at least one value to be processed.
;; 3. The list of values is terminated by a zero value.
;; 4. The code segment begins at address 00.
;; 5. The data segment begins at address 80.

;; Program template (to be filled in with code)

;; program set-up
00 xxxx ;; set R0 to zero for later comparisons (constant)
02 xxxx ;; set count (R3) to zero
04 xxxx ;; set total (R2) to zero
: : ;; set R5 to one (constant)
: : ;; set address of first data value in R4

;; loop to process all values
;; load next value into R1
;; is this value zero (i.e., end of number list)? if yes, go to store results
;; block; otherwise it is a valid number, continue processing
;; add current value to running total
;; add 1 to value counter
;; increment data address (location pointer) to next data value
;; go to top of loop and continue processing

;; store results
;; store final counter in memory location 80
;; store final sum in memory location 81

;; end program
;; halt

Assignment #5 – Machine Language Program – September 2 – Due September 21

Description

Write a program in the Brookshear machine language. The program counts and adds up a list of integers.

Details

Follow the program template handed out in class.
a. document any additional memory or register use
b. add line addresses throughout the code
c. format of one line of code:
memory code address instruction ;; comment (given)

New instruction, to be added to the Brookshear language: unconditional jump (i.e., always jump at this point in the program).
D 0XY second position unused (0), XY is the memory address of the line of
code to jump to
Walkthrough. You must do a walkthrough of your completed program with me, before handing in the program. If you don’t, the assignment is considered late. If your program is correct, or has only 1 or 2 simple errors, you will be checked off. For programs with more errors, you will need to return for an additional walkthrough.
Once you are finished, schedule the walkthrough, leaving enough time to correct errors (if needed) and / or do extra credit.
Cover letter. Add to the usual cover letter the date of your walkthrough(s) and what we found.
Extra credit #1. Include a discussion where you explain whether your program would or would not behave correctly if there were no data values in the list, only the terminating zero. “Correctly” means the answers are right (count of zero and sum of zero) and that the program halts.
Additional extra credit by arrangement with me, possibly a second program.

New Instruction:
E R0X LOAD indirect. X and R are registers. X contains the address of the
next data value; X starts with the address 82. The E instruction
goes to the address given in register X and LOADs that information
into register R. Use this for the first instruction in the loop.

Other notes (these and the new instruction should match your class notes):

1. Ignore Brookshear’s instruction 6 (we are not using floating point numbers).
2. The data segment numbering on the assignment sheet is altered to reflect the fact that we are not using location 82 for an address; the list of numbers starts in 82.


StArCuE   United States. Sep 14 2009 21:32. Posts 123

I just need to write it out on paper this isn't a real programming language or anything. Just something my teacher made up.


StArCuE   United States. Sep 14 2009 21:41. Posts 123

The first data value would be in location 80 then 81 next 82 and so forth.
16 16 16
It would probably be best to get on skype or msn and do this. Which I would more than happy to do. Just send me a pm and hopefully we can work something out.


StArCuE   United States. Sep 14 2009 21:44. Posts 123

Brookshear btw is my CS book. And yes machine language as an assembly.


boreHM   Netherlands. Dec 28 2009 11:14. Posts 1595

http://vision.middlebury.edu/~cs101/Homework/hw05/instructions.html
so this is the language?

you know it's due september 21?


 



Poker Streams

















Copyright © 2024. LiquidPoker.net All Rights Reserved
Contact Advertise Sitemap