Skip to main content
GameDev.net gamedev.net
🔒 Locked

Assembly issues

Started by HalfReal Dec 9, 2004 at 3:27 PM 9 replies 1.7k views
Original Post
HalfReal
HalfReal
Hello, I am having issues with a program in assembler. Heres the source code: page 60,132 TITLE SHELL (EXE) (Ryan Harris) 12/01/04 ;---------------------------------------------------- STACK SEGMENT PARA STACK 'Stack' DW 32 Dup(0) STACK ENDS ;---------------------------------------------------- DSEG SEGMENT PARA 'Data' ENT DB 'Enter your','$' FIR DB 'first name: ','$' LAS DB 'last name: ','$' BYR DB 'birth year: ','$' BLANK DB 0AH, 0DH, '$' FNAME DB 15 DUP(' ') LNAME DB 15 DUP(' ') YEAR DB 6 DUP(' ') FCODE DB 00H DBG DB 00H, '$' PARLIST LABEL BYTE STRNG DB 15 DUP(' ') RL DB ? MAX DB 15 BCODE DB 00H DSEG ENDS ;---------------------------------------------------- ;---------------------------------------------------- CSEG SEGMENT PARA 'Code' MAIN PROC FAR ASSUME SS:STACK,DS:DSEG,CS:CSEG MOV AX,DSEG MOV DS,AX ;---------------------------------------------------- ;PROMPT FOR AND DISPLAY FIRSTNAME ;---------------------------------------------------- MOV AH, 09H MOV DX, OFFSET BLANK INT 21H MOV DX, OFFSET ENT INT 21H MOV DX, OFFSET FIR INT 21H ;---------------------------------------------------- ;GET AND SAVE FIRSTNAME ;---------------------------------------------------- MOV AH, 0AH MOV DX, OFFSET PARLIST INT 21H MOV CH, 00H MOV CL, RL MOV DX, OFFSET FNAME CALL CPY ;---------------------------------------------------- ;PROMPT FOR AND DISPLAY LASTNAME ;---------------------------------------------------- MOV AH, 09H MOV DX, OFFSET BLANK INT 21H MOV DX, OFFSET ENT INT 21H MOV DX, OFFSET LAS INT 21H ;---------------------------------------------------- ;GET AND SAVE LASTNAME ;---------------------------------------------------- MOV AH, 0AH MOV DX, OFFSET PARLIST INT 21H MOV CH, 00H MOV CL, RL MOV DX, OFFSET LNAME CALL CPY ;---------------------------------------------------- ;DISPLAY AND PROMPT YEAR OF BIRTH ;---------------------------------------------------- MOV AH, 09H MOV DX, OFFSET BLANK INT 21H MOV DX, OFFSET ENT INT 21H MOV DX,OFFSET BYR ;---------------------------------------------------- ;GET AND SAVE YEAR OF BIRTH ;---------------------------------------------------- MOV AH, 0AH MOV DX, OFFSET PARLIST INT 21H MOV CX, 0004H MOV DX, OFFSET YEAR CALL CPY ;---------------------------------------------------- ;DISPLAY PROMPT ;---------------------------------------------------- MOV AH, 09H MOV DX, OFFSET BLANK INT 21H MOVE DL, FCODE ;***********ERROR MOV DBG, DL MOV DX, OFFSET DBG INT 21H MOV DX, OFFSET BLANK INT 21H MOV DX, OFFSET YEAR INT 21H MOV DX,OFFSET BLANK INT 21H MOV AX, 4C00H INT 21H MAIN ENDP ;---------------------------------------------------- ;STRING PROCEDURE ;---------------------------------------------------- CPY PROC NEAR MOV SI, OFFSET STRNG MOV DI, DX START: MOV BX, [SI] MOV [DI], BX INC DI INC SI LOOP START MOV BX, '$' MOV [DI], BX MOV BX, DX ADD BL, RL MOV DX, BX MOV BL, ' ' MOV [DI], BL RET CPY ENDP CSEG ENDS END MAIN Cant stomp this error, been workin at it for over an hour. Any help will be apprectiated. This program asks for user input for fir and last name and dob then displays the info
oakskc
oakskc
I'm not clear on what the error is, outside of the line marked 'ERROR'.
Ra
Ra
Shouldn't "MOVE" be "MOV"?
Ra
HalfReal
HalfReal
wow I missed that silly typo for that long!!!!!!!

How Embarrasing
HalfReal
HalfReal
Finally it runs, but the proggy shuts down after I insert Firtname when prompted. Assembler makes me cry
Richy2k
Richy2k
Thats why i stopped programming in assembly, kept making mistakes like "MOVE", I think we've all done it, even simple stuff like DC instead of DX (yeah, im an idiot..). The error messages never seemed very helpful in asm either.
khalligan
khalligan
Did you try downloading Borlands Tubo Debugger (td.exe), its a really old program from pre - 486 days. It lets you step through your code like you would in visual studio and place watches.

get it at http://www.micosyen.com/asm.php

if that dont work have a try on google.
technomancer
technomancer
Quote:
Original post by Richy2k
Thats why i stopped programming in assembly, kept making mistakes like "MOVE", I think we've all done it, even simple stuff like DC instead of DX (yeah, im an idiot..). The error messages never seemed very helpful in asm either.


know what you mean i came from a 68000 assembler backgroud (AMIGA) and Move was its mov very confusing when doing x86 asm there was also the fact that the source and dest registers changed all that little and big endian stuff, i decided to switch to C/C++, much less spelling errors ... not :)
Skizz
Skizz
The buffer you're passing to DOS Function 0ah has the following specification:
ds:dx + 0 = working size of buffer (maximum length of input)
ds:dx + 1 = number of bytes in buffer (current length of input)
ds:dx + 2 = start of input string
So, you need to alther the PARLIST declaration:
PARLIST LABEL BYTEDB 17, 0STRNG DB 15 DUP(' ') 

Without the buffer definition bytes, you had effectively a 32 byte buffer but only allocated 15 bytes to store the data in.

Skizz
oakskc
oakskc
Quote:
Original post by Skizz
ds:dx + 1 = number of bytes in buffer (current length of input)
ds:dx + 2 = start of input string
So, you need to alther the PARLIST declaration:
PARLIST LABEL BYTEDB 17, 0STRNG DB 15 DUP(' ') 

Without the buffer definition bytes, you had effectively a 32 byte buffer but only allocated 15 bytes to store the data in.

Skizz


I have to disagree with a small detail here. I think the "DB 17, 0" should be "DB 15, 0" because he only has 15 bytes that the buffer can hold. Granted, it won't be an issue if the name is <= 15 chars, but the tactic is sound.
izzo
izzo
What assembler are you using? It looks like masm or tasm.. Try nasm, it is very good and has meaningful error messages, decent documentation, and a clean syntax.

cheers
sam.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.