First post, by Guld
Hey everyone, I've recently taken upon myself to go through some of my really old books and learn x86 assembly...for "fun" 😀. In any event, I am following the instructions in "Compute!'s Beginner's Guide to Machine Language on the IBM PC and PCjr". Their very first program just swaps some data around in memory and you are supposed to use the DOS debugger to look at the results.
So, I managed to get MASM to compile and link the program just fine. The executive looks alright, if I look at it in HxD I can see the data in the correct memory locations, etc. and the instructions seem correct. But when I run the program, it never returns back to DOS (Dosbox in this case).
Following the instructions from the book, I've also attempted to get DEBUG working in DOSBox (DOS debug, not DOSBoxes debug).
I tried to run DEBUG.EXE from IBM DOS 5.0, when I do, I never get the debugger '-' prompt, nor does it crash, it just seems to lock up.
I can run DEBUG.COM from IBM DOS 3.3 (by running "ver set 3 30" at the dosbox prompt), however unassembling the code via the 'U' command doesn't look like the correct data, and running the program via 'G' acts like running the program at the command line and doesn't reach normal program termination.
The code is listed below in case maybe I've put something in wrong?
machine = pcjr
all other settings are default I believe.
Any help would be greatly appreciated. If I get time I'll also try running this on my PCjr to see what it does there but I'd like to be able to mess with this under DOSBox just for simplicity sake. Or is there a better DEBUG tool I should be using for old DOS programs which works better? I presume that Visual Studio 2020 will not work with these old assembly programs.
; Reverses an eight byte buffer. DEBUG
; must be used to analyze the results
; This program should work in any
; MS-DOS computer
; Marc Sugiyama 8/15/84
data segment ; segment which holds buffers
source db 1,3,5,7,11,13,17,19 ; source buffer
dest db 0,0,0,0,0,0,0,0 ; empty destination buffer
stack segment stack ; stack segment
dw 128 dup (?) ; give the stack 256 bytes
code segment ; segment for code
switch proc far ; for proper return to DOS
push ds ; set up for FAR RETurn to DOS
mov ax,data ; set up DS for data segment
mov si,0 ; first byte of source data
mov di,15 ; last byte of desination area
mov al,[si] ; move from source to AL
mov [di],al ; move from AL to destination
sub di,1 ; reduce dest pointer by one
add si,1 ; increase source pointer by one
cmp si,8 ; moved all of the bytes?
jne move_bytes ; if not, do more.
ret ; return to DOS
switch endp ; end of procedure declaration
code ends ; end of code segment
end ; end of program