Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Errors from a simple hello program

Status
Not open for further replies.

rjwilldohisbest

Technical User
Jun 2, 2001
79
US
Hello

I have been to an online tutorial and wrote in what I saw there for a hello program. I'm using the windows Emu8086/8088 assembler.

Here is an example of the code:

.386P
Locals
jumps

.Model Flat, StdCall
mb_ok equ 0 ; value goes to 0
hWnd equ 0 ; Windows handle
lpText equ offset text ; Sets pointer to text
lpCaption equ offset caption ; Sets pointer to
; caption

; Declaration of API functions

extrn ExitProcess :pROC ; Procedure to shut down
extrn MessageBoxA :pROC ; Procedure to show
; message box

; Data begins here

.Data
text db "Windows 32 bit power!!, 13, 10
; First row of text with wordwrap
db "Reimport ini file to window.",0
; Second row of text, terminated with 0

caption db "Runs in the GUI Subsystem", 0
; Caption string, 0-terminated

; Code starts here

.Code
Main:

push mb_ok
push lpCaption
push lpText
push hWnd
call MessageBoxA
CALL ExitProcess

END MAIN


Heres what the reasons are for not compiling:

(2) Unknown command: .386P
or not enough parameters.
(3) Unknown command: Locals
or not enough parameters.
(4) Unknown command: jumps
or not enough parameters.
(6) Unknown command: .Model Flat, StdCall
or not enough parameters.
(15) Unknown command: extrn ExitProcess :pROC
or not enough parameters.
(16) Unknown command: extrn MessageBoxA :pROC
or not enough parameters.
(21) Unknown command: .Data
or not enough parameters.
(32) Unknown command: .Code
or not enough parameters.
(35) Not supported: PUSH 0 ; value goes to 0
(36) Not supported: PUSH offset caption ; Sets pointer to
(37) Not supported: PUSH offset text ; Sets pointer to text
(38) Not supported: PUSH 0 ; Windows handle
(39) Not supported: CALL MessageBoxA
(40) Not supported: CALL ExitProcess


If anyone knows what is happening please let me know.
Thanks for your time.

RJ
 
hi,

emu8086 looks like it doesnt support 386 and greater hence "emu8086". maybe you could find another assembler. NASM, TASM etc are good "FREE" assemblers.

.8086 directive is like the opposite to .386p

maybe emu8086 is stuck in this mode.

but first check to see if "IDEAL MODE" has been enabled. Ideal mode make the assembler directives much easier and free to use and it looks like some of your directive require this.

example:
.code ;is ideal mode for:-

code segment "code" uses32
assume cs:code,ds:code,es:code,fs:code,gs:code
{your program here}
code ends
end

One thing I always notice about tutorials and examples is that to get them to work they always end up different. It is probably due to the author was using a different assembler and although assembly code is pretty much the same all assemblers differ.

I would read the emu manual or help file and it will explain how the directives are used.
"People who have nothing to say, say it too loud and have little knowledge. It's the quiet ones you need to worry about!"
 
Hi straiph

Just went to a nasm site. I'm not sure what to download? There are sources, binaries, and other packages.

According to the instructions this 8086 emu uses MASAM syntax and appears to be compatible with a 386, I recall something about 286's wouldn't be supported or anything under it will not support when I was at their site. The only options is for changing font and text appearence and no changes for the envirnoment itself. The program looks interesting though. It can save in exe, com, bin, etc and has a hex editor along with it. As a newbie I am not clear on how to use these tools but I assume they are great tools to have

I had downloaded MASM and I get errors when compiling this same source file, the dos box opens up and something about a resource file couldn't be opened? I don't know if this resource file has to be written by hand or if the program writes this file on it's own?

I'm only doing a hello program, lol.
Well, I'll keep working on it. I like being challenged with computer things, keeps my mind occupied and me out of trouble.

Thanks.

RJ
 
The following is a code snipet from an example program.
it didnt work at first (assemble under TASM) because I had to change a push & pop command. i actually dont know if it works but it gave me enough information to complete the task at hand.
the best way to learn is by looking at examples, reading manuals and lots and lots and lots and lots of patience.
there are a few manuals in the FAQ under technical references. Manual 2 gives full opcode usage etc.
i dont know about the resource file error.
the downloads you have installed must have come with some examples.

; Flat Real/Real Big mode (v1.2)

code segment public

assume cs:code

public FLAT_install, FLAT_destall

FLAT_install proc ; Installs FLAT_tsr

pushf ; Check for NT-flat (only on 386+)
pushf
pop ax
xor ah,40h
push ax
popf
pushf
pop bx
popf
cmp ah,bh
jne no_NT
.386p ; SMSW is a priviledged instruction(?)
smsw ax ; Check for real mode
.386
test al,1
jnz short V86
pushf ; Save flags & DS register
push ds
cli
xor eax,eax ; Get IRQ5 vector & Set FLAT_tsr
mov ds,ax
mov ebx,ds:[34h]
mov cs:eek:ld_IRQ5,ebx
mov word ptr ds:[34h],offset FLAT_tsr
mov ax,cs
mov ds:[36h],ax
shl eax,4 ; Build Global Descriptor Table
add dword ptr cs:GDT[2],eax
pop ds ; Restore DS register & flags
popf
ret

no_NT: mov ah,09h ; Write message
mov dx,offset no_NT_msg
push cs
pop ds
int 21h
mov ax,4C01h ; Terminate with error code 1
int 21h

no_NT_msg db 'This program requires at least an i386sx!',10,'$'

V86: mov ah,09h ; Write message
mov dx,offset V86_msg
push cs
pop ds
int 21h
mov ax,4C02h ; Terminate with error code 2
int 21h

V86_msg db 'Cannot run in a virtual environment!',10,'$'

FLAT_install endp

FLAT_destall proc ; Destalls FLAT_tsr

push ds ; Save DS register
xor ax,ax ; Restore old IRQ5 vector
mov ds,ax
mov eax,cs:eek:ld_IRQ5
mov ds:[34h],eax
pop ds ; Restore DS register
ret

FLAT_destall endp

align 8
GDT dw 15 ; Limit (16 bytes)
dw offset GDT,0 ; Offset within current segment...
dw ? ; Unused

FLAT_desc dw 0ffffh ; Limit (bit 0..15)
db ?,?,? ; Base (bit 0..23)
db 92h ; Access rights
db 0cfh ; Page granularity + Limit(16..19)
db ? ; Base (bit 24..31)

FLAT_sel equ FLAT_desc - GDT


old_IRQ5 dd 0
last_Exc_13 dd 0
IRQ5_flag db 0

FLAT_tsr proc

test cs:IRQ5_flag,1 ; Exception within IRQ5 handler?
jnz short Exc_13
push ax ; Ask PIC if IRQ5 is 'IN-SERVICE'
mov al,0Bh
out 20h,al
jmp $+2
in al,20h
test al,20h
pop ax
jz short Exc_13

IRQ5: mov cs:IRQ5_flag,1 ; Call old IRQ5 handler
pushf
call dword ptr cs:eek:ld_IRQ5
mov cs:IRQ5_flag,0
iret

Exc_13: push eax ; Save accumulator

mov eax,ss:esp[4] ; Get address of SOE
cmp eax,cs:last_Exc_13 ; Same as last time?
je short SOE
mov cs:last_Exc_13,eax
.386p
lgdt qword ptr cs:GDT ; Load GDT Register

push gs fs es ds bx ; Save registers

mov eax,CR0
or al,1 ; Enter Protected mode
mov CR0,eax

jmp $+2 ; Flush instruction decode queue

mov bx,FLAT_sel ; Load 4Gb limits
mov ds,bx
mov es,bx
mov fs,bx
mov gs,bx

and al,not 1 ; Back to Real mode
mov CR0,eax
.386
pop bx ds es fs gs ; Restore registers
pop eax ; Restore accumulator
iret ; Done

SOE: call FLAT_destall ; Remove FLAT_tsr
mov ah,0fh ; Clear screen
int 10h
mov ah,00h
int 10h
mov ah,09h ; Write message
mov dx,offset SOE_msg
push cs
pop ds
int 21h
mov ax,4C0Dh ; Terminate with error code 13
int 21h

SOE_msg db 'Segment Overrun Exception!',10,'$'

FLAT_tsr endp

code ends
end
"People who have nothing to say, say it too loud and have little knowledge. It's the quiet ones you need to worry about!"
 
This file produced 119 errors(unknown commands) in Emu 8086

Masm only complained about missing expressions, three errors

Blasm reported 52 errors, many of them specfying illegal use of certain commands, like mov, jump, etc and errors regarding commands that do not exist?

I will look at the examples that came with the program. I was hoping to find starting tutorials though. The examples work and are fine, but the examples get right into it to soon. Most of the commands I do not know and would like sort of a step by step walk-through with exercises to do. I need something basic and where I can work from the ground up. Also it would mean more to me to do things by hand and get that accomplished feeling.

I like being challenged and this is a challenge, especially when these compilers are throwing different results from the same source files from each of the programs. This is just as bad as web browser compatibilities discerning html diffeently, lol.

I'll look at the examples and keep working on these problems.

Thanks

RJ
 
well, emu8086 is a very basic compiler just for Intel's 8086
microprocessor. What's good about emu8086 that it's a 8086 microprocessor emulator, thus:

it is extremely helpful
for those who just begin to study assembly
language. It compiles the source code
and executes it on emulator step by step.

Visual interface is very easy to work with.
You can watch registers, flags and memory while
your program executes.

Arithmetic & Logical Unit (ALU) shows the
internal work of the central processor
unit (CPU).

Emulator runs programs on a Virtual PC,
this completely blocks your program from accessing
real hardware, such as hard-drives and memory,
since your assembly code runs on a virtual machine,
this makes debugging much easier.

8086 machine code is fully compatible with all next
generations of Intel's micro-processors, including
Pentium II and Pentium 4, I'm sure Pentium 5 will
support 8086 as well. This makes 8086 code very
portable, since it runs both on ancient and on
the modern computer systems. Another advantage
of 8086 instruction set is that it is much smaller,
and thus easier to learn.

search for "emu8086" at for more info...
 
That's the problem nowadays - different compilers now have different ways of declaring stuff. NASM, FASM, MASM, TASM are all totally different in the way they expect assembly sources. It appears that the code you posted is TASM dialect. MASM will complain a wee bit, but since it's TASM ideal it's only a wee bit. NASM and FASM are worse - their assumptions are totally different with respect to labels, and converting MASM code to NASM or FASM can be an exercise in patience.

I would suggest that you stick to one assembler that you would expect to use for most of your life, and learn it. Then learn the other dialects. "Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top