我正在尝试学习汇编语言,但我必须花费十几个小时才能在我的带有 nasm 的 intel core 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
请提供帮助,因为书籍仅以以后的格式提供。