Hello everyone am new to this site and am new to assembler i have been learning how to program in high level languages so when i see assembler my logic doesnt work. Well i have to write a program that prints the prime numbers from 2 to 255 and i have been having so much trouble doing it so i was wondering if any of you can give me a little bit of help right here is what i wrote which is not working off course since i assume many things that probalby are not allow in assembler well i hope some one can help me and tell me what are the errors and if there is a better way to do it of if some one has already written something similar thanks a lot in advance

.MODEL SMALL
.STACK 100h
.DATA
.CODE

MOV AX, 1d
JMP Increment_Loop

Divide_Loop:
INC BX
DIV BX
CMP AH,0
JZ Increment_Loop
JNZ Compareden_Loop

Compareden_Loop:
MOV AX,CX
DIV 2
CMP AX,BX
MOV AX,CX
JNZ Divide_Loop
JMP Printing_loop

Printing_Loop:
DIV 100
MOV DH,AH
ADD AL,30h
MOV DL,AL
MOV AH,02
INT 21h
MOV AX,DX
DIV 10
MOV DH,AH
ADD AL,30h
MOV DL,AL
MOV AH,2
INT 21h
ADD DH,30h
MOV DL,DH
MOV AH,02
INT 21h
MOV DL, 20h
MOV AH,02
INT 21h
MOV AX, CX

Increment_loop:
INC AX
MOV BX,1d
MOV CX, AX
CMP AX,255
JNZ DIVIDE_Loop

END
Posted on 2004-05-04 12:53:37 by dachivo
Attached is the source of such a program I wrote in DOS more than 10 years ago to be assembled into a .com executable. Have a look at the algorithm and modify memory access as required.

Raymond
Posted on 2004-05-12 10:53:20 by Raymond