|
-
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
-
Oct 22nd, 2000, 11:18 AM
#2
Fanatic Member
I know it probably worked for everybody else, but it's one of those weeks for me: nothing works. I get:
segment name 'code' not recognised
segment name 'data' not recognised
segment name 'stack' not recognised
AND
I changed ..start to .start, and it doesn't complain about ..start any more.
Help would be most appreciated.
Thanks,
Moi.
-
Oct 22nd, 2000, 12:22 PM
#3
What are you using to compile?
-
Oct 25th, 2000, 12:05 PM
#4
Fanatic Member
I'm not doing this for the Post Count ...
PLEASE? I haven't compiled/made a Single ASM program because none of the compilers WORK (NASM, TASM3.1 Shareware version, MASM32 etc.)
There's gotta be something wrong.
-
Oct 29th, 2000, 05:24 PM
#5
Member
Someone might get mad at me for this, but DOS debug does work.
-
Nov 5th, 2000, 06:03 AM
#6
what is object code? is that the same as lowest-level machine code or it is higher, like pseudo code?
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
|