Having huge problems in assembly language Format -


i trying learn assembly language have spent dozen of hours .asm code run on intel core i5 win 7 laptop nasm. problem books of assembly code have .section,.data in it.and when compile it give error,no matter hello world rogram.

program run (nasm)

org 100h mov dx,string mov ah,9 int 21h mov ah,4ch int 21h string db 'hello, world!',0dh,0ah,'$' 

program format dont run

%include  "io.mac" .stack 100h .data number_prompt  db  "please type number (<11 digits): ",0 out_msg        db  "the sum of individual digits is: ",0  .udata number         resb  11  .code         .startup         putstr  number_prompt  ; request input number         getstr  number,11    ; read input number string         nwln         mov     ebx,number   ; ebx = address of number         sub     dx,dx        ; dx = 0 -- dl keeps sum repeat_add:         mov     al,[ebx]     ; move digit al         cmp     al,0         ; if null character         je      done         ;  sum done         ,     al,0fh       ; mask off upper 4 bits         add     dl,al        ; add digit sum         inc     ebx          ; update ebx point next digit         jmp     repeat_add    done:         putstr  out_msg         putint  dx           ; write sum         nwln         .exit 

please books come later format.

the errors encounter because different assemblers use different syntaxes. first program in nasm format; second 1 in masm format.

see wikipedia on asm syntax several examples, , see masm/nasm differences , link mentioned in there tips.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

html - Repeat image to extend header to fill screen -

javascript - Backbone.js getting target attribute -