NGASM 8086/8088 Assembler v1.4 Beta 2 - Programmer's Manual



Download
NGASM 8086/8088 Assembler v1.4 Beta 2   Latest Version

NGASM Programmer's Manual - shorter version - as edited by The Hong Kong Polytechnic University

The NGASM 8086/8088 Assembler FREE Programmer's Manual included with NGASM v1.4 Beta 2 contains

  • The 8086/8088 Instruction Set with source code examples / snippets. The Instruction Set is classified into 9 different classes before each Instruction is dealt with. Most Instructions have examples you can assemble and debug to completely understand what they do.

  • An analytical review of Operands of Instructions / Mnemonics so that one never gets confused with the usage of Operands with Instructions / Mnemonics.

  • An analytical review of what unassembled code DEBUG.EXE shows to you as opposed to what conditional jump instructions you write.

  • An analytical review of conditional jump instructions for signed comparison that can put bugs into your program.

  • Two small programs explaining C style calling of a routine and returning from that routine (how you should code the CALL, and code the RETurn in the called routine. And who should clear PUSHed parameters from the Stack).

  • Two small programs explaining Pascal style calling of a routine and returning from that routine (how you should code the CALL, and code the RETurn in the called routine. And who should clear PUSHed parameters from the Stack).

  • A quick guide to using DEBUG.EXE on day one.

  • Using INT 3 for quickly getting to the code section you want to debug.

  • An introduction to Indirect Memory Addressing. That is, using CPU Registers to address memory locations.

  • An introduction to CPU Registers, Flags, and Operand types.

  • Parts of an Assembly Language Program and what one can do.

  • Four Terminate and Stay Resident (TSR) programs which may only run on WINDOWS 98SE and below.

  • ROUTINES.NGA - containing source code of all routines used in the examples is provided as a separate file. Many of the routines are listed below:

    1. DISP_NUM
    2. DISP_BIG_NUM
    3. DISP_SIGNED_NUM
    4. DISP_BIG_SIGNED_NUM
    5. SHOW_REG_AL
    6. SHOW_REG_AX
    7. SHOW_REG_DX_AX
    8. print_null_terminated_string
    9. GET_COMMAND_LINE_PARAMS
    10. NULLString_2_DOSString
    11. DECIMALNUM_2_HEXNUM

  • A routine to simplify calling DOS functions below 36h. For DOS functions below 36h, the carry flag can't be checked to see if the function executed well and didn't return an error.

    INT21h_Funcs_Below_36h   is the routine that simplifies calling these functions. By routing DOS function calls below 36h through this routine, you can check for any returned error by testing the Carry Flag with the JC or the JNC Instruction just as you would with functions 37h and above.

    Routine INT21h_Funcs_Below_36h   is in the MANUAL.DOC - Programmer's Manual - file.



The small program below gets user input values from keyboard, displays the number of input values entered, finds the maximum value out of them and displays the maximum value on screen.

You can change the values for DIGITS [1 (for 1 digit numbers) to 5 (for 5 digit numbers)] and NUMBER_of_INPUT_VALUES (to as many as you want).

Just run it to see what happens.

You can improve upon the code (validate each digit of INPUT value), separate code sections as callable routines, etc. If you do that as an exercise, send us the code.

Someone asked for more help, so here are some step by step description of what the code does:
  1. Displays a prompt
  2. Number of DIGITS to get is initialized in the CX Register
  3. Gets a number (a single character)
  4. Checks if it is not below 30h (=0) and not above 39h (=9)
  5. If it is 0-9, gets saved value from array, multiplies it by 10 (1st time it is nonsense, be prepared for it), subtracts 30h from new value, adds it up and stores the result in the array
  6. Adds back 30h to the same new value, and displays it on screen
  7. Code execution loops back to get the remaining number of DIGITS (to step 3).
  8. Once one value (a set of digits) was got, array pointer in BX gets incremented by 2
  9. COUNT (NUMBER_of_INPUT_VALUES) is decremented to see if specified number of INPUT VALUES have been entered by user. If not, control jumps to (ANOTHER_NUMBER) get another value (to step 1).
  10. Then (putting other things short) the number of INPUT VALUES entered is calculated, stored in TCOUNT, displayed, used in finding the maximum value (MAXIMUM_VAL), and the maximum value is found and displayed. Algorithm for these must be easy to decipher. If you can't decipher, you must trace through the code inside DEBUG.EXE as many times as required.

;This small program finds and displays the maximum of 21 5-digit values entered.

;INPUT can be 5 DIGIT NUMBERS each of WHICH MUST BE LESS THAN 65536 (10000h)

	JMP	MAIN

DIGITS			DB	5  ;1 to 5
NUMBER_of_INPUT_VALUES	EQU	21	;2 to AS MANY AS YOU WANT
COUNT		DB	NUMBER_of_INPUT_VALUES
TCOUNT		DB	NUMBER_of_INPUT_VALUES
DECIMAL_NUMs	DW	NUMBER_of_INPUT_VALUES DUP(0)
ENTER_A_NUM$	DB	'ENTER A NUMBER  ',24H
ENTERED$		DB	' Numbers are entered',13,10,24h
MAXIMUM_VAL$	DB	13,10,'MAXIMUM VALUE = ',24h
MAXIMUM_VAL	DW	0

MAIN:
	MOV	BX,OFFSET DECIMAL_NUMs
ANOTHER_NUMBER:
	MOV	AH,9
	MOV	DX,OFFSET ENTER_A_NUM$
	INT	21H
	XOR	CX,CX
	MOV	CL,DIGITS
ANOTHER_DIGIT:
	MOV	AH,8
	INT	21H
	CMP	AL,30H
	JB	NUMBERS_GOT
	CMP	AL,39H
	JA	NUMBERS_GOT
	PUSH    AX
	MOV	AX,[BX]
	PUSH    CX
	MOV	CX,10
	MUL	CX
	POP	CX
	POP	DX
	XOR	DH,DH
	SUB	DL,30H
	ADD	AX,DX
	MOV	[BX],AX

	MOV	AH,2
	ADD	DL,30H	;DL has the digit
	INT	21H
	LOOP	ANOTHER_DIGIT
DONE:
	ADD	BX,2
	DEC	COUNT
	JZ	NUMBERS_GOT

	CALL	PRINT_CRLF
	JMP	ANOTHER_NUMBER

NUMBERS_GOT:
	MOV	AH,TCOUNT
	MOV	AL,AH
	SUB	AL,COUNT
	SUB	AH,AL
	MOV	TCOUNT,AL
	CALL	PRINT_CRLF
	CALL	PRINT_CRLF
	XOR	AH,AH
	MOV	AL,TCOUNT
	CALL	DISP_NUM
	MOV	AH,9
	MOV	DX,OFFSET ENTERED$
	INT	21H

FIND_MAXIMUM_NUM:
	MOV	AH,9
	MOV	DX,OFFSET MAXIMUM_VAL$
	INT	21H
	
	MOV	SI,OFFSET DECIMAL_NUMs
NEXT_VALUE:
	LODSW
	CMP	MAXIMUM_VAL,AX
	JAE	KEEP
	MOV	MAXIMUM_VAL,AX
KEEP:
	DEC	TCOUNT
	JNZ	NEXT_VALUE	
	MOV	AX,MAXIMUM_VAL
	CALL	DISP_NUM
	CALL	PRINT_CRLF
	INT	20H

INCLUDE ROUTINES.NGA
;-------------------

This tiny routine displays a 16 bit number in Binary format. The number must be in the AX Register before calling DISP_BINARY_NUM.

If you want to test NGASM with binary numbers get NGASM 8086/8088 Assembler V1.4 Beta 2 Latest Version

DISP_BINARY_NUM:
	PUSH	 AX
	MOV	BX,AX
	MOV	CX,16
SIXTEEN_TIMES:
	AND	AX,1
	PUSH	 AX
	MOV	AX,BX
	SHR	AX,1
	MOV	BX,AX
	LOOP	 SIXTEEN_TIMES
	MOV	CX,16
	MOV	AH,2
SIXTEEN_POPs:
	POP	DX
	ADD	DL,30h
	INT	21H
	LOOP	 SIXTEEN_POPs
	MOV	DL,'b'
	INT	21H
	POP	AX
	RET
;-------------------
Note: We have decided against giving any source code from any third party. We think it is against our policy stated in the Indian Assembler page. If we had used other people's code, we would never have developed NGASM 8086/8088 Assembler, however tiny it may be, within 2 years of starting to learn Assembly Language. Sorry for this sudden change of mind.








Home     |     Awards     |     RECOVER Floppy Pro v1.0     |     RECOVER Fixed/Floppy Disk FAT32/16/12 v3.0    | Recover Fixed/Floppy Disk v2.2    |     ANALYZER for RECOVER Floppy Pro v0.3 FREEWARE    |     ANALYZER for RECOVER Fixed/Floppy Disk v0.3 FREEWARE    |     Dealing with Multiple Disk Errors     |     100% Data Recovery - How-to    | Floppy Disk Recovery    |    RFD v1.4  FREEWARE    |    NGASM 8086/8088 Assembler    |    Delete Special    |    Search Zip Rar

Google
Systech Software
G.Namasivayam & G.Gurupandian 16, South Veli Street, Madurai Pin 625001, Tamil Nadu, India
E-Mail:info@www.bestdiskrecovery.com





eXTReMe Tracker
FREE hit counter and Internet traffic statistics from freestats.com