Linked List in ASM - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Linked List in ASM

nitsakhnitsakh Posts: 1Member
I want to write a simple linked list program with ASM .
Here's the code which I have tried to write(presently only for single digit numbers) ! However,it works only for 3 numbers and that too has sometimes some errors. I am new to assembly language.
So please help me as to what I am supposed to do,as I am in fix !


[code].model small

.data
m1 db 10,13,'Enter Data :: $'
m2 db 10,13,'Continue ?? $'
head dw 0
.code
mov ax,@data
mov ds,ax

mov bx,1
mov ah,48h
int 21h

mov head,ax

mov dx,offset m1
mov ah,09h
int 21h
mov ah,01h
int 21h
xor ah,ah
mov bx,head
mov [bx],ax
mov di,head

mov dx,offset m2
mov ah,09h
int 21h
mov ah,01h
int 21h
cmp al,'y'
je loop1
cmp al,'Y'
je loop1
jmp below

loop1:
mov bx,1
mov ah,48h
int 21h

xor si,si
mov [di+2],ax
xor di,di
mov si,ax
mov dx,offset m1
mov ah,09h
int 21h
mov ah,01h
int 21h
xor ah,ah
mov word ptr [si],ax
mov di,si

mov dx,offset m2
mov ah,09h
int 21h
mov ah,01h
int 21h
cmp al,'y'
je loop1
cmp al,'Y'
je loop1

below:
mov word ptr [di+2],0

disp:
mov ah,02h
mov dx,10
int 21h
mov dx,13
int 21h
mov bx,head
mov ah,02h
mov dx,[bx]
int 21h

lp:
mov ah,02h
add bx,2
mov dx,word ptr [bx]
int 21h
cmp word ptr [bx+2],0
jnz lp

exit:
mov ah,4ch
int 21h

end[/code]
Sign In or Register to comment.