Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can someone help me with this simple code?

Status
Not open for further replies.

Exlover81

Programmer
Sep 7, 2002
2
US
I'm a newbie to assembly language. I am trying to write an experimental program that would display "What's Up?!" in reverse. Any advice/suggestions is greatly appreciated.
Below is my code:
Thanks in advance,



title Reversal (hi.asm)

dosseg

.model small

.stack 100h

.data
msg db 'What Up?!',0Ah,0Dh,'$'
len dw $-msg-3

.code

main proc
mov ax,@data
mov ds,ax

mov ax,0900h
mov dx,offset msg
int 21h

L1: push bx
inc bx
loop L1

mov cx,len

L2: pop dx
mov dx,ax
mov ah,02h
int 21h
loop L2

mov ax,4C00h
int 21h
main endp
end main
 
main proc
mov ax,@data
mov ds,ax

mov ax,0900h
mov dx,offset msg
int 21h

;push message onto stack
mov cx,msglen
mov bx,offset msg
mov al,[bx]
L1: push ax
inc bx
loop L1

;get message off stack in reverse
mov cx,len
L2: pop dx ;should be AX ????
mov dx,ax ;WHY THIS????
mov ah,02h ;correct function to print charactor????
int 21h
loop L2

mov ax,4C00h
int 21h
main endp
end main
"There are 10 types of people in this world, those who know binary and those who don't!"
 
move label to correct position!

;push message onto stack
mov cx,msglen
mov bx,offset msg
L1: mov al,[bx]
push ax
inc bx
loop L1

oh, by the way this program will never print "What's Up?!" because your string value is incorrect. :)
"There are 10 types of people in this world, those who know binary and those who don't!"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top