🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.lang.asm
Article #350

Re: piece of code

#350
From: Krzysztof Marski
Date: Sun, 17 Jan 1999 00:00
40 lines
2046 bytes
I don't think that this is an assembler-type problem (BTW: I use TASM 5.0).
You haven't notice any trial of setting ds (Data Segment register). Before
you can load any value into any register, you should ensure yourself that
ds really points to your data segment. I will give you an example in TASM
(TASM-specific keywords are upcased):

ASSUME cs:_code, ds:_data,ss:_stack

_stack SEGMENT STACK
	dw 512 dup(0)			; Stack size in words (1 word = 2 bytes)
_stack ENDS

_data SEGMENT
	message db 'Hellow!',0dh,0ah,'$'	; Simple & standard beginner's message
	counter db 05h
_data ENDS

_code SEGMENT
	Start:
	mov ax,_data			; --> Here we put _data seg. numb. into ax
	mov ds,ax			; --> Here we put ax into ds

	mov dx,OFFSET message	; Offset of message goes into dx
	mov cx,counter			; Number of repeats in counter reg.

	mov ah,09h			; Function 09h of INT 21h
	Repeat:
		int 21h			; Here we call an interrupt
	loop Repeat			; Loop until cx is 0 (zero)

	mov ax,4c00h			; Here we end program and return to DOS
	int 21h
_code ENDS

END Start				; Start from "Start" label

Always be careful what you set, trace return values of software interrupts,
and everything gonna be fine.

[ k_marski@friko4.onet.pl ]
Technical Details
Message-ID: <77sqbb$aj6$6@winter.news.rcn.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <77l40a$3fp$1@winter.news.rcn.net> <77l4p0$6ku$1@winter.news.rcn.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f7d8d,6f88259792fe2bb6
X-Google-Attributes: gidf7d8d,public
X-Google-Thread: feaef,6f88259792fe2bb6
X-Google-Attributes: gidfeaef,public
X-Google-Thread: 114917,6f88259792fe2bb6
X-Google-Attributes: gid114917,public
From: "Krzysztof Marski" <k_marski@friko4.onet.pl>
Subject: Re: piece of code
Date: 1999/01/17
Message-ID: <77sqbb$aj6$6@winter.news.rcn.net>
X-Deja-AN: 433633490
Approved: <johnfine@erols.com>
References: <77l40a$3fp$1@winter.news.rcn.net> <77l4p0$6ku$1@winter.news.rcn.net>
X-Complaints-To: abuse@rcn.com
X-Trace: kzDcD63SsxVJYGp3OY0pcJm5JxSkLxhc8oVRNkKIyWk=
Organization: TPNET - http://www.tpnet.pl
NNTP-Posting-Date: 17 Jan 1999 13:59:07 GMT
Newsgroups: alt.lang.asm,borland.public.tasm,comp.lang.asm.x86