Hello, I was just wondering if it is possible to create a data struct in assembly 8086. For example, creating a struct that holds a student's name and ID number.

It is somewhat helpful, but I don't want to code structs in c++, I was wondering if you could literally code structs in assembly language (8086)

What assembler?

emu8086

Creating a data structure in 8086 assembler is as simple as declaring
any other data variables.

MYVAR1 DB 0 ; an 8-bit quantity

FAR_OFF DW 0 ; a 32-bit far pointer
FAR_SEG DW 0

; Now for the mentioned data structure
StudentId DW 0 ; this is also the address of the structure
StudentName DB ? DUP(64) ; Create 64-byte Character Array For Name

also some assemblers provide a STRUCT directive

STRUCT MyStruct
 StudentId DW ?
 StudentName DB ? DUP(64)
END STRUCT

Declare an instance of the structure and then you should be
able to refer to it's members by name and create other
instances.

how we can pass use that struct into external methods. i mean what if we invoke the method . how we can pass the struct?

Pass a pointer to the struct

allright. if i pass addr. of StudentId can i say assume ebx:ptr StudentId and then use other fields myStruct.studentName etc.
by the way 8086

If you had a pointer to StudentID and you wished to reference StudentName, you'd just have to add the size of StudentID to your pointer, then your pointer would be pointing at StudentName

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.