flat assembler
Message board for the users of flat assembler.
Index
> DOS > Newbie : DOS program from a book wont run Goto page 1, 2, 3, 4, 5, 6 Next |
Author |
|
CandyMan 10 Oct 2016, 20:51
corrected code:
Code: format MZ entry MainSeg:BEGIN stack 1024 segment MainSeg BEGIN: ;set up pgm ds MOV AX,DataSeg ; place .DATA addr in ax MOV DS,AX ;assign values to bl and bh MOV BL,'A' MOV BH,'B' ;swap registers XCHG BL,BH ;move registers to result area for display MOV [TheBL],BL MOV [TheBH],BH ;print result MOV AH,09H ;display string MOV DX,RSLT ;rslt address must be in dx INT 21H ;a dos interrupter that uses fctn (?) code in ah MOV AH,4Ch INT 21h segment DataSeg ;$ delimiter meaning end of string RSLT DB 0DH, 0AH, ' BL = ' TheBL DB '?',', BH = ' TheBH DB '?','$' ;-------------- _________________ smaller is better |
|||
10 Oct 2016, 20:51 |
|
revolution 11 Oct 2016, 15:11
radarblue: The code you posted appears to be in MASM syntax. And it also appears to be very old DOS code. 64-bit versions of Windows won't be able to run the DOS code unless you install something like DOSBOX or a similar program.
|
|||
11 Oct 2016, 15:11 |
|
radarblue 11 Oct 2016, 15:28
Thanks alot Mr. Candyman, and Mr. Revolution
Still doesnt run, in the FASM editor. Error message : "....\swap_bytes.exe " cannot run due to incompatability with 64-bit versions of windows . When I write the : include 'win64ax.inc' on the top, or include 'win32ax.inc' . Error message : format MZ ( the first line ) There is a compatability failure, it seems . Mr. Revolution, I will try your advice and install the DOSbox and MASM. |
|||
11 Oct 2016, 15:28 |
|
revolution 11 Oct 2016, 18:46
radarblue wrote: Error message : "....\swap_bytes.exe " cannot run due to incompatability with 64-bit versions of windows . radarblue wrote: Mr. Revolution, I will try your advice and install the DOSbox and MASM. BTW, your assumption about "Mr. Revolution" might not be correct. Half of the people on this planet are not Mr. |
|||
11 Oct 2016, 18:46 |
|
edfed 11 Oct 2016, 21:56
lol
|
|||
11 Oct 2016, 21:56 |
|
rugxulo 11 Oct 2016, 23:53
radarblue wrote: I am reading a book called : x86 assembly language and C fundamentals, by J. Cavanagh. I have read the usual basics, and made some small C programs that runs. Now I am on page 200 in the book, and examples proceedes in assembly. And again, equally lost as I were when getting a C program to run, the asm wont run. The book suggests flat assembler. I get errors on every line. Error on capital letters, and error on the "proc far". I'm pretty sure that the book's author is not telling you to use FASM here. MASM is a radically different language. Especially regarding 16-bit DOS (which even MASM has shunned for decades), FASM won't work for linking since it doesn't support OMF output. If you really want to learn MASM, try these links:
All of the high-level stuff is different. The only similarity is raw x86 mnemonics. FASM does not try to support MASM (or TASM or ...) syntax at all (unlike JWasm, which is forked/heavily improved from OpenWatcom's WASM). Most MASM code (for many years) has been Win32/64 only, but it was still popular in DOS days too, so you'll still find old code. I'm also not sure if you're trying to mix C and assembly or not. FASM doesn't really support that for 16-bit DOS (but 32-bit COFF for DJGPP is okay). If you want to mix 16-bit assembly and C, one example is the Calvin editor (Turbo C + A86): calvin23.zip, calsrc23.zip . If you just want to learn 32-bit C and assembly, try reading Dr. Paul Carter's free book (using NASM): http://pacman128.github.io/pcasm/ P.S. I'd honestly recommend VirtualBox (VT-X) + FreeDOS over (slow, limited) DOSBox. |
|||
11 Oct 2016, 23:53 |
|
radarblue 12 Oct 2016, 20:44
Thanks alot. Its boiling over ...
However I want to spend time on it and understand. rugxolo : rugxulo wrote: I'm also not sure if you're trying to mix C and assembly or not. FASM doesn't really support that for 16-bit DOS (but 32-bit COFF for DJGPP is okay). In the book (p209) the Author lists up many assemblers, MASM, NASM, LZASM, NBASM, FASM, codeX assembler, TMA macro assembler, and continues this book uses a "version" of flat assembler. Im not a typical "computer guy", but have caught up an old and deep facination in the recent years. Thank you for the links and support, I will investigate . Checked out : emu8086, and it seems very interesting. And also checked DOSbox with MASM. however I could only load the qeditor in a window, and could not access any "edit" or "debug" from the CMD prom. Althou the code seems decently alike that style, noticably the @data. Question. how can it be that many different assemblers run on the same chipset architecture x86, and some codes just doesnt, like the code I have in the book ? revolution : I am sorry, I was trying to be polite. |
|||
12 Oct 2016, 20:44 |
|
sleepsleep 12 Oct 2016, 22:02
here page 209,
|
|||
12 Oct 2016, 22:02 |
|
Trinitek 13 Oct 2016, 04:43
Quote: Question. how can it be that many different assemblers run on the same chipset architecture x86, and some codes just doesnt, like the code I have in the book ? 1) certain 16-bit opcodes aren't encodable in 64-bit protected mode ("Long mode") 2) Virtual-8086 mode, which Windows uses to run 16-bit executables, isn't accessible when in 64-bit mode. And thus, only 32-bit Windows versions can run 16-bit code. Although, while it isn't technically impossible to step down into a processor mode that can run 16-bit code, the transition would have been too expensive and too much of a hassle to implement. |
|||
13 Oct 2016, 04:43 |
|
revolution 13 Oct 2016, 13:47
Trinitek wrote: Although, while it isn't technically impossible to step down into a processor mode that can run 16-bit code, the transition would have been too expensive and too much of a hassle to implement. |
|||
13 Oct 2016, 13:47 |
|
radarblue 13 Oct 2016, 15:34
ok so it would be safe to say that there is an unique assembler "language" for each processor, and for each bit level, like x86, 16bit, 32bit and 64 bit. and there would also be an individual assembly language for the different chips . Like Amiga motorola 68060, will have its own ASM structure. along with an IBM processor, Intel Processor or AMD. Or flashing or progamming a washing machine logic, traffic lights or a motor controller .
It seems clear that I am onto the Intel x86 16/32bit for starters. I would also presume all the different assemblers have something in common, since the basic theory seems to be more or less uniform. But the Assemblers headers and program structure is different from processor to processor, and bit level to bit level. Last edited by radarblue on 13 Oct 2016, 15:48; edited 2 times in total |
|||
13 Oct 2016, 15:34 |
|
revolution 13 Oct 2016, 15:46
radarblue wrote: ok so it would be safe to say that there is an unique assembler "language" for each processor, and for each bit level, like x86, 16bit, 32bit and 64 bit. and there would also be an individual assembly language for the different chips . |
|||
13 Oct 2016, 15:46 |
|
radarblue 13 Oct 2016, 16:04
The first thing I should do is to obtain a CPU simulator or a real CPU (like the one I have in my own machine) . Then study that CPUs specific instruction set, then apply the assembly programming language via a proper editor.
1. find the target CPU to program . 2. obtain the CPU`s instruction set . 3. apply assembly code to the CPU instruction set, from an editor . I am going to try out the EMU8086 , the .EXE header gives a nice starting point. The emu8086 is related to fasm, so I presum its relevant for the forum, however maybe not in the DOS thread ? Anybody that is familiar with the emu8086 ? |
|||
13 Oct 2016, 16:04 |
|
Trinitek 13 Oct 2016, 19:57
radarblue wrote: The emu8086 is related to fasm, so I presum its relevant for the forum, however maybe not in the DOS thread ? Anybody that is familiar with the emu8086 ? |
|||
13 Oct 2016, 19:57 |
|
radarblue 13 Oct 2016, 20:23
I am very proud ! I managed to get a print !
Using the EMU8086 editor, on a 64bit CPU, no win32bit emulator. Code: .stack .data temp db ? rslt db 0dh, 0ah, "bl = , bh = $" ;dh = cursor position ;ah = linefeed ;$ = string terminator .code proc mov ax,@data mov ds,ax mov bl,'A' mov bh,'B' mov temp,bl mov bl,bh mov bh,temp mov rslt + 7,bl mov rslt + 15,bh mov ah,09h mov dx, offset rslt int 21h endp the error was that the book said : rslt db 0dh, 0ah, 'bl = , bh = $' while the editor tolerated this rslt db 0dh, 0ah, "bl = , bh = $" rugxolo : the link you provided from " the Art of Assembly". Is a mother load of valuable information. C, assembly, logic circuits and BCD. http://www.plantation-productions.com/Webster/www.artofasm.com/DOS/pdfaoa.zip sleepsleep : Thats the book ! Last edited by radarblue on 14 Oct 2016, 14:34; edited 3 times in total |
|||
13 Oct 2016, 20:23 |
|
MrFox 14 Oct 2016, 06:12
Yay! Congrats!
Can you tell us what made you learn specifically DOS-assembler? DOS is a Dead OS, you're never going to run into it on new computers. Windows/Linux/Unix/UEFI or bare metal. No other options, I guess. So, why? |
|||
14 Oct 2016, 06:12 |
|
radarblue 14 Oct 2016, 13:52
Id be happy to. I have always been facinated by computers, but never "engaged", I am typically a "user", audio and graphix. But took an education into classical art. Had to get re-schooled, pay my bills. and went for Electro. Got a job in the high voltage domain.
In the Electro schoolbooks, particularely Automation. We had something called "Ladder programming" PLC and relay coil control, for motors on and off, factory conveyor belts. alert sounds and lights. And I figured it was a great way to finally start to understand the computer. I have always also loved the Amiga. and assembly its something mystical and inspiring about it. Bought the book X86 and C fundamentals. And here I am ! As far as I understand the emu8086 is a 32bit and not a DOS assembler. However, I like to learn from scratch. From the circuits to software. For example Embedded Systems. |
|||
14 Oct 2016, 13:52 |
|
revolution 14 Oct 2016, 14:09
I'd suggest you abandon DOS (and the ugly segment registers) and try some 32-bit code. It will be both more relevant to current computers as they are used today and it doesn't complicate things with a limited selection of address registers or the needless segment register complexities. Plus no need for a VM or emulator, it can run natively.
|
|||
14 Oct 2016, 14:09 |
|
radarblue 14 Oct 2016, 14:47
I see you point revolution. But since I am following this certain book, and it focus on Inline C and asm code. The inlines allow for this particular (DOS...) assembly code. And since I am not familiar with the syntax this is my starting point. All in good time.
|
|||
14 Oct 2016, 14:47 |
|
Goto page 1, 2, 3, 4, 5, 6 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.