Don't rush to run it... Maybe someone has already run it and found that a black window flashes and then nothing happens. This is normal. Please don't think that NASM is broken.
Open this window (see the picture below↓)
1: Click "View",
2: Uncheck the option [Hide known file extensions].
3: Click the "Apply" button at the bottom of the window.
4: Click the "OK" button again.
Then look at the files in your computer. The file names all show the extensions. Please familiarize yourself with the extensions first. Be careful when changing the file names in the future. Changing the wrong extension will cause the file type to be lost (of course, if you remember the extension, you can change it back)! [page]
OK, open Notepad and create a new text file. Save it and you will get a file with the extension TXT. Change the extension to ASM!
Have you finished changing it? What? You said the icon is different from mine? That's normal, please don't mind it....
Well, ASM files are assembly code files used to write assembly code. You can edit it with Notepad. Of course, you can also find a special assembly code editing tool (this is why the icon after I changed the extension is different from yours, the special assembly code editor has its own icon!), but I think Notepad is enough for beginners, and special editing tools will dazzle you!
OK, open it with Notepad and write the following code:
ORG 0100H; This line of code has not been mentioned before, but will be mentioned later!
MOV AX,0B800H
MOV BX,AX
MOV CX,BX
MOV DX,CX
OK, save the code to a file.
Next, we compile it and create a text file again. We still need to change the extension. Change it to BAT (see the figure below↓):
Use Notepad to write the following syntax:
NASM "code file name. extension" -o "file name to be generated. extension"
Note the spaces!
Example:
NASM "New text document.ASM" -o "1.COM"
After writing, save and unzip NASM to the same folder:
Double-click to run the BAT file. If you have done all the previous steps correctly, you will find an extra COM file. Don't rush to run it! This is what your code is compiled from! Did you know that Debug can also debug compiled programs? Let's debug it with Debug. Create a BAT file again and use Notepad to write the content according to the following syntax:
DeBug The file name and extension to be debugged
Note: There is a space in front of the file name, and the file name itself cannot have spaces!
Example:
DeBug 1.COM
After running, the Debug window will appear. Enter the R command and look at the first line of code:
You may have been shocked to find that the first line of code is not the first line of the code: ORG 0100H, but the second line MOV AX,0B800H
In fact, the reason is this:
The ORG is not actually an assembly instruction. It is a flag that tells the compiler where this code may be loaded into memory in the future (please note the offset address of the MOV instruction in Debug, yes, it is 0100H!)
Note: This 0100H is not set by the ORG pseudo-instruction! (In fact, the CPU does not have it at all. The instructions specifically given to the compiler are called pseudo-instructions.) ORG just tells NASM that this code will be loaded into 0100H so that NASM can prepare it (you will know this later)
OK, let's try running it: T command, it works, B800 is put into AX, and then AX is copied into BX.
Previous article:Chapter 7 NASM Usage Tutorial (X86 Assembly Tutorial)
Next article:Chapter 5 Hands-on Operation - Use of DEBUG 1 (X86 Assembly Tutorial)
Recommended ReadingLatest update time:2024-11-16 15:19
- Popular Resources
- Popular amplifiers
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Learning PLC is easy - PLC ladder diagram and statement table with pictures (Li Changjun, Zhou Hua)
- How to read electrical control circuit diagrams (Classic best-selling books on electronics and electrical engineering) (Zheng Fengyi)
- Single-chip microcomputer C language programming and simulation
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- EEWORLD University - How to draw a high-end PCB ruler with Altium20
- Agitek case sharing - Metrology and testing demonstration case of automotive electronic modules
- How to turn off MPLAB XIDE's code optimization function
- IoT Smart Parking Solutions
- EPWM1 A and B pulses are not complementary
- Find the parameters of the low-pass filter
- Bone vibration sensor and high-quality voice calls (including working principles)
- Millimeter wave sensors
- New Year's flavor competition, post photos during the New Year to win gifts~~
- C language function interrupt function