|
-
Aug 27th, 2000, 03:15 PM
#1
Thread Starter
Monday Morning Lunatic
Having started to learn asm this morning, I have now created my first application, and I am posting it here so that others can have a slight head start.
This is for the Netwide Assembler (NASM), a free assembler that produces object code for all x86 platforms. I used NASM, and VAL, an experimental linker.
NASM - http://www.web-sites.co.uk/nasm
VAL (requires LHA to unpack) - ftp://x2ftp.oulu.fi/pub/msdos/progra...ng/00index.txt
I made this using the free syntax-coloured editor NasmEdit, free from http://www.inglenook.co.uk/nasmedit/nasmedit.zip
Code:
; Title: Looped Hello World
;==========================================================================================================;
segment code ; Begin code segment
..start: mov ax, data ; Put address of data segment into DS
mov ds, ax ; No data path from memory to DS, so AX used as temporary storage
mov ax, stack ; Stack onto SS
mov ss, ax
mov sp, stacktop ; Top of stack onto SP (stack pointer)
mov cl, 0x31 ; Initialise CL to '1'
startpt: mov dx, hello ; Put address of hello into DX
mov ah, 0x9 ; Set AH to 9 (Output string)
int 0x21 ; DOS Interrupt 21
mov ah, 0x2 ; Set AH to 2 (Output character)
mov dl, cl ; Copy CL to DL
int 0x21 ; DOS Interrupt 21
mov dx, crlf ; Put address of crlf into DX
mov ah, 0x9 ; Set AH to 9 (Output string)
int 0x21 ; DOS Interrupt 21
add cl, 0x1 ; Add 1 to CL
cmp cl, 0x36 ; Compare CL to '5'
je end ; If equal, jump to end
jmp startpt ; Jump back to start
end: mov ax, 0x4c00 ; Set AX to 4c00 (Exit)
int 0x21 ; DOS Interrupt 21
;==========================================================================================================;
segment data ; Begin data segment
hello: db 'Hello World from Mike! This is time: ', '$' ; All DOS strings end in a $ sign.
crlf db 13, 10, '$'
;==========================================================================================================;
segment stack stack ; Begin stack segment
resb 32 ; Reserve 32 bytes on the stack
stacktop: ; Set top of stack
It was originally in hello.asm
I hope this is of help to anyone.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|