Windows Command Line Batch Quiz Primer Tutorial

Windows Command Line Batch Quiz Primer Tutorial

Windows Command Line Batch Quiz Primer Tutorial

Readers who found Assembler Primer Tutorial interesting may well be interested in today’s tutorial where we construct a simple quiz made up of questions suiting a hotkey answer on the Windows command line, written in DOS (or Windows Command Line) Batch.

Ever since Microsoft Windows XP 64 bit operating system, and on, the Windows Command Line (or DOS) has had available to it the extremely useful command …


CHOICE [/C choices] [/N] [/CS] [/T timeout /D choice] [/M text]

… which allows for fairly sophisticated hotkey interactive input functionality. However, we found on the net a really useful link pointing to some clever DOS Batch code possibilities making use of …


DEBUG [[drive:][path]filename [testfile-parameters]]

… facilitating the writing of assembly code to come to the same hotkey capability CHOICE is capable of … but working for 32 bit … should that be your scenario … cute, huh?!

The other cute thing about today’s DOS Batch is its use of …


ping -n 2 127.0.0.1 >nul

… to sleep for two seconds at various times.

So if you are on Windows you could download quiz.bat to try it out. It includes the brilliance of Paul Tomasi’s hotkey functionality Assembler …


@rem ========================================
@rem GETKEY.BAT - Written by Paul Tomasi 2010
@rem
@rem Waits for keypress. Returns key value
@rem ========================================
::---------------------------
:: GETKEY
::---------------------------
:getkey
(
echo a
echo mov ah, 08
echo int 21
echo mov ah, 4c
echo int 21
echo.
echo rcx
echo 08
echo n getkey.com
echo w
echo q
)>script
debug<script>nul
call getkey.com
goto :eof

To read a bit more about Assembler, and the, now, huge history its “story” spans, keep reading below and through to its links. Another topic of interest, if all this interests you, would no doubt be AutoHotKey.


Previous relevant Assembler Primer Tutorial is shown below.

Assembler Primer Tutorial

Assembler Primer Tutorial

Assembler programming is a very early form of software code, dating back as far as 1954, that sits, in the spectrum of computer language sophistication, between computer machine code and the compiled source codes of modern programming languages (which comparatively read like a story … good luck with Assembler stories … gobbleLITTLELESSgook?!), predating BASIC and FORTRAN. The Wikipedia page about compilers puts this in historical perspective “

The first compiler was written by Grace Hopper, in 1952, for the A-0 programming language. The FORTRAN team led by John Backus at IBM is generally credited as having introduced the first complete compiler in 1957.

” Let’s see some information about Assembler, from Wikipedia, below.

An assembly language is a low-level programming language for a computer, or other programmable device, in which there is a very strong (generally one-to-one) correspondence between the language and the architecture’s machine code instructions. Each assembly language is specific to a particular computer architecture, in contrast to most high-level programming languages, which are generally portable across multiple architectures, but require interpreters or compiling.

Assembly language is converted into executable machine code by a utility program referred to as an assembler; the conversion process is referred to as assembly, or assembling the code.

Assembly language uses a mnemonic to represent each low-level machine operation or opcode. Some opcodes require one or more operands as part of the instruction, and most assemblers can take labels and symbols as operands to represent addresses and constants, instead of hard coding them into the program. Macro assemblers include a macroinstruction facility so that assembly language text can be pre-assigned to a name, and that name can be used to insert the text into other code. Many assemblers offer additional mechanisms to facilitate program development, to control the assembly process, and to aid debugging.

The tutorial shows some simple Assembler code in action for a Hello World program after seeing some slides regarding the install of MASM 32bit compiler of Assembler code. Please take care if you go ahead installing MASM 32bit Assembler compiler, and, as mentioned several times with the install, do not proceed if there are even warning messages from the install, or, pretty obviously, if you do not have 32bit Windows as your operating system.

Link to Assembler information … from Wikipedia from which quote above comes.
Link to MASM32 SDK download website here which installs an Assembler compiler for 32bit Windows.
Link to downloadable Assembler programming source code which is word for word from Outputting Hello World in MASM using WIN32 Functions and rename to test.asm

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in eLearning, Operating System, Tutorials and tagged , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *