我正在嘗試學習彙編語言,但我必須花費十幾個小時才能在我的英特爾核心i5 win 7筆記本電腦上運行.asm代碼。 問題是大部分彙編代碼的書都有.Section,.Data,當我編譯它時它總是給出錯誤,不管它是hello world rogram。在彙編語言中遇到大問題格式
程序,它運行(NASM)
org 100h
mov dx,string
mov ah,9
int 21h
mov ah,4Ch
int 21h
string db 'Hello, World!',0Dh,0Ah,'$'
程序與此格式不運行
%include "io.mac"
.STACK 100H
.DATA
number_prompt db "Please type a number (<11 digits): ",0
out_msg db "The sum of individual digits is: ",0
.UDATA
number resb 11
.CODE
.STARTUP
PutStr number_prompt ; request an input number
GetStr number,11 ; read input number as a string
nwln
mov EBX,number ; EBX = address of number
sub DX,DX ; DX = 0 -- DL keeps the sum
repeat_add:
mov AL,[EBX] ; move the digit to AL
cmp AL,0 ; if it is the NULL character
je done ; sum is done
and AL,0FH ; mask off the upper 4 bits
add DL,AL ; add the digit to sum
inc EBX ; update EBX to point to next digit
jmp repeat_add
done:
PutStr out_msg
PutInt DX ; write sum
nwln
.EXIT
請幫書本與後來的格式來只。
_「它總是給出錯誤」_。這並沒有告訴我們任何事情。請詳細說明您收到的錯誤。 – Michael