#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    9
    Rep Power
    0

    Question How to program in assembly language?


    I am programming MASM 32-bit try to add up the sum and then get the average. There is a lot of 50 numbers in Hex. How can I add up all the number and get the average without overflowing? Because every time when I add those number up, if the number is too big, it would start over. Therefore, I am not getting the correct sumů.
    Even when I got the sum before overflow, when I try to divide it by some number, at compile time it gives me a message "immediate operand not allowed".... how can i solve this problem?
    my code:
    Loop:.........
    .........
    MOV EDI, OFFSET sum
    MOV [EDI], EAX
    MOVZX EAX, sum
    DIV number
    MOV AVEG, DL

    Also, if i try to compare the array to see if any of the number is the same, how should i do that. i tried with the following code, but the answer of the count is still zero...
    my code:
    mov esi, offset array
    mov ecx, count
    L2: cmp byte ptr [esi], 33
    JE A1
    ; similar code of cmp------
    A1: ADD num_1
    JMP B2
    ;similar code of increment counts---
    B2: mov edi, offset most
    mov [edi], EAX

    lea EDX, prompt
    call WriteString
    MOVZX EAX, most
    CALL WriteHex



    THANK YOU!
    Last edited by mulderGURL; June 13th, 2003 at 03:45 PM.

IMN logo majestic logo threadwatch logo seochat tools logo