News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

hi, can anybody help me? plsssssssssss

Started by erika, April 04, 2011, 04:20:55 AM

Previous topic - Next topic

erika

Hi, I am Erika, computer science student. I need help for my case study in assembly language.. :( ... Our professor gave us problems and we need to pass it on Wednesday, but how can we do such a program if she didn't taught us on how to do it.  huhu... and now I'm freakin' out... PLEASE.... help me..

these are the problems:

1. Write an assembly language program that counts the number of odd and even numbers in a list that is stored in memory starting at memory location ALPHA. The list is terminated with a sentinel number FFH(note that the sentinel number is not part of the list). Place the odd number count in memory location ODD and the even number count in memory location EVEN. Assume that there is a possibility of an empty list.

2. Write an assembly language program that counts the number of positive and negative numbers in the list. The list contains byte size signed numbers and is stored at memory location ALPHA. The list is terminated with a sentinel number FFH(note that the sentinel number is not part of the list). Place the positive number count in memory location POS and the negative number count in memory location NEGA.

3.Write an assembly language instruction that gets the highest and the lowest numbers in a list. The list contains byte-size signed numbers and is stored at memory location ALPHA. The list is terminated with a sentinel number FFH(note that the sentinel number is not part of the list). Place the highest number in memory location HIGH and the lowest number in memory location LOW. Assume that there is at least one element is the list.

4. Write an assembly language program that adds the elements in a list. The list contains byte-sized signed numbers and is stored at memory location ALPHA. The number of elements in the list is stored at byte memory location COUNT. Place the result in memory location SUM. Assume that there is at least one element in the list.

5. Write an assembly language program that adds two 32-bit numbers and stores the result in memory location GAMMA. The first 32-bit number is located at memory location ALPHA, while the second 32-bit number is located at memory location BETA.

6. Write an assembly language program that adds two 64-bit numbers and stores the result at memory location GAMMA. The first 64-bit number is located at memory location ALPHA, while the second 64-bit number is located at memory location BETA.

7. Write an assembly language program that reads a byte from memory location INPUT. The program should then examine this byte to determine which bit is a logic 1. If the first bit (b0) is a logic 1, then the program should load 01H to memory location OUTPUT. If the second bit (b1) is logic 1, then the program should load 02H to memory location OUTPUT. And so on and so forth. If the byte is equal to 00H(there is no bit equal to logic 1), then the program should terminate. ASsume that only one of the bits (b0 to b7) can be equal to 1.

8. Write an assembly language program that adds two 2-decade BCD numbers and stores the result at memory location GAMMA. The first 2-decade BCD number is located at memory location ALPHA, while the second 2-decade BCD number is located at memory location BETA. Assume that there would be a carry from then least significant decimal number to the most significant decimal number.



dedndave

hi Erika - welcome to the forum
sounds like a crappy instructor - lol - i had a few of those
a few of them didn't teach at all - they just handed out assignments

we have a policy of not doing homework for people
however, we can help if you make a concentrated effort and have problems
it may be that your instructor does not actually expect you to succeed at some of these tasks
it could be that she wants to see the same thing - make a good effort
also - if someone in here writes this code for you, it is going to look like it was written by an experienced assembly programmer   :P
there is much to learn, just to get started, let alone writing a functional piece of code
you will want to start out by installing the masm32 package
your best friend may be the forum search tool
look at other code and see how it was done

vanjast

google wrt Assembler:

1) Loop control
2/3) Comparing values - cmp instruction
4/5/6) Maths instructions - 8/16/32/64 bit
7) The Test and In/Out Instructions
8) BCD maths, and Ascii adjust instructions

As you can see you really have only 4 assignments, don't forget to study the CPU status register with regard to overflows, carry's.. etc.

You can do this in one evening - it's not that difficult.
Good luck
:wink


dedndave

that's right - it isn't that hard
you will have more fun getting a file to assemble than writing the program - lol
the first 6 chapters of Randy Hyde's "Art of Assembly" will get you going

http://www.arl.wustl.edu/~lockwood/class/cs306/books/artofasm/toc.html

FORTRANS

Hi,

   Here is a thread that discusses BCD arithmetic.  Dave, I,
and others posted some code for you to look at.  But just
the discussion may help to explain what BCD is all about.

http://www.masm32.com/board/index.php?topic=12771.0

HTH,

Steve N.

RuiLoureiro

Erika,
         To start try to solve your problem number 1 and then modify it to solve
         number 2, 3, ...
         
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
I think you need to start with something like this
Try to write your own program and test it, show us your problems...
may be we can help you, ok ?
Am i right ?
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    include \masm32\include\masm32rt.inc
    .686

.data
EVEN    db 0
ODD     db 0

ALPHA   db 1
        db 2
        db 5
        db 200
        db 0FFh     ; end

;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
.code
start:
            mov     esi, offset ALPHA
   next:    mov     al, byte ptr [esi]
            add     esi, 1
           
            cmp     al, 0FFh
            je      done
            ;
            ; If AL is even then EVEN = EVEN + 1 and Goto next
            ;
            ;
            ; If AL is odd then ODD = ODD + 1 and Goto next
            ;

            ;------------------------------
            ;
            ; END
            ;
done:       
            invoke ExitProcess, 0
;........................................................
end   start   
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<