; FIRST.ASM ; ; A sample of how to include and call routines in the dec_IO.pkg ; The dec_IO.pkg was written by Alan Pinck. ; ; This file may be assembled and linked using the freeware ASM assembler ; and VAL linker available at: ; ; ftp://ftp.algonquincollege.com/pub/infosystems/pincka/dat2343/arrowasm ; ; These are the command lines I used (note the trailing semicolons): ; ; C:> asm /s first ; ; C:> val /co first ; ; ; - Using a semicolon as an argument suppresses all the prompts ; for output files and uses the defaults. (See the documentation.) ; - The /s option to ASM suppresses unnecessary verbosity. ; - The /co option to VAL creates a ".COM" file (instead of a ".EXE") ; ; C:> first ; This is my first Intel ASM program. ; ; 12345 ; 26708 ; 26708 ; C:> ; ; You can examine and trace the resulting executable .COM file using debug: ; ; C:> debug first.com ; -u100 ; 1454:0100 BA2201 MOV DX,0122 ; 1454:0103 B409 MOV AH,09 ; 1454:0105 CD21 INT 21 ; ... etc ... ; ; -IAN! idallen@ncf.ca November 1999 ; ;------------------------------------------------------------------- Ian segment assume CS:Ian,DS:Ian org 100h ; .COM requires this ;------------------------------------------------------------------- start: ; Print a message. ; mov dx,offset msg ; offset address of the message text mov ah,09h ; code for "display ASCII$ string" int 21h ; Note: don't forget the 'h' on 21h! ; Display a number using the I/O package "shownum" procedure. ; (Read the comments in the I/O package to know how to use ; each of the I/O functions.) ; mov ax,12345 ; Note: no 'h' - this number is decimal call shownum ; Load the first two ASCII bytes of msg as if they were a number ; and print the number (in decimal). ; mov bx,offset msg ; load offset address of the message text mov ax,[bx] ; pick up into AX 2 bytes at that address call shownum ; Explicitly set the AX register to be the same two bytes ; and print the number again. See! It's the same! ; mov al,"T" ; first byte in low half of AX mov ah,"h" ; second byte in high half of AX call shownum ; Quit the program (return to the O/S). ; mov al,0h ; load a successful return status mov ah,4Ch ; code for "terminate program" int 21h ;------------------------------------------------------------------- ; I put my data and variables down here. ; Note that labels on data do *NOT* have colons! ; (Labels on program instructions *DO* need colons.) ; msg db "This is my first Intel ASM program." db 0Dh,0Ah ; CR, LF db "$" ; end of ASCII$ string ;------------------------------------------------------------------- include dec_IO.pkg ; include source for Alan's I/O package here Ian ends end start ; "start" is the label on the first instruction