Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

8086 Assembly Programing problem

Status
Not open for further replies.

Lord Loh.

Full Member level 4
Full Member level 4
Joined
Jun 19, 2004
Messages
196
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,296
Location
Texas
Activity points
1,951
I have written a small 8086 programme to display a string on the PC screen using MS DOS interrupts....

I would like to have my string "Hello World !" stored in the data segment...

My assembler a86/nasm demands the datasegment to be defined before the code segment...

The code is generated and when I see the .com file, the string is defined before the code.... And in DEBUG Utility, the string is placed at cs:0100 and the dat a is executed before the code.... I guess that the programming is giving the desired output only by fluke...

Please help....
Code:
.DATA SEGMENT

hm:
 db 'Hello World'
.DATA ENDS

.CODE SEGMENT
mov ax,SEG hm
mov ds,ax
mov si,OFFSET hm
mov cx,0005h
mov ah,02h
writestring:
mov dl,[si]
int 21h
inc si
loop writestring
int 20h
.CODE ENDS

Debug Output
Code:
D:\a86>debug 1.com
-d
0B5B:0100  48 65 6C 6C 6F 20 57 6F-72 6C 64 8C C8 8E D8 BE   Hello World.....
0B5B:0110  00 01 B9 05 00 B4 02 8A-14 CD 21 46 E2 F9 CD 20   ..........!F...
0B5B:0120  75 06 C7 06 7E 01 FF FF-39 3E 80 01 75 05 6A 00   u...~...9>..u.j.
0B5B:0130  E8 0F 12 6B DF 0E 8B B7-2E 4B C1 E6 02 03 36 B4   ...k.....K....6.
0B5B:0140  52 EB 18 8B C6 2B 06 B4-52 C1 F8 02 50 E8 66 A1   R....+..R...P.f.
0B5B:0150  8B 04 C1 E0 02 03 06 B4-52 8B F0 83 3C FF 75 E3   ........R...<.u.
0B5B:0160  6B DF 0E C7 87 2E 4B FF-FF 33 C0 5E 5F C9 C2 02   k.....K..3.^_...
0B5B:0170  00 00 55 8B EC 56 8B 5E-04 6B DB 0E 8D 87 2E 4B   ..U..V.^.k.....K

Unassembled
Code:
-u
0B5B:0100 48            DEC     AX
0B5B:0101 65            DB      65
0B5B:0102 6C            DB      6C
0B5B:0103 6C            DB      6C
0B5B:0104 6F            DB      6F
0B5B:0105 20576F        AND     [BX+6F],DL
0B5B:0108 726C          JB      0176
0B5B:010A 64            DB      64
0B5B:010B 8CC8          MOV     AX,CS
0B5B:010D 8ED8          MOV     DS,AX
0B5B:010F BE0001        MOV     SI,0100
0B5B:0112 B90500        MOV     CX,0005
0B5B:0115 B402          MOV     AH,02
0B5B:0117 8A14          MOV     DL,[SI]
0B5B:0119 CD21          INT     21
0B5B:011B 46            INC     SI
0B5B:011C E2F9          LOOP    0117
0B5B:011E CD20          INT     20
 

hi dear plz reffer book name MAZIDI & MAZIDI u get direct coading of this program i have done it.
 

I guess the Mohd. Ali Mazadi Book is for 8051... I checked google for "Mazadi 8086" and there are no relavent results....
 

Small rewriting:D
Code:
.MODEL SMALL
.STACK
.DATA
hm  label near 
    db 'Hello World'
hm_size = $ - hm  
.CODE 
start:
    mov ax, SEG hm 
    mov ds,ax 
    mov si,OFFSET hm 
    mov cx, hm_size
    mov ah,02h 
writestring: 
    mov dl,[si] 
    int 21h 
    inc si 
    loop writestring 
    int 20h 
end start
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top