Assembly Arithmetic Algorithms
Preface
Introduction
- Required Knowledge
- Low Level
- Why DOS?
- Online Example Programs
Chapter 1: The First Program
- Assemble with FASM
- Assemble with NASM
- Disassembling the Program
- The General Purpose Registers
- Interrupt Information
Chapter 2: The putstring Function
Chapter 3: The intstr and putint functions
Chapter 4: Chastity’s Intel Assembly Reference
- mov
- add
- sub
- mul
- div
- cmp
- jmp
- push/pop
- Take it slow
Chapter 5: Integer Sequences and Their Application in Learning
- Fibonacci numbers
- Powers of 2
- Prime Numbers
- How to use these examples
Chapter 6: The strint Function
- The Program
- The Function
- The Output
Chapter 7: Translating Assembly to Other Programming Languages
- main.asm
- chastelib16.asm
- Assembly Test Suite Output
- main.c (The C Test Suite)
- chastelib.h (The C chastelib library)
- Portable Assembly Language
Chapter 8: Going from DOS to Linux or Windows
- main.asm (32 bit)
- main.asm 64 bit
- main.s (GNU Assembler 64 bit)
Chapter 9: Bitwise Operations for Advanced Nerds
- The Bitwise Operations
- Example 0: Fake Add
- Example 1: Fake Sub
Chapter 10: chastehex: Not just a program, but a philosophy.
- chex.asm
- chex.com
Chapter Z: More Documentation
Appendix of System Calls for DOS
- (Table 01680) Values for DOS extended error code: —-DOS 2.0+ —- 00h (0) no error 01h (1) function number invalid 02h (2) file not found 03h (3) path not found 04h (4) too many open files (no handles available) 05h (5) access denied 06h (6) invalid handle 07h (7) memory control block destroyed 08h (8) insufficient memory 09h (9) memory block address invalid 0Ah (10) environment invalid (usually >32K in length) 0Bh (11) format invalid 0Ch (12) access code invalid 0Dh (13) data invalid 0Eh (14) reserved 0Eh (14) (PTS-DOS 6.51+, S/DOS 1.0+) fixup overflow 0Fh (15) invalid drive 10h (16) attempted to remove current directory 11h (17) not same device 12h (18) no more files —-DOS 3.0+ (INT 24 errors)—- 13h (19) disk write-protected 14h (20) unknown unit 15h (21) drive not ready 16h (22) unknown command 17h (23) data error (CRC) 18h (24) bad request structure length 19h (25) seek error 1Ah (26) unknown media type (non-DOS disk) 1Bh (27) sector not found 1Ch (28) printer out of paper 1Dh (29) write fault 1Eh (30) read fault 1Fh (31) general failure 20h (32) sharing violation 21h (33) lock violation 22h (34) disk change invalid (ES:DI -> media ID structure)(see #01681) 23h (35) FCB unavailable 23h (35) (PTS-DOS 6.51+, S/DOS 1.0+) bad FAT 24h (36) sharing buffer overflow 25h (37) (DOS 4.0+) code page mismatch 26h (38) (DOS 4.0+) cannot complete file operation (EOF / out of input) 27h (39) (DOS 4.0+) insufficient disk space 28h-31h reserved —-OEM network errors (INT 24)—- 32h (50) network request not supported 33h (51) remote computer not listening 34h (52) duplicate name on network 35h (53) network name not found 36h (54) network busy 37h (55) network device no longer exists 38h (56) network BIOS command limit exceeded 39h (57) network adapter hardware error 3Ah (58) incorrect response from network 3Bh (59) unexpected network error 3Ch (60) incompatible remote adapter 3Dh (61) print queue full 3Eh (62) queue not full 3Fh (63) not enough space to print file 40h (64) network name was deleted 41h (65) network: Access denied (DOS 3.0+ [maybe 3.3+???]) codepage switching not possible (see also INT 21/AX=6602h,INT 2F/AX=AD42h) 42h (66) network device type incorrect 43h (67) network name not found 44h (68) network name limit exceeded 45h (69) network BIOS session limit exceeded 46h (70) temporarily paused 47h (71) network request not accepted 48h (72) network print/disk redirection paused 49h (73) network software not installed (LANtastic) invalid network version 4Ah (74) unexpected adapter close (LANtastic) account expired 4Bh (75) (LANtastic) password expired 4Ch (76) (LANtastic) login attempt invalid at this time 4Dh (77) (LANtastic v3+) disk limit exceeded on network node 4Eh (78) (LANtastic v3+) not logged in to network node 4Fh (79) reserved —-end of errors reportable via INT 24—- 50h (80) file exists 51h (81) (undoc) duplicated FCB 52h (82) cannot make directory 53h (83) fail on INT 24h —-network-related errors (non-INT 24)—- 54h (84) (DOS 3.3+) too many redirections / out of structures 55h (85) (DOS 3.3+) duplicate redirection / already assigned 56h (86) (DOS 3.3+) invalid password 57h (87) (DOS 3.3+) invalid parameter 58h (88) (DOS 3.3+) network write fault 59h (89) (DOS 4.0+) function not supported on network / no process slots available 5Ah (90) (DOS 4.0+) required system component not installed / not frozen 5Bh (91) (DOS 4.0+,NetWare4) timer server table overflowed 5Ch (92) (DOS 4.0+,NetWare4) duplicate in timer service table 5Dh (93) (DOS 4.0+,NetWare4) no items to work on 5Fh (95) (DOS 4.0+,NetWare4) interrupted / invalid system call 64h (100) (MSCDEX) unknown error 64h (100) (DOS 4.0+,NetWare4) open semaphore limit exceeded 65h (101) (MSCDEX) not ready 65h (101) (DOS 4.0+,NetWare4) exclusive semaphore is already owned 66h (102) (MSCDEX) EMS memory no longer valid 66h (102) (DOS 4.0+,NetWare4) semaphore was set when close attempted 67h (103) (MSCDEX) not High Sierra or ISO-9660 format 67h (103) (DOS 4.0+,NetWare4) too many exclusive semaphore requests 68h (104) (MSCDEX) door open 68h (104) (DOS 4.0+,NetWare4) operation invalid from interrupt handler 69h (105) (DOS 4.0+,NetWare4) semaphore owner died 6Ah (106) (DOS 4.0+,NetWare4) semaphore limit exceeded 6Bh (107) (DOS 4.0+,NetWare4) insert drive B: disk into A: / disk changed 6Ch (108) (DOS 4.0+,NetWare4) drive locked by another process 6Dh (109) (DOS 4.0+,NetWare4) broken pipe 6Eh (110) (DOS 5.0+,NetWare4) pipe open/create failed 6Fh (111) (DOS 5.0+,NetWare4) pipe buffer overflowed 70h (112) (DOS 5.0+,NetWare4) disk full 71h (113) (DOS 5.0+,NetWare4) no more search handles 72h (114) (DOS 5.0+,NetWare4) invalid target handle for dup2 73h (115) (DOS 5.0+,NetWare4) bad user virtual address / protection violation 74h (116) (DOS 5.0+) VIOKBD request 74h (116) (NetWare4) error on console I/O 75h (117) (DOS 5.0+,NetWare4) unknown category code for IOCTL 76h (118) (DOS 5.0+,NetWare4) invalid value for verify flag 77h (119) (DOS 5.0+,NetWare4) level four driver not found by DOS IOCTL 78h (120) (DOS 5.0+,NetWare4) invalid / unimplemented function number 79h (121) (DOS 5.0+,NetWare4) semaphore timeout 7Ah (122) (DOS 5.0+,NetWare4) buffer too small to hold return data 7Bh (123) (DOS 5.0+,NetWare4) invalid character or bad file-system name 7Ch (124) (DOS 5.0+,NetWare4) unimplemented information level 7Dh (125) (DOS 5.0+,NetWare4) no volume label found 7Eh (126) (DOS 5.0+,NetWare4) module handle not found 7Fh (127) (DOS 5.0+,NetWare4) procedure address not found 80h (128) (DOS 5.0+,NetWare4) CWait found no children 81h (129) (DOS 5.0+,NetWare4) CWait children still running 82h (130) (DOS 5.0+,NetWare4) invalid operation for direct disk-access handle 83h (131) (DOS 5.0+,NetWare4) attempted seek to negative offset 84h (132) (DOS 5.0+,NetWare4) attempted to seek on device or pipe —-JOIN/SUBST errors—- 85h (133) (DOS 5.0+,NetWare4) drive already has JOINed drives 86h (134) (DOS 5.0+,NetWare4) drive is already JOINed 87h (135) (DOS 5.0+,NetWare4) drive is already SUBSTed 88h (136) (DOS 5.0+,NetWare4) can not delete drive which is not JOINed 89h (137) (DOS 5.0+,NetWare4) can not delete drive which is not SUBSTed 8Ah (138) (DOS 5.0+,NetWare4) can not JOIN to a JOINed drive 8Bh (139) (DOS 5.0+,NetWare4) can not SUBST to a SUBSTed drive 8Ch (140) (DOS 5.0+,NetWare4) can not JOIN to a SUBSTed drive 8Dh (141) (DOS 5.0+,NetWare4) can not SUBST to a JOINed drive 8Eh (142) (DOS 5.0+,NetWare4) drive is busy 8Fh (143) (DOS 5.0+,NetWare4) can not JOIN/SUBST to same drive 90h (144) (DOS 5.0+,NetWare4) directory must not be root directory 91h (145) (DOS 5.0+,NetWare4) can only JOIN to empty directory 92h (146) (DOS 5.0+,NetWare4) path is already in use for SUBST 93h (147) (DOS 5.0+,NetWare4) path is already in use for JOIN 94h (148) (DOS 5.0+,NetWare4) path is in use by another process 95h (149) (DOS 5.0+,NetWare4) directory previously SUBSTituted 96h (150) (DOS 5.0+,NetWare4) system trace error 97h (151) (DOS 5.0+,NetWare4) invalid event count for DosMuxSemWait 98h (152) (DOS 5.0+,NetWare4) too many waiting on mutex 99h (153) (DOS 5.0+,NetWare4) invalid list format 9Ah (154) (DOS 5.0+,NetWare4) volume label too large 9Bh (155) (DOS 5.0+,NetWare4) unable to create another TCB 9Ch (156) (DOS 5.0+,NetWare4) signal refused 9Dh (157) (DOS 5.0+,NetWare4) segment discarded 9Eh (158) (DOS 5.0+,NetWare4) segment not locked 9Fh (159) (DOS 5.0+,NetWare4) invalid thread-ID address