8086 microprocessor sample program

Status
Not open for further replies.

usern

Newbie level 5
Joined
Sep 25, 2010
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,322
anyone has a sample program that prints out 'hello world' using masm? thanks
 

.model small
.data

msg db 'hello$'

.code

mov ax,@data ;the ds is set to datasegment
mov ds,ax
mov dx,offset msg ;ofset of buffer is stored in dx
mov ah,09h ;write string terminated with $
int21h
mov ah,4ch ;exit to dos
int 21h
end
 

**broken link removed**

for windows
; requires /coff switch on 6.15 and earlier versions
.386
.model small,c
.stack 100h

.data
msg db "Hello World!",0

.code
includelib MSVCRT
extrn printf:near
extrn exit:near

public main
main proc
push offset msg
call printf
push 0
call exit
main endp

end main

for dos:
.model small
.stack 100h

.data
msg db 'Hello, world!$'

.code
start:
mov ah, 09h ; Display the message
lea dx, msg
int 21h
mov ax, 4C00h ; Terminate the executable
int 21h

end start
 

thanks.. i will try that
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…