;A program to display the message, "ASSEMBLY LANGUAGE PROGRAM" on the screen.
;MODEL MEDIUM
;STACK
Datasg SEGMENT; Beginning of data segment
message DB "ASSEMBLY LANGUAGE PROGRAMMING"

Datasg ENDs; End of data segment
Dispsg SEGMENT; Beginning of code segment
ASSUME CS:Dispsg, DS:Datasg
ORG 100h
john: MOV AH,09h; 9 is function value to display string
MOV BX,Datasg; Initialise the start segment
MOV DS, BX
LEA BX,message; Load effective address in BX register
INT 21h
MOV AH,4ch
Dispsg ENDs
END start

Please can somebody help me correct this code because am a newbie, the code is not displaying what it suppose to display.

Regards
Paul

Recommended Answers

All 26 Replies

Isn't DOS printing suppose to have a '$' terminator?

Oh yes.
message DB 'ASSEMBLY LANGUAGE PROGRAMMING$'

DS:DX            ; is string pointer.

String must end with '$'

i TRIED IT AND IT DOESNT DIPLAY THE MESSAGE
IS THERE ANY ERROR ON THE CODE.

CAN SOMEBODY HELP ME DEBUG IT.

THANKS

commented: Stop YELLING at us, and learn how to use code tags while you're at it -7

Is the ;model medium and ;stack supposed to be commented out.
pls can any one help me re-write that script to display
"assembly language program" on the screen.

regards
paul

Are you using

DS:DX

you were using BX which is wrong.

Post your current code again!

;A program to display the message, "ASSEMBLY LANGUAGE PROGRAM" on the screen.
MODEL MEDIUM
STACK 21H
Datasg SEGMENT; Beginning of data segment
message DB 'ASSEMBLY LANGUAGE PROGRAMMING:$'

Datasg ENDs; End of data segment
Dispsg SEGMENT; Beginning of code segment
ASSUME CS:Dispsg, DS:Datasg
ORG 100h
john: MOV AH,09h; 9 is function value to display string
MOV BX,Datasg; Initialise the start segment
MOV DS,DX
LEA BX,message; Load effective address in BX register
INT 21h
MOV AH,4ch
Dispsg ENDs
END start

Hi Wildgoose,
Thank you so much for all your support, I am a new in assembly language and am very eager to know it because it is one of my major in my course.
But, this assignment is very crucial to me because it carries 30 mark, and I have to submit it tomorrow. Please if you can help me make it work , I will appreciate so much.
One thing again, am using an IDE software called emu8086. when I ran it, it doesnt display output automatically, i have to click on screen button, but then is oesnt show anything. just blank black screen.

Am suspecting this area of code segment as where the problem lies:
1. MODEM MEDIUM
2. STACK
3. ASSUME CS: Dispsg, DS: Datasg
4. MOV DS, BX
5.LEA DS, message


Actually, the second question of this assignment requests that after the first one works, that I should rewrite the program using a function value of INT 21h.

please am very grateful so far for urgent attention you gave for this my codes to make sure it works.

Thanks so much as I wait for your reply.
Paulnewman

DX DX DX DX DX !!!!!

Message is     DS:DX
NOT BX!!!!

You mean the following lines:

MOV DS,BX
LEA DX,message;

Gotta make a late night grocery run but here's your original code tweaked....

...I'm not sure about if it will work because you may need OFFSET or someother specifier for setting the DX register.

Datasg SEGMENT; Beginning of data segment
message DB "ASSEMBLY LANGUAGE PROGRAMMING$"
Datasg ENDs; End of data segment

Dispsg SEGMENT; Beginning of code segment
ASSUME CSispsg, DSatasg
ORG 100h

john: MOV AH,09h; 9 is function value to display string
         MOV BX,Datasg; Initialise the start segment
         MOV DS, BX
         LEA DX,message; Load effective address in DX register
         INT 21h

         MOV AH,4ch 

         Dispsg ENDs
END start

I haven't used DOS for years.

But if it doesn't work then try variations like

mov DX,OFFSET message
mov DX,DS:offset message
etc.

I will also appreciate if you can offer any explanation to any of the question, especially (1.) and (3.)


1. describe what happens when a processor is interrupted and how it resumes its operations after servicing the interrupting devices.


2. Describe the functions of the following register, SP,IP,CCR,CS,DS,SS,ES.

3. Compare the status indicator of 8086 processor and MC6800 processor.

Regards
Paulnewman

Thanks so much Wildgoose,

I tried the whole code you posted but it didn't work, but am suspecting this line:
ASSUME CSispsg, DSatasg

is it right?

I will try to be online with you while at my work place when you'll be back.

Thanks
Paul

It's been many years since I've worked with just REAL mode on the 80x86 family. I typically work with the 32/64-bit Protected Mode, though I do work with other processors.

Intel vs Motorola
Little Endian vs Big Endian
You can download the manuals and review status registers on your own. If you think about it, there should be a degree of overlap.
Results of comparisons
Carry
Sign
Zero
Interrupt
etc.


If interrupts are enabled an IRQ Interrupt Request or NMI Non-Maskable Interrupt occurs for various reasons. UART just received a byte. Keyboard key just pressed. Floating-Point chip had an exception, etc. On the 80x86 there is a priority system for interrupts. One kind of interrupt can have a higher priority then another. Interrupt occurs and the IP (Instruction Pointer) is vectored to the Interrupt address stored at the Interrupt table. The interrupt code typically saves the registers, does its processing, such as storing the incoming byte, etc. then restores the registers and returns from interrupt. A return from interrupt is similar to a call return but the interrupt is re-enabled. RET vs RTI

You really need to read this stuff out of the technical manuals. There is a book I like written by James Leiterman, "80x86 Assembly Language Architecture" (pg.42 - 47). He also has another "Vector Game Math Processors" that discusses all of this.

On the 8086 16-bit processor you have Segment Registers, General Purpose Registers, and index registers.
Segment Registers:
CS: Code Segment
DS: Data Segment
ES: Extra Segment
SS: Stack Segment
Index Registers
SI Source Index Default pair DS:[SI]
DI Destination Index Default pair ES:[DI]
SP Stack Pointer Default pair SS:[SP]
BP Base Pointer
General Purpose Registers
AX AL, AH
BX BL, BH
CX CL, CH
DX DL, DH

There are other special purpose registers.
CCR Condition Code Register

32 bit (Are similar but Extended)
CS Code Selector
DS Data Selector
ES Data Selector
FS Data
GS Data
SS Stack

EAX AX AH AL
EBX BX BH BL
ECX CX CH CL
EDX DX DH DL

ESI SI
EDI DI

64-bit are very complex
RAX EAX AX AH AL

And ABUNCH OF OTHERS All 64-bit!

Hi Thanks so much for ur help.

Then on the script, can you run it see you are getting same thing as mine.

or check if there are any error on the code in the ASSUME section.

Regards
Paul

I'm sorry I can't I don't even have an old DOS computer anymore. Not for years, and XP prevents thunking down into the Real Mode layer from Protected mode.

I still have MASM laying around however.

How are you building testing your code?

Hi Wildgoose,
Thanks

I am using emu8086 to run it. I have attached the file and emu8086 for you to help me test it on ur side as is not displaying the output for me.

Thanks
Paulnewman

[TEX];A program to display the message, "ASSEMBLY LANGUAGE PROGRAM" on the screen.
;MODEL MEDIUM
;STACK
Datasg SEGMENT; Beginning of data segment
message DB "ASSEMBLY LANGUAGE PROGRAMMING$"

Datasg ENDs; End of data segment
Dispsg SEGMENT; Beginning of code segment
ASSUME CS:Dispsg,DS: Datasg
ORG 100h
john: MOV AH,09h; 9 is function value to display string
MOV BX,Datasg; Initialise the start segment
MOV DS, BX
LEA DX,message; Load effective address in BX register
INT 21h
MOV AH,4ch
Dispsg ENDs
END start
[/TEX]

Still battling to get this code work.

Can you give me your skipe id or yahoomessenger id, so that we can interactively get this code work.

I wanted to attach the file but it wasn;t accepting it.

Thanks
Paulnewman

You aren't working with a real system. You're using that emulator. I downloaded and am not happy with it, but it ran the code.
It starts by assigning the data segment to the code segment. Doesn't appear to use segment labelling? It correctly handled the offset for the data segment when I tagged .CODE vs .DATA but to the data segment. However since I haven't seen where the emulator automatically displaces the data segment then that's a problem, since DS = CS and segment labels seems to be a problem.

It also inserted a jump around the data when I had data at the top of the function. But didn't compensate for the data offset.

So I dumbed down your code. Assume CS and DS are the same.
Put all data at bottom of file below code.

Works fine.

org 100h   
    push cs         ; Make sure Data Segment shares Code Segment.
    pop   ds

    mov ah,9
    mov dx,offset message
    int 21h
    
    mov ah,4ch
Datasg SEGMENT

message DB "ASSEMBLY LANGUAGE PROGRAMMING$"

Datasg ENDS

Dispsg SEGMENT
ASSUME CS:Dispsg, DS: Datasg
;ORG 100h                      ;you only need org 100h with .COM files,
                                      ; and they can have only one segment
john: MOV AH,09h
MOV BX,Datasg
MOV DS, BX
LEA DX,message
INT 21h
MOV AH,4ch                      ;4ch is a DOS function like 09h
int 21h                              ;so it needs an int 21h after it

Dispsg ENDs

END john                           ;this label should indicate where the
                                         ;code starts executing

Yep, I forgot that little tid bit about .COM files. One segment files.
In the olden days we ran EXE2BIN converters to build .com files.

I will also appreciate if you can offer any explanation to any of the question, especially (1.) and (3.)

1. describe what happens when a processor is interrupted and how it resumes its operations after servicing the interrupting devices.

An interrupt can occur when a hardware device sends a signal to the processors intr pin, or if software uses an int instruction. In either case, the processor uses the interrupt number as an index into a look up table. From that table it retrieves the address where the appropriate interrupt procedure can be found in memory. It then starts executing the code it finds there until it reaches an iret instruction, at which point it goes back to what it was doing when the interrupt occured.

2. Describe the functions of the following register, SP,IP,CCR,CS,DS,SS,ES.

sp points to the next free location on the stack. When you use an instruction like push ax, the processor decrements the value in the sp register by two, and then stores the value of ax at that location. If you pop bx (say) the processor retrieves the value located wherever sp is pointing, and then increments sp by two. The retrieved value would in this case be stored in the bx register.

There are various cr registers. cr0, cr1, cr2, cr3, and more in the latest processors. In what is known as protected mode, by loading values into these registers the operating system can control the operation of the processor. (cr stands for control register).

The processor gets the address of the next instruction to be executed by multiplying the contents of cs by 16, and adding the value in the ip register (ip stands for instruction pointer).

The processor evaluates an expression like ds:[bx] by multiplying the ds register by 16, and adding the value in bx. Similarly for es:[bx].

The current location on the stack is got by multiplying ss by 16, and adding the value in the sp register.

I will ever remain grateful to this forum especially my thanks to Wildgoose and Mathematician.

The code by mathematician work fine and am very :)

I will be more happy than any person on earth if you also help with No:3. Compare the status indicator of 8086 processor and MC6800 processor.

Thanks very much
Paul Newman :)

Hi Wildgoose,

is CCR correct or is it just CR.
Also, what is the difference between 8086 and MC6800 processor.

Thanks
Paul Newman

Hi Wildgoose,

is CCR correct or is it just CR.
Also, what is the difference between 8086 and MC6800 processor.

Thanks
Paul Newman

I have never heard of a ccr register, and you won't need to worry about the cr registers unless you are going to write an operating system.

I have never used a system based upon the MC6800 processor, but computers based upon it will soon be a rarity in any case. Even Apple has gone over to 8086 based processors.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.