Article View: alt.lang.asm
Article #318Re: Need some help here...
From: anonymous
Date: Tue, 23 May 2000 00:00
Date: Tue, 23 May 2000 00:00
107 lines
4964 bytes
4964 bytes
On 2000-05-22 ---.m.thie@hetnet.nl.--- said:
>Hello....
>Sorry for multiposting this message, but I realy need some help...
>I'm a newbee to assembly, as you can see later on at the source. In
>that source I just try to write a textbuffer to screen without any
>DOS interrupts. Well, one char is not a problem, but a NULL
>terminated string is.
>I think the problem has something to do with the segments. I did
>create a data-segment and a code-segment, but strangely enough...
>the code-segment isn't familiar with the data-segment.
>I tried putting the data within the data-segment into the
>code-segment and then it works. But I'd realy like to produce
>propper code. I'm using the A86 assembler and it compiles just fine,
>but... Why doesn't it work???
>If anyone could help me...
>Thanks in advance.
>Martijn Thie
>----- CODE BELOW -----
>DATA SEGMENT
>text DB "This is a test!",00h
>DATA ENDS
>CODE SEGMENT
>assume CS:CODE,DS:DATA
>;Set cursor pos.
>mov DH,00h ;Row
>mov DL,00h ;Column
>mov AH,02h ;SetCur command
>int 10h ;Initiate
>;Write the text
>lea BX,text ;Set the pointer to the text
>call Write ;Write the damn thing
>;Wait for keystroke
>mov AH,00h ;Wait for keystroke command
>int 16h ;Initiate
>;End program
>ret
>;*******************************
>;* Write command
>;*******************************
>;
>;input:
>; BX = pointer to NULL terminated string
>;
>;output:
>;
>;uses:
>; AX, BX, CX, DX
>Write:
>mov AL,BYTE[BX] ;Get char to print
>push BX ;Push pointer to stack
>xor BX,BX ;Clear register
>mov CX,01h ;Print char 1 time
>mov AH,0Ah ;Write command
>int 10h ;Initiate
>mov AH,03h ;Get cursor pos command
>int 10h ;Initiate
>inc DL ;Next column
>mov AH,02h ;Set cursor pos command
>int 10h ;Initiate
>pop BX ;Get pointer from stack
>inc BX ;Next char
>cmp BYTE[BX],00h ;Check for end
>jne Write ;Not the end, next char
>ret
>CODE ENDS
You have made a false assumption. You assume that putting the
text string in the code segment is not 'proper.' This is not
true. It is perfectly proper to do this.
One of the nice things about the A86 compiler is that it is not
so convoluted and proprietary as that abominable piece of crud
produced by Mikro$loth.
Even though A86 will accept much of the MA$M-style syntax, A86 is
also very 'forgiving.' In the simple program you have written,
there is NO NEED to have a separate data segment.
Why make things more complicated than necessary?
You code is quite complicated for the relatively simple task you
want to accomplish. If I were coding your program for A86, I would
write it something like this:
code segment ;start of code segment
org 100h ;leave room for base page (.COM file)
jmp start ;go start the program
;
msg db 'This is a test!',0 ;our screen message
;
start:
mov si,offset msg ;point SI to the start of the message
again:
lodsb ;load a byte of the message (in AL)
cmp al,0 ;is the byte our '0' terminator?
je exit ;yes, so we're all done
mov ah,0Eh ;function 14 - write TTY
int 10h ;call ROM BIOS video services
jmp again ;go do it again
exit:
ret ;exit to the Operating System
end
Technical Details
Message-ID:
<sijissubo198@corp.supernews.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<siip08ido1161@corp.supernews.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: feaef,3d80c1f0ef66ac3f X-Google-Attributes: gidfeaef,public X-Google-Thread: f7d8d,3d80c1f0ef66ac3f X-Google-Attributes: gidf7d8d,public X-Google-Thread: 1125f6,3d80c1f0ef66ac3f X-Google-Attributes: gid1125f6,public X-Google-Thread: 114917,3d80c1f0ef66ac3f X-Google-Attributes: gid114917,public X-Google-Thread: 1093da,3d80c1f0ef66ac3f X-Google-Attributes: gid1093da,public X-Google-Thread: 110df7,3d80c1f0ef66ac3f X-Google-Attributes: gid110df7,public From: anonymous@bogus_address.con Subject: Re: Need some help here... Date: 2000/05/23 Message-ID: <sijissubo198@corp.supernews.com> X-Deja-AN: 626073822 Approved: ccrayne@pacific.net (comp.lang.asm.x86) References: <siip08ido1161@corp.supernews.com> Organization: Posted via Supernews, http://www.supernews.com X-Track: 1-1: 40 (peer crosschecked as: q.seanet.com [199.181.164.16]) id QQiqhz11072 for <comp-lang-asm-x86@moderators.isc.org>; Mon, 22 May 2000 19:49:29 GMT Newsgroups: alt.lang.asm,alt.os.assembly,borland.public.tasm,comp.lang.asm,comp.lang.asm.x86,microsoft.public.masm X-Complaints-To: newsabuse@supernews.com