WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Sponsors
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
Hard Drive Recovery
Wiring your own LAN
Personal menu
Welcome Guest
User:
Pass:
Register!
Resend Validation Email
 
Forum
 

Help to understand this line of code please, cad1 db 31,?,31 dup (?)

rovama
Quote Post


New Member
*

Group: Members
Posts: 3
Member No.: 38977
Joined: 27-October 10


Hello everybody smile.gif

I've started to remember assembly language again, because I'm trying to help a friend with a program. Can someone explain me this line of code please:

cad1 db 31,?,31 dup (?)

I know it's declaring an array of type byte (db). And I could understand that line if it was like this:

cad1 db 31 dup (?)

but the other way I don't unsure.gif , why are the 31,?, before the 31 dup(?)


rolleyes.gif
PMEmail Poster
Top
shoorick
Quote Post


Extremely Active Member
******

Group: Admins
Posts: 2303
Member No.: 160
Joined: 22-June 04


db 31 - placing the byte 31 (1Fh)
db ? - reserving place for the byte (usually =0, but it is not guaranted)
db 31 dup (?) - reserving place for 31 bytes
PMEmail PosterUsers Website
Top
rovama
Quote Post


New Member
*

Group: Members
Posts: 3
Member No.: 38977
Joined: 27-October 10


Hey shoorick, thanks for your answer. Now I understand the reason of that line...

cad1 db 31,?,31 dup (?)

Because later on the program there is this code:
lea DX, cad1
mov AH, 0Ah
int 21h

And according to int 21h and AH = 0Ah:

"Buffered Keyboard Input: This function reads a line of text from the keyboard and stores it into the input buffer pointed at by ds:dx. The first byte of the buffer must contain a count between one and 255 that contains the maximum number of
allowable characters in the input buffer. This routine stores the actual number of characters read in the second byte
. The actual input characters begin at the third byte of the buffer. "

So that's the reason of the first 31 (They are defining the maximun numbers of characteres of cad1 = 31)

And the ? (it's undefined because it's the second byte and it will contain the actual number of characters read by the keyboard)

Am I right ? smile.gif

PMEmail Poster
Top
Slider
Quote Post


Extremely Active Member
******

Group: Moderators
Posts: 287
Member No.: 5004
Joined: 11-May 07


Here is some code to help explain the answer you are looking for.


.data

orig_name db 140 dup(?)
new_name db 128 dup(?)

.code
begin:
mov ax,@data
mov ds,ax
mov es,ax ; need this for function 7156h

mov dx, offset prompt
mov ah,9
int 21h

mov orig_name,128 ; max characters in input
lea dx,orig_name ; get filename
mov ah,0ch ; flush keyboard buffer
mov al,0ah ; buffered keyboard input
int 21h
PMEmail Poster
Top
rovama
Quote Post


New Member
*

Group: Members
Posts: 3
Member No.: 38977
Joined: 27-October 10


Thanks Slider. I will check this code and get back to you asap smile.gif
PMEmail Poster
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll

 

Sponsors
Computer Science

Internet
C/C++
Hardware & PC maintenance

HiEditor

General Discussions
Suggestions/Bug Reports
WinAsm Studio

General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming

Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules

Announcements

General

Online Degrees - Distance Learning
The Heap
Russian
Google