without using any Irvine libraries?
If you are using Windows 7 then you can't use interrupts without using a DOS emulator
Interrupt list: http://www.ctyme.com/rbrown.htm
DOS Emulator I use: http://dfendreloaded.sourceforge.net/
You need link16.exe to build this.
.Model small
.Stack 512
.686 ; you can indeed use 32-bit regs
chr$ MACRO any_text:VARARG
LOCAL txtname
.data
txtname db any_text,"$"
.code
EXITM <OFFSET txtname>
ENDM
.Code
_main proc FAR
; set the DS register to DGROUP (will fail with some Masm versions - use ml 6.15 or higher, or JWasm)
mov ax, @DATA
mov ds, ax
; display the message
mov dx, chr$("Nobody here uses Irvine libraries")
mov ah, 9
int 21h
; wait for a key
mov ah, 0
int 16h
; the DOS equivalent to ExitProcess
mov ax, 4C00h
int 21h
_main endp
end _main
.model small, c
.386
.stack
.data
str1 db "Hi, I'm Larry, this is my brother Darryl,",13,10
db "and this is my other brother Darryl.",13,10,0
.code
; -----------------------------------------------
; DOS handles for standard input/output devices.
; -----------------------------------------------
HSTDIN EQU 0
HSTDOUT EQU 1
; -------------------------------------------------------------
; This proc returns the length of the specified
; null-terminated string in AX.
; -------------------------------------------------------------
szlen proc c uses bx npsz:WORD
mov bx, npsz
runLoop:
cmp BYTE PTR [bx], 0 ; Compare bytes until find null
jz @F
inc bx
jmp runLoop
@@:
mov ax, bx ; Calc length and return in AX
sub ax, npsz
ret
szlen endp
; -------------------------------------------------------------
; This proc calls the Write File or Device function to
; output the specified null-terminated string to STDOUT.
; -------------------------------------------------------------
stdout proc c uses ax bx cx dx npsz:WORD
invoke szlen, npsz
mov cx, ax
mov bx, HSTDOUT
mov dx, npsz
mov ah, 40h
int 21h
ret
stdout endp
.startup
invoke stdout, ADDR str1
mov ah, 0
int 16h
.exit
end
Short & crispy:
ml 6.14 with /c
link16.exe with /omf
include \masm32\MasmBasic\Mb16.inc ; inspired by DednDave (http://www.masm32.com/board/index.php?topic=12621.msg97236#msg97236)
Init
mov dx, Chr$("DOS is fun", 13, 10, "isn't it?") ; display the message
mov ah, 9 ; the traditional
int 21h ; way
mov cx, Chr$(13, 10, "More fun") ; display the message
Print cx, 13, 10 ; using the cx register
Print "Real fun", 13, 10 ; the simplest option
Print Str$(123), " is 123", 13, 10
Inkey "bye" ; wait for a key
Exit
end start
Quote from: Gunner on November 26, 2011, 11:53:11 PM
If you are using Windows 7 then you can't use interrupts without using a DOS emulator
Interrupt list: http://www.ctyme.com/rbrown.htm
DOS Emulator I use: http://dfendreloaded.sourceforge.net/
thanx you for link.
Ralf Brown's homepage...
http://www.cs.cmu.edu/~ralf/
New 16-bit macro added above in Mb16a.zip:
Print Str$(123), " is 123", 13, 10
Print Str$(ah), " is ah", 13, 10
Print Str$(cl), " is cl", 13, 10
Quote from: jj2007 on November 26, 2011, 11:56:04 PM
You need link16.exe to build this.
.Model small
.Stack 512
.686 ; you can indeed use 32-bit regs
linker16? I am compiling in 16 bit now a see that this code will switch me to 32 bit?
Quote from: bcddd214 on December 23, 2011, 06:42:26 PM
linker16? I am compiling in 16 bit now a see that this code will switch me to 32 bit?
Yes and no. Watch the 66...
16-bit
15AA:000B B07B MOV AL,7B
15AA:000D B87B00 MOV AX,007B
15AA:0010 66 DB 66
15AA:0011 B87B00 MOV AX,007B
32-bit
00401015 ³? B0 7B mov al, 7B
00401017 ³? 66:B8 7B00 mov ax, 7B
0040101B ³. B8 7B000000 mov eax, 7B
Quote from: MichaelW on November 27, 2011, 09:04:14 AM
[/quote]
my program lost all functionality when trying to implement the 16 bit version
http://pastebin.com/SuZ8XzD1
Quote from: jj2007 on December 23, 2011, 07:02:06 PM
Quote from: bcddd214 on December 23, 2011, 06:42:26 PM
linker16? I am compiling in 16 bit now a see that this code will switch me to 32 bit?
Yes and no. Watch the 66...
16-bit
15AA:000B B07B MOV AL,7B
15AA:000D B87B00 MOV AX,007B
15AA:0010 66 DB 66
15AA:0011 B87B00 MOV AX,007B
32-bit
00401015 ³? B0 7B mov al, 7B
00401017 ³? 66:B8 7B00 mov ax, 7B
0040101B ³. B8 7B000000 mov eax, 7B
I see you are using eax which puts me into 32 bit. I a really trying to stay 16 bit if possible.
i think i almost got it this time but the program hangs??
http://pastebin.com/vm3n1LuP