There are millions of tutorials about how to program an 8086 microconputer in assembly but none of them explains how to get the program file to the memory? I assume i have to get the hex file to the memory but how? Where do I get a programmer?
you code in assembly language, and you assemble the assembly language to binary code with the assembler.
Yep, that was a lot of usage of the word "assemb..."
Wiki can get you: http://en.wikipedia.org/wiki/List_of_assemblers a list of all 80x86 cpus... personally I would choose GAS and use a tutorial for that.
Maybe you want to have a look at "Programming from the Ground UP" (PGU) which uses gas and can be read online here http://download.savannah.gnu.org/releases/pgubook/ (google gave me the link)
Related
I am reading a Go tutorial (The Way To Go), and it mentions something about assembly routine, can somebody please explain what is that? It also states about implemented 'outside' Go, and also no body... may I know what is the purpose?
Quote as follow:
To declarer[sic] a function implemented outside Go, such as an assembly routine, you simply give the name and signature, and no body:
func flushICache(begin, end uintptr) // implemented externally
I tried to search online, but it seems hard to find any tutorial regarding assembly routine, what is that alien? And, what is the meaning of implemented outside Go?
Please read this and follow the links there.
To cite it
Machine code or machine language is a set of instructions executed
directly by a computer's central processing unit (CPU). Each
instruction performs a very specific task, such as a load, a jump, or
an ALU operation on a unit of data in a CPU register or memory.
<…>
All practical programs today are written in higher-level languages or
assembly language.
The Go's own reference doc on its support for assembler is this.
I would like to get a feel of how computers originally worked. I know initially with computers such as ENIAC, they physically had to plug in wires in the correct order to make their programs execute. They later used punch cards and finally then came up with assembly language(s). It just build upward from there with FORTRAN, COBOL, etc. Is there any way I am compile 0s and 1s on my computer. If I open textedit, and type in a specific sequence of zeroes and ones, then is how can I make that a binary file and not a text with a sequence of ASCII characters? I am open to any method. (Disclaimer: I know doing things in binary takes forever, I just want to learn how to very basic things.)
The easiest way to do this is to start with an assembler of your choice, in an IDE if you like. Use some sort of debugger (such as an IDE) so you can see the effect of your code without also having to write to console or file.
Rather than writing only binary as text digits, write a complete assembler source using data elements instead of instructions.
So, instead of
.code
main proc
mov eax,5
add eax,6
main endp
end main
you could write:
main proc
db 10111000b, 00000101b, 00000000b, 00000000b, 00000000b
db 10000011b, 11000000b, 00000110b
main endp
end main
db means define byte and the b suffix means binary.
And, with this, you'd be all set up to cheat, but I won't tell you how until you ask so I don't spoil the fun for you.
Here is a good tutorial for getting started on Windows with MASM and Visual Studio 2015.
The way to create a binary data stream depends heavily on its purpose.
Binary data itself is not much of magic. You can take any hex-editor and start typing the desired binary input.
But this is not how computers are programmed nowadays. If you really want to go to the lowest level, you can have a look on assembly programming, which basically allows you to tell your machine the exact instructions it should execute in a more handy way.
But even here you won't have much fun. If you want to be able to actually execute your programs and see some results on your display or perhaps even things like keyboard input, the code would grow really large and hard to write and understand for humans.
This is why we use compilers. Compilers generate such code from a high level language and eliminate the need to write the smallest instruction blocks over and over again.
If you really just want to understand how computers work in principle, download some emulator for a simple CPU (perhaps with a nice GUI)
and play around with it. Edumips is one of those emulators for educational purpose.
I truly apologize if my question is too amateurish or has been asked before (I searched and couldn't find anything).
I am working on a big project with a PIC MCU (MPLAB), I picked up where someone else stopped and he has no documentation of his code, it's horrible to look at.
The main problem is that I can't find any records online for functions that appear on the code (i.e rdft, I know it performs FFT but I want to know more about parameters structure etc.).
Is there a good online source for library function for PIC?
Or am I missing something and it's pure C written for embedded systems?
Thanks for your help.
Amir
With the provided information I cannot help with your particular code.
But answering your question:
Is there a good online source for library function for PIC?
Yes there is you can find it in http://www.microchip.com/doclisting/SoftwareLib.aspx
Where it includes several libraries including some to preform FFT's.
Or am I missing something and it's pure C written for embedded systems?
Well the IC provides several peripherals for different functionalities (SPI,I2C,ADC's, etc..) some IC's also include DSP's where one can implement FFT's making use of dedicated hardware on the IC's.
In the Software Lib's from Microchip you can find several libraries that provide an abstraction layer to access such hardware.
Well it's not easy to answer your questions, but when I program some C-Code in MPLAB X, I have no libraries, for the MCU. Well I program some 8-Bit MCUs like the PIC18F4550 or the PIC18F46K20, etc... But you can use some standard libraries like math.h, strings.h or so to implement. But the rest like an I2C-Port or an RS232-Port I write by my self in small functions. For the 8-Bit MCUs, there are practically no libraries available from Microchip themselves, at least what I know. :-)
My tip for you: Tell us which Microcontroller it is (if it is an 8-Bit or so) and take a look at the data sheet of it. Also, you could make a copy on your desktop of the Code and try to clean it up (with tabs), that it looks readable to you.
Well I don't know how else I could help you. :-)
I'm trying to decompress a data file that was originally compressed with an extension for AMOS Pro, the old Amiga BASIC language, that shipped with the AMOS Pro compiler. I've still got the programming language and have access to the compressor and decompressor, but I'm trying to decompress the files using C. I ultimately want to be able to view these files on modern hardware without having to resort to using an Amiga emulator first.
However, there's no documentation as to how the compressor worked, so I'm trying to reverse-engineer it solely from watching its behaviour. Here's what I've got so far.
This is a raw file (ASCII):
AABCDEFGHIJKLMNOPQRSTUVWXYZAABCDEFGHIJKLMNOPQRSTUVWXYZAABCDEFGHIJKLMNOPQRSTUVWXYZ
Here's the compressed version (hex):
D802C6B5
05048584
4544C5C4
2524A5A4
6564E5E4
15149594
5554D5D4
3534B591
00000007
AD763363
00000051
Testing with various files has given me to a few insights:
The last 4 bytes are the size of the original file.
The file seems to function as a bit stream, so byte boundaries aren't important (I say this because I've seen ASCII codes appear in a few files and they aren't aligned to byte boundaries).
All of the bits in the file are stored in reverse.
The first 4 byte seems to represent a sequence length. In the above example, the value 0xD8 is 11011000 in binary; mirror it (bits are in reverse) and you'll get 00011011, which is 0x1B in hex or 27 in decimal. That matches the sequence length.
However, I'm not making any more progress. Does this look like a standard compression algorithm? What do I try next?
As you've posted here, the compression function is called "squash", a function part of AMOS Pro.
As such, my advice would be to try one of the following lines of attack:
Reverse engineer the algorithm by analyzing its output: This is definitely not a viable option. You will only waste time.
Read, annotate, understand the source code of the unsquash function in AMOS Pro
Contact the author of AMOS Pro
Read the source code
The source code for AMOS Pro is apparently in the public domain now and can be found here:
http://www.pianetaamiga.it/downloads/AMOSPro_Sources.zip
It consists of 68000 assembly code and quite a few compiled object files.
The unsquash function can be found in the file +header.s on line 1061 and onwards. It is not documented, except for its entry register values, which is good at least. It doesn't appear to be a very large function so this might be worth a shot.
You will need to have, or obtain/learn, rudimentary 68000 machine code. It does not appear to call out to system libraries or anything and only seem to operate directly on memory, which would suggest this is actually doable (ie. understanding the code). Still, I've never written or read 68000 code in my life so what do I know.
Contact the author of AMOS Pro
The author of AMOS Pro is François Lionet, as is evident by the User Guide, he founded Clickteam in the mid-90s to make game- and multimedia-making software. He still seems to be situated in that company and according to forum posts from others looking into AMOS Pro he seems to be willing to answer email. Sadly I don't know his email but the Clickteam website above should give you a starting point.
I have a question about how to store the assembly language in memory, when I compile the C-code in assembly, and run by "step", I can see the address of each instruction, but is there a way to change the start address of the code in the memory?
Second question is, can I break the assembly code into two?
That is, how to store the two parts in separate memory sections?
is there a way to do that?
I am curious about how the machine store the assembly code.
I am working on a MACBOOK Pro, duo core.
For the first question, can we change the offset value? or the linker and loader can not be controlled by the user? I am a litter confuse with your answer, it seems that we can not change it?
For the second question, I think what you are talking about is "input section", even if your have many ".text" input sections in your codes, after being assembled, they will become one ".text" "output section".
And the output section is the actual code stored in memory.
And I am wondering if I can control its position.
I am using the knowledge of DSP assembly, I think the mechanisms are same.
I'm not completely following either of your questions, but I'll guess.
For the first one, you're asking how to change where the executable is positioned in memory? ELF files have a preferred offset that the linker will try to use first, but the loader is usually free to position the sections anywhere if the base offset isn't available. If the image is non-relocatable and the preferred offset is unavailable, the loader will fail and the program won't run
As for your second question, you want to modify the assembly so code will be in different sections? How to do that depends on the assembler you're using; in gas you use the section pseudo-op:
.section new-section-name
The code following that directive will be in the specified section