Geeks With Blogs
Mark Pearl

 

If you are new to NASM like me – you might find the following code snippets useful just to get started… (this is targeted to the Windows environment, it may be different in Linux)

Printing the number 6 character to the console… the value in the ah register changes to 02h and you mov the message to dl

org 0x100
bits 16
jmp main

displayCharacter:
mov ah,2h
int 21h
ret

main:
mov dl,36h
call displayCharacter
int 20h

Printing a string to the console…. the value in the ah register changes to 09h and you mov the message to dx

org 0x100
bits 16
jmp main

message: db 'example text'

displayString:
mov ah,09h
int 21h
ret

main:
mov dx,message
call displayString
int 20h

Posted on Thursday, March 1, 2012 7:23 AM UNISA COS 2621 Computer Organization | Back to top


Comments on this post: NASM – writing to the console

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © MarkPearl | Powered by: GeeksWithBlogs.net